Add Dockerfile for deployment.
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
# VCS / editor
|
||||
.git
|
||||
.gitignore
|
||||
*.md
|
||||
|
||||
# Node build artifacts (rebuilt inside the web stage)
|
||||
web/node_modules
|
||||
web/dist
|
||||
web/tsconfig.tsbuildinfo
|
||||
|
||||
# Local runtime data / secrets (never ship these into the image)
|
||||
data
|
||||
.env
|
||||
|
||||
# Docker files themselves
|
||||
Dockerfile
|
||||
.dockerignore
|
||||
+39
@@ -0,0 +1,39 @@
|
||||
# syntax=docker/dockerfile:1
|
||||
|
||||
# --- Stage 1: build the web frontend (web/dist) -----------------------------
|
||||
FROM node:22-bookworm-slim AS web
|
||||
WORKDIR /web
|
||||
# Install deps first for better layer caching. --include=dev is explicit so the
|
||||
# build works even if NODE_ENV=production leaks in (vite/tsc are devDependencies).
|
||||
COPY web/package.json web/package-lock.json ./
|
||||
RUN npm ci --include=dev
|
||||
COPY web/ ./
|
||||
RUN npm run build
|
||||
|
||||
# --- Stage 2: build the Go server binary ------------------------------------
|
||||
FROM golang:1.25-bookworm AS go
|
||||
WORKDIR /src
|
||||
# Cache module downloads separately from the source.
|
||||
COPY go.mod go.sum ./
|
||||
RUN go mod download
|
||||
COPY . .
|
||||
# modernc.org/sqlite is pure Go, so we can build a fully static binary.
|
||||
RUN CGO_ENABLED=0 go build -trimpath -ldflags="-s -w" -o /out/server ./cmd/server
|
||||
|
||||
# --- Stage 3: minimal runtime image -----------------------------------------
|
||||
FROM debian:bookworm-slim AS runtime
|
||||
RUN apt-get update \
|
||||
&& apt-get install -y --no-install-recommends ca-certificates \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
WORKDIR /app
|
||||
COPY --from=go /out/server /app/server
|
||||
COPY --from=web /web/dist /app/web/dist
|
||||
|
||||
# The server reads these at runtime (see cmd/server/main.go). DATA_DIR should be
|
||||
# backed by a Dokku persistent volume so the SQLite DB survives redeploys.
|
||||
ENV STATIC_DIR=/app/web/dist \
|
||||
DATA_DIR=/app/data \
|
||||
PORT=8080
|
||||
EXPOSE 8080
|
||||
|
||||
CMD ["/app/server"]
|
||||
@@ -1 +1 @@
|
||||
{"root":["./src/App.tsx","./src/api.ts","./src/main.tsx","./src/petArt.ts","./src/types.ts","./src/useGame.ts","./src/components/ArrangePhase.tsx","./src/components/BattlePhase.tsx","./src/components/CardView.tsx","./src/components/GameOver.tsx","./src/components/Home.tsx","./src/components/Lobby.tsx","./src/components/ShopPhase.tsx","./src/components/Table.tsx"],"version":"5.9.3"}
|
||||
{"root":["./src/App.tsx","./src/api.ts","./src/main.tsx","./src/petArt.ts","./src/types.ts","./src/useGame.ts","./src/components/ArrangePhase.tsx","./src/components/BattlePhase.tsx","./src/components/CardView.tsx","./src/components/DebugPanel.tsx","./src/components/Dice.tsx","./src/components/GameOver.tsx","./src/components/Home.tsx","./src/components/Lobby.tsx","./src/components/ShopPhase.tsx","./src/components/Table.tsx"],"version":"5.9.3"}
|
||||
Reference in New Issue
Block a user