Fix Docker build: Debian Node image, npx vite build, .dockerignore
This commit is contained in:
@@ -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
@@ -1,25 +1,25 @@
|
|||||||
# Dostalgia — Dockerized DOS game hub
|
# Dostalgia — Multi-stage Docker build
|
||||||
|
|
||||||
# ─── Build frontend ───────────────────────────────
|
# ─── 1. Build frontend ───────────────────────────
|
||||||
FROM node:20-alpine AS frontend-builder
|
FROM node:20-bookworm AS frontend
|
||||||
WORKDIR /src
|
WORKDIR /build
|
||||||
COPY frontend/package.json frontend/package-lock.json ./
|
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/ ./
|
COPY frontend/ ./
|
||||||
RUN npm run build
|
RUN npx vite build
|
||||||
|
|
||||||
# ─── Build Go binary ─────────────────────────────
|
# ─── 2. Build Go binary ──────────────────────────
|
||||||
FROM golang:1.23-alpine AS go-builder
|
FROM golang:1.23-bookworm AS gobuild
|
||||||
WORKDIR /src
|
WORKDIR /build
|
||||||
COPY go.mod ./
|
COPY go.mod ./
|
||||||
COPY *.go ./
|
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 .
|
RUN CGO_ENABLED=0 go build -o /dostalgia .
|
||||||
|
|
||||||
# ─── Runtime ─────────────────────────────────────
|
# ─── 3. Runtime ──────────────────────────────────
|
||||||
FROM alpine:3.20
|
FROM debian:bookworm-slim
|
||||||
RUN apk add --no-cache ca-certificates tzdata
|
RUN apt-get update -qq && apt-get install -y -qq --no-install-recommends ca-certificates tzdata && rm -rf /var/lib/apt/lists/*
|
||||||
COPY --from=go-builder /dostalgia /dostalgia
|
COPY --from=gobuild /dostalgia /dostalgia
|
||||||
VOLUME /data
|
VOLUME /data
|
||||||
EXPOSE 8765
|
EXPOSE 8765
|
||||||
ENV DOSTALGIA_DATA=/data
|
ENV DOSTALGIA_DATA=/data
|
||||||
|
|||||||
Reference in New Issue
Block a user