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