Fix Docker build: Debian Node image, npx vite build, .dockerignore

This commit is contained in:
David Alvarez
2026-05-23 18:13:00 +02:00
parent 70fba6d14a
commit aad4ec21a6
2 changed files with 29 additions and 14 deletions
+15
View File
@@ -0,0 +1,15 @@
# Prevent local build artifacts from leaking into Docker
node_modules/
frontend/node_modules/
dist/
frontend/dist/
# Runtime data
data/
# IDE
.vscode/
.idea/
# Binary
dostalgia
+14 -14
View File
@@ -1,25 +1,25 @@
# Dostalgia — Dockerized DOS game hub
# Dostalgia — Multi-stage Docker build
# ─── Build frontend ───────────────────────────────
FROM node:20-alpine AS frontend-builder
WORKDIR /src
# ─── 1. Build frontend ───────────────────────────
FROM node:20-bookworm AS frontend
WORKDIR /build
COPY frontend/package.json frontend/package-lock.json ./
RUN npm install --legacy-peer-deps
RUN npm ci --only=production 2>/dev/null || npm install --legacy-peer-deps
COPY frontend/ ./
RUN npm run build
RUN npx vite build
# ─── Build Go binary ─────────────────────────────
FROM golang:1.23-alpine AS go-builder
WORKDIR /src
# ─── 2. Build Go binary ──────────────────────────
FROM golang:1.23-bookworm AS gobuild
WORKDIR /build
COPY go.mod ./
COPY *.go ./
COPY --from=frontend-builder /src/dist ./frontend/dist/
COPY --from=frontend /build/dist ./frontend/dist/
RUN CGO_ENABLED=0 go build -o /dostalgia .
# ─── Runtime ─────────────────────────────────────
FROM alpine:3.20
RUN apk add --no-cache ca-certificates tzdata
COPY --from=go-builder /dostalgia /dostalgia
# ─── 3. Runtime ──────────────────────────────────
FROM debian:bookworm-slim
RUN apt-get update -qq && apt-get install -y -qq --no-install-recommends ca-certificates tzdata && rm -rf /var/lib/apt/lists/*
COPY --from=gobuild /dostalgia /dostalgia
VOLUME /data
EXPOSE 8765
ENV DOSTALGIA_DATA=/data