diff --git a/docker-compose.yml b/docker-compose.yml index 2892638..19d4da5 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -8,10 +8,17 @@ services: # - 5000:5000 networks: sodoff_network: + # use static ip address for nginx proxy configuration + # - if run multiple instances of this docker, each instance should use unique address + # - if do not use proxy, port mapping as above should be enough ipv4_address: 172.16.99.10 networks: sodoff_network: + name: sodoff_network + # bellow network configuration should be put in at least one file + # - but it may be in many or all + # - without it it will work like `external: true` driver: bridge ipam: config: diff --git a/src/Dockerfile b/src/Dockerfile index 5b06dd8..e4fc8a9 100644 --- a/src/Dockerfile +++ b/src/Dockerfile @@ -1,20 +1,22 @@ -#See https://aka.ms/customizecontainer to learn how to customize your debug container and how Visual Studio uses this Dockerfile to build your images for faster debugging. - -FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS base -WORKDIR /app - +# Use the official .NET SDK image for building the application FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build WORKDIR /src -COPY ["src/sodoff.csproj", "src/"] -RUN dotnet restore "src/sodoff.csproj" + +# Copy the source code COPY . . -WORKDIR "/src/src" -RUN dotnet build "sodoff.csproj" -c Release -o /app/build -FROM build AS publish -RUN dotnet publish "sodoff.csproj" -c Release -o /app/publish /p:UseAppHost=false +# Restore dependencies and build the application +RUN dotnet build -c Release -o /app -FROM base AS final +# move mods and assets directors from sources to /app +RUN mv src/mods /app && ln -s /app/mods src/ +RUN mv src/assets /app && ln -s /app/assets src/ + +# Create clean run environment (without source and sdk) +# FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS base +# WORKDIR /app +# COPY --from=build /app . + +# Run the application WORKDIR /app -COPY --from=publish /app/publish . -ENTRYPOINT ["dotnet", "sodoff.dll"] +ENTRYPOINT ["./sodoff"]