ci: add Docker CD workflow to push images to GHCR

Multi-stage Dockerfile for smaller runtime image, CD workflow triggers
on main branch pushes and version tags, docker-compose defaults to the
prebuilt GHCR image.
This commit is contained in:
Houmgaor
2026-02-17 00:28:37 +01:00
parent 220de4cf3b
commit 7d54dd0ee6
3 changed files with 54 additions and 27 deletions

View File

@@ -1,14 +1,29 @@
FROM golang:1.25-alpine3.21
# Build stage
FROM golang:1.25-alpine3.21 AS builder
ENV GO111MODULE=on
WORKDIR /app/erupe
COPY go.mod .
COPY go.sum .
WORKDIR /build
COPY go.mod go.sum ./
RUN go mod download
COPY . .
RUN CGO_ENABLED=0 go build -o erupe-ce .
CMD [ "go", "run", "." ]
# Runtime stage
FROM alpine:3.21
RUN adduser -D -h /app erupe
WORKDIR /app
COPY --from=builder /build/erupe-ce .
COPY --from=builder /build/www/ ./www/
COPY --from=builder /build/schemas/ ./schemas/
# bundled-schema/ is optional demo data, copy if present
RUN mkdir -p bundled-schema
# bin/ and savedata/ are mounted at runtime via docker-compose
# config.json is also mounted at runtime
USER erupe
ENTRYPOINT ["./erupe-ce"]