0

I have an application built with .NET 8 and MySQL 8.0 inside on docker container, and I need to deploy this container on IIS so that each user can access it via IP on the local network. My question is: is it possible to do this just by running a container of this application using a specific Dockerfile?

My dockerfile:

FROM mcr.microsoft.com/dotnet/aspnet:8.0-windowsservercore-ltsc2019 AS base
WORKDIR /app
EXPOSE 8080
EXPOSE 8081


FROM mcr.microsoft.com/dotnet/sdk:8.0-windowsservercore-ltsc2019 AS build
ARG BUILD_CONFIGURATION=Release
WORKDIR /src
COPY ["HMS/HMS.csproj", "HMS/"]
COPY ["HMS.Infra.IoC/HMS.Infra.IoC.csproj", "HMS.Infra.IoC/"]
COPY ["HMS.Data/HMS.Data.csproj", "HMS.Data/"]
COPY ["HMS.Domain/HMS.Domain.csproj", "HMS.Domain/"]
RUN dotnet restore "./HMS/HMS.csproj"
COPY . .
WORKDIR "/src/HMS"
RUN dotnet build "./HMS.csproj" -c %BUILD_CONFIGURATION% -o /app/build

FROM build AS publish
ARG BUILD_CONFIGURATION=Release
RUN dotnet publish "./HMS.csproj" -c %BUILD_CONFIGURATION% -o /app/publish /p:UseAppHost=false

FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "HMS.dll"]

My docker compose with mysql:

version: '3.9'

services:
  mysql:
    image: mysql:8.0
    container_name: hms-mysql
    restart: always
    environment:
      MYSQL_ROOT_PASSWORD: password of server
    ports:
      - "3306:3306"
    networks:
      hms-net:
        aliases:
          - localhost

  hms:  # <-- nome do projeto principal ASP.NET
    build:
      context: .
      dockerfile: HMS/Dockerfile  # Ajuste conforme o caminho do seu Dockerfile
    container_name: hms-iis
    depends_on:
      - mysql
    ports:
      - "8080:8080"
    extra_hosts:
      - "host.docker.internal:host-gateway"
    networks:
      - hms-net
    environment:
      - ASPNETCORE_ENVIRONMENT=Development

networks:
  hms-net:
    driver: bridge
2
  • that makes little sense, a container is already everything you need. There's no need to wrap it into some other kind of container like a web-server, as this is literally contained in your container already. All you need to do is run that container on any arbitrary machine (that has some docker-engine, of course). Once it runs, it will start the contained web-server. Commented Apr 10 at 6:02
  • @MakePeaceGreatAgain Yeah, I know. It's just something the client asked for — they want the app running on IIS because it works better for their network setup. Commented Apr 11 at 0:00

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.