simplify/update docker config

- change docker config
  - by default include source in docker image for simple debug (can be disabled via uncoment section in Dockerfile)
  - fix/improve network config in docker-compose
This commit is contained in:
Robert Paciorek 2024-03-19 21:06:34 +00:00
parent e956985678
commit b5bb289a4e
2 changed files with 23 additions and 14 deletions

View File

@ -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:

View File

@ -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"]