Server
This commit is contained in:
58
Dockerfile
Normal file
58
Dockerfile
Normal file
@@ -0,0 +1,58 @@
|
||||
# ═══════════════════════════════════════════════════════════════════════════
|
||||
# GeoSus Server Dockerfile
|
||||
# ═══════════════════════════════════════════════════════════════════════════
|
||||
# Multi-stage build pro optimální velikost image
|
||||
#
|
||||
# Build: docker build -t geosus-server .
|
||||
# Run: docker run -d -p 7777:7777 -p 8088:8088 --name geosus geosus-server
|
||||
# ═══════════════════════════════════════════════════════════════════════════
|
||||
|
||||
# ─────────────────────────────────────────────────────────────────────────────
|
||||
# STAGE 1: Build
|
||||
# ─────────────────────────────────────────────────────────────────────────────
|
||||
FROM mcr.microsoft.com/dotnet/sdk:9.0 AS build
|
||||
WORKDIR /src
|
||||
|
||||
# Kopíruj pouze csproj pro využití cache vrstev
|
||||
COPY Server.csproj ./
|
||||
RUN dotnet restore
|
||||
|
||||
# Kopíruj zbytek zdrojáků a builduj
|
||||
COPY . ./
|
||||
RUN dotnet publish -c Release -o /app
|
||||
|
||||
# ─────────────────────────────────────────────────────────────────────────────
|
||||
# STAGE 2: Runtime
|
||||
# ─────────────────────────────────────────────────────────────────────────────
|
||||
FROM mcr.microsoft.com/dotnet/aspnet:9.0 AS runtime
|
||||
WORKDIR /app
|
||||
|
||||
# Vytvoř uživatele bez root práv
|
||||
RUN groupadd -r geosus && useradd -r -g geosus geosus
|
||||
|
||||
# Kopíruj build output
|
||||
COPY --from=build /app ./
|
||||
|
||||
# Vytvoř složku pro data s právy
|
||||
RUN mkdir -p /app/data && chown -R geosus:geosus /app
|
||||
|
||||
# Přepni na non-root uživatele
|
||||
USER geosus
|
||||
|
||||
# Exponuj porty
|
||||
# TCP 7777 - Herní komunikace (binární protokol)
|
||||
# HTTP 8088 - Stats REST API
|
||||
EXPOSE 7777
|
||||
EXPOSE 8088
|
||||
|
||||
# Health check
|
||||
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
|
||||
CMD curl -f http://localhost:8088/health || exit 1
|
||||
|
||||
# Environment variables pro konfiguraci
|
||||
ENV DOTNET_ENVIRONMENT=Production
|
||||
ENV GEOSUS_TCP_PORT=7777
|
||||
ENV GEOSUS_HTTP_PORT=8088
|
||||
|
||||
# Spuštění
|
||||
ENTRYPOINT ["dotnet", "Server.dll"]
|
||||
Reference in New Issue
Block a user