-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
39 lines (26 loc) · 773 Bytes
/
Copy pathDockerfile
File metadata and controls
39 lines (26 loc) · 773 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# syntax=docker/dockerfile:1
# Multi-stage build for the Wiitoo monolith.
# Produces a minimal image (~8MB) with the compiled Go binary.
# ---- Stage 1: Build ----
FROM golang:1.26-alpine AS builder
RUN apk add --no-cache gcc musl-dev
WORKDIR /app
# Cache dependencies
COPY go.mod go.sum ./
RUN go mod download
# Copy source
COPY . .
# Build a statically-linked binary
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build \
-ldflags="-s -w" \
-o /wiitoo \
./cmd/wiitoo/
# ---- Stage 2: Minimal runtime image ----
FROM alpine:3.21
RUN apk add --no-cache ca-certificates tzdata
# Create a non-root user
RUN addgroup -S wiitoo && adduser -S wiitoo -G wiitoo
COPY --from=builder /wiitoo /usr/local/bin/wiitoo
USER wiitoo
EXPOSE 8080
ENTRYPOINT ["wiitoo"]