feat: add config to docker

This commit is contained in:
Timothy Schenk 2023-11-16 18:48:29 +01:00
parent a247f82a8f
commit 58f4448438
3 changed files with 34 additions and 26 deletions

View file

@ -21,3 +21,4 @@ repos:
rev: v2.12.0 rev: v2.12.0
hooks: hooks:
- id: hadolint-docker - id: hadolint-docker
args: [--ignore, SC2086]

View file

@ -7,17 +7,16 @@ ENV TZ=Etc/UTC
ENV DOTNET_TieredPGO=1 ENV DOTNET_TieredPGO=1
ENV DOTNET_CLI_TELEMETRY_OPTOUT=1 ENV DOTNET_CLI_TELEMETRY_OPTOUT=1
RUN echo "Target: $TARGETARCH" RUN echo "Target: $TARGETARCH" && echo "Build: $BUILDPLATFORM"
RUN echo "Build: $BUILDPLATFORM"
WORKDIR /src WORKDIR /src
COPY ["Wonderking/Wonderking.csproj", "Wonderking/"] COPY ["Wonderking/Wonderking.csproj", "Wonderking/"]
COPY ["Server/Server.csproj", "Server/"] COPY ["Server/Server.csproj", "Server/"]
RUN dotnet restore "Wonderking/Wonderking.csproj" -a $TARGETARCH RUN dotnet restore "Wonderking/Wonderking.csproj" -a $TARGETARCH && dotnet restore "Server/Server.csproj" -a $TARGETARCH
RUN dotnet restore "Server/Server.csproj" -a $TARGETARCH
COPY . . COPY . .
FROM build AS publish FROM build AS publish
RUN dotnet publish "Server/Server.csproj" -c Release -a $TARGETARCH --no-restore -f net8.0 -o /app RUN dotnet publish "Server/Server.csproj" -c Release -a $TARGETARCH --no-restore -f net8.0 -o /app
COPY ../config /app/config
FROM base AS final FROM base AS final
WORKDIR /app WORKDIR /app

View file

@ -1,44 +1,52 @@
services: services:
server: server:
container_name: continuity-server container_name: continuity-server
image: continuity:latest image: continuity:latest
restart: always restart: always
depends_on: depends_on:
- db - db
environment: environment:
- ENVIRONMENT=Development - ENVIRONMENT=Development
- Testing:CreateAccountOnLogin=true - Testing:CreateAccountOnLogin=true
- DB:Host=db - DB:Host=db
- DB:Port=5432 - DB:Port=5432
- DB:Username=continuity - DB:Username=continuity
- DB:Password=continuity - DB:Password=continuity
- Game:Data:Path=/app/data/ - Game:Data:Path=/app/data/
networks: networks:
- continuity - continuity
ports: ports:
- "10001:10001" - 10001:10001
volumes: volumes:
- type: bind - type: bind
source: ../wk-data source: ../wk-data
target: /app/data target: /app/data
read_only: true read_only: true
- type: bind
source: ../wk-logs
target: /app/logs
read_only: false
- type: bind
source: ../config
target: /app/config
read_only: true
db: db:
container_name: continuity-db container_name: continuity-db
image: postgres:16.1-alpine image: postgres:16.1-alpine
restart: always restart: always
environment: environment:
- POSTGRES_USER=continuity - POSTGRES_USER=continuity
- POSTGRES_DB=continuity - POSTGRES_DB=continuity
- POSTGRES_PASSWORD=continuity - POSTGRES_PASSWORD=continuity
networks: networks:
- continuity - continuity
ports: ports:
- "5432:5432" - 5432:5432
volumes: volumes:
- db-data:/var/lib/postgresql/data - db-data:/var/lib/postgresql/data
healthcheck: healthcheck:
test: [ "CMD-SHELL", "pg_isready -U ${POSTGRES_USER} -d ${POSTGRES_DB}" ] test: [CMD-SHELL, 'pg_isready -U ${POSTGRES_USER} -d ${POSTGRES_DB}']
interval: 10s interval: 10s
timeout: 3s timeout: 3s
retries: 3 retries: 3