- frontend.go: Seitenrouten liefern die index.html (no-cache), gehashte Assets unter /assets dauerhaft cachebar, sonst echtes 404 - /stats als Seite, /stats.html leitet per 301 weiter - Containerfile: Node-Stage baut das Frontend nach web/ - Vite baut nach ../web (gitignored); web/ (Vanilla-JS) gelöscht - notes/frontend.md, deploy.md angepasst Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TiXsPUqw7oeomZ8wZrQW5q
37 lines
1.3 KiB
Docker
37 lines
1.3 KiB
Docker
# Frontend-Stage: React-Build nach /src/web (siehe frontend/vite.config.ts).
|
|
# Erst nur die Paketdateien, damit npm ci bei reinen Code-Änderungen aus dem
|
|
# Cache kommt.
|
|
FROM docker.io/library/node:24-alpine AS frontend
|
|
WORKDIR /src/frontend
|
|
COPY frontend/package.json frontend/package-lock.json ./
|
|
RUN npm ci
|
|
COPY frontend/ ./
|
|
RUN npm run build
|
|
|
|
# Build-Stage: statisches Binary, CGO aus (pgx und modernc.org/sqlite für den
|
|
# einmaligen Import sind pures Go).
|
|
FROM docker.io/library/golang:1.26-alpine AS build
|
|
WORKDIR /src
|
|
COPY go.mod go.sum ./
|
|
RUN go mod download
|
|
COPY *.go ./
|
|
RUN CGO_ENABLED=0 go build -trimpath -ldflags="-s -w" -o /kver .
|
|
|
|
# Laufzeit-Stage: minimales Alpine, eigener unprivilegierter Nutzer.
|
|
FROM docker.io/library/alpine:3.22
|
|
RUN adduser -D -u 1000 kver
|
|
WORKDIR /app
|
|
COPY --from=build /kver /usr/local/bin/kver
|
|
COPY --from=frontend /src/web web/
|
|
COPY static/ static/
|
|
# data: GeoLite2-ASN-DB (und die alte SQLite-DB für den Import);
|
|
# static/media: Uploads. Beide als Volume persistieren.
|
|
RUN mkdir -p data static/media && chown kver:kver data static/media
|
|
USER kver
|
|
ENV KVER_ADDR=:8080
|
|
EXPOSE 8080
|
|
VOLUME ["/app/data", "/app/static/media"]
|
|
HEALTHCHECK --interval=30s --timeout=3s \
|
|
CMD wget -qO /dev/null http://localhost:8080/api/stats || exit 1
|
|
ENTRYPOINT ["/usr/local/bin/kver"]
|