-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathDockerfile
More file actions
101 lines (77 loc) · 2.87 KB
/
Copy pathDockerfile
File metadata and controls
101 lines (77 loc) · 2.87 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
# Build arguments for multi-arch support
ARG BUILDPLATFORM
ARG TARGETPLATFORM
ARG TARGETOS
ARG VERSION=0.0.1
# Stage 1: Build Frontend
FROM --platform=linux/amd64 node:22-alpine AS frontend-build
ARG SENTRY_AUTH_TOKEN
ARG VITE_SENTRY_DSN
WORKDIR /src
# Enable pnpm via corepack
ENV COREPACK_ENABLE_DOWNLOAD_PROMPT=0
RUN corepack enable
# Copy frontend package files
COPY boardgametracker.client/package.json boardgametracker.client/pnpm-lock.yaml ./
RUN pnpm install --frozen-lockfile --ignore-scripts
# Copy frontend source
COPY boardgametracker.client/ ./
# Build frontend (SENTRY_AUTH_TOKEN enables sourcemap upload via @sentry/vite-plugin)
ENV SENTRY_AUTH_TOKEN=${SENTRY_AUTH_TOKEN}
ENV VITE_SENTRY_DSN=${VITE_SENTRY_DSN}
RUN pnpm build
# Stage 2: Build Backend
FROM mcr.microsoft.com/dotnet/sdk:10.0-alpine AS backend-build
ARG VERSION
WORKDIR /src
# Copy Directory.Build.props (affects MSBuild behavior)
COPY Directory.Build.props ./
# Copy project files for restore
COPY BoardGameTracker.Common/BoardGameTracker.Common.csproj BoardGameTracker.Common/
COPY BoardGameTracker.Core/BoardGameTracker.Core.csproj BoardGameTracker.Core/
COPY BoardGameTracker.Api/BoardGameTracker.Api.csproj BoardGameTracker.Api/
COPY BoardGameTracker.Host/BoardGameTracker.Host.csproj BoardGameTracker.Host/
# Restore dependencies
RUN dotnet restore BoardGameTracker.Host/BoardGameTracker.Host.csproj
# Copy source code
COPY BoardGameTracker.Common/ BoardGameTracker.Common/
COPY BoardGameTracker.Core/ BoardGameTracker.Core/
COPY BoardGameTracker.Api/ BoardGameTracker.Api/
COPY BoardGameTracker.Host/ BoardGameTracker.Host/
# Copy frontend build output to wwwroot
COPY --from=frontend-build /src/dist BoardGameTracker.Host/wwwroot
# Build and publish backend
WORKDIR /src/BoardGameTracker.Host
RUN ASSEMBLY_VERSION=$(echo "${VERSION}" | cut -d'-' -f1) && \
dotnet publish \
-c Release \
-o /app/publish \
--no-restore \
/p:Version=${ASSEMBLY_VERSION} \
/p:BuildWithoutEsproj=true
# Stage 3: Runtime
FROM mcr.microsoft.com/dotnet/aspnet:10.0-alpine AS runtime
# Build arguments for runtime configuration
ARG ASPNETCORE_ENVIRONMENT=production
ARG ASPNETCORE_URLS=http://*:5444
WORKDIR /app
RUN apk add --no-cache curl su-exec poppler-utils
RUN mkdir -p /app/images /app/logs /app/manuals
# Copy published files from backend build stage
COPY --from=backend-build /app/publish .
# Copy entrypoint script
COPY entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh
# Set environment variables
ENV ASPNETCORE_ENVIRONMENT=${ASPNETCORE_ENVIRONMENT}
ENV DOTNET_EnableDiagnostics=0
ENV ASPNETCORE_URLS=${ASPNETCORE_URLS}
# Default PUID/PGID (can be overridden at runtime)
ENV PUID=1654
ENV PGID=1654
# Expose port
EXPOSE 5444
# Health check
HEALTHCHECK --interval=30s --timeout=5s --start-period=10s --retries=3 \
CMD curl --fail http://localhost:5444/api/health || exit 1
ENTRYPOINT ["/entrypoint.sh"]