All checks were successful
Build and Push / build (push) Successful in 44s
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
43 lines
1.1 KiB
Docker
43 lines
1.1 KiB
Docker
# ---- Stage 1: Build frontend ----
|
|
FROM mirror.gcr.io/library/node:22-alpine AS frontend-build
|
|
WORKDIR /app/frontend
|
|
COPY frontend/package.json frontend/package-lock.json ./
|
|
RUN npm ci
|
|
COPY frontend/ ./
|
|
RUN npx vite build
|
|
|
|
# ---- Stage 2: Build Go backend ----
|
|
FROM mirror.gcr.io/library/golang:1.26-alpine AS backend-build
|
|
WORKDIR /app/backend
|
|
COPY backend/go.mod backend/go.sum ./
|
|
RUN go mod download
|
|
COPY backend/ ./
|
|
RUN CGO_ENABLED=0 GOOS=linux go build -ldflags="-s -w" -o /server ./cmd/server
|
|
|
|
# ---- Stage 3: Runtime ----
|
|
FROM mirror.gcr.io/library/alpine:3.21
|
|
RUN apk add --no-cache ca-certificates tzdata
|
|
WORKDIR /app
|
|
|
|
COPY --from=backend-build /server /app/server
|
|
COPY --from=frontend-build /app/frontend/dist /app/static
|
|
COPY data/ /app/data-seed/
|
|
|
|
EXPOSE 8080
|
|
|
|
ENV PORT=8080
|
|
ENV DATA_DIR=/app/data
|
|
|
|
# Copy seed data on first run if /app/data is empty (volume mount)
|
|
COPY <<'EOF' /app/entrypoint.sh
|
|
#!/bin/sh
|
|
if [ ! -f /app/data/tournaments.json ]; then
|
|
echo "Seeding initial data..."
|
|
cp -r /app/data-seed/* /app/data/
|
|
fi
|
|
exec /app/server -static /app/static -data /app/data
|
|
EOF
|
|
RUN chmod +x /app/entrypoint.sh
|
|
|
|
ENTRYPOINT ["/app/entrypoint.sh"]
|