chore: add Dockerfile for Go backend
Multi-stage build that compiles server, CLI, and migrate binaries, then produces a minimal Alpine runtime image. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
038dac7fcb
commit
ce43ff014d
1 changed files with 36 additions and 0 deletions
36
Dockerfile
Normal file
36
Dockerfile
Normal file
|
|
@ -0,0 +1,36 @@
|
||||||
|
# --- Build stage ---
|
||||||
|
FROM golang:1.26-alpine AS builder
|
||||||
|
|
||||||
|
RUN apk add --no-cache git
|
||||||
|
|
||||||
|
WORKDIR /src
|
||||||
|
|
||||||
|
# Cache dependencies
|
||||||
|
COPY server/go.mod server/go.sum ./server/
|
||||||
|
RUN cd server && go mod download
|
||||||
|
|
||||||
|
# Copy server source
|
||||||
|
COPY server/ ./server/
|
||||||
|
|
||||||
|
# Build binaries
|
||||||
|
ARG VERSION=dev
|
||||||
|
ARG COMMIT=unknown
|
||||||
|
RUN cd server && CGO_ENABLED=0 go build -ldflags "-s -w" -o bin/server ./cmd/server
|
||||||
|
RUN cd server && CGO_ENABLED=0 go build -ldflags "-s -w -X main.version=${VERSION} -X main.commit=${COMMIT}" -o bin/multica ./cmd/multica
|
||||||
|
RUN cd server && CGO_ENABLED=0 go build -ldflags "-s -w" -o bin/migrate ./cmd/migrate
|
||||||
|
|
||||||
|
# --- Runtime stage ---
|
||||||
|
FROM alpine:3.21
|
||||||
|
|
||||||
|
RUN apk add --no-cache ca-certificates tzdata
|
||||||
|
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
COPY --from=builder /src/server/bin/server .
|
||||||
|
COPY --from=builder /src/server/bin/multica .
|
||||||
|
COPY --from=builder /src/server/bin/migrate .
|
||||||
|
COPY server/migrations/ ./migrations/
|
||||||
|
|
||||||
|
EXPOSE 8080
|
||||||
|
|
||||||
|
ENTRYPOINT ["./server"]
|
||||||
Loading…
Add table
Add a link
Reference in a new issue