-
-
Notifications
You must be signed in to change notification settings - Fork 70
Expand file tree
/
Copy pathDockerfile
More file actions
37 lines (28 loc) · 895 Bytes
/
Dockerfile
File metadata and controls
37 lines (28 loc) · 895 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
# Stage 1: Build frontend
FROM node:22 AS frontend-builder
WORKDIR /app/frontend
COPY frontend/package.json frontend/yarn.lock ./
RUN yarn install --frozen-lockfile --network-timeout 1000000
COPY frontend/ ./
RUN yarn build
# Stage 2: Build Go binary
FROM --platform=${BUILDPLATFORM} golang:1.26 AS builder
ARG TARGETOS
ARG TARGETARCH
WORKDIR /app
# Copy go mod files first for better caching
COPY go.mod go.sum ./
RUN go mod download
# Copy source code
COPY . .
# Copy frontend build to internal/web/build for embedding
COPY --from=frontend-builder /app/frontend/build ./internal/web/build/
# Build the binary
RUN CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} \
go build -ldflags="-s -w" -o /forecastle ./cmd/forecastle
# Stage 3: Runtime image
FROM gcr.io/distroless/static:nonroot
WORKDIR /
COPY --from=builder /forecastle .
USER nonroot:nonroot
ENTRYPOINT ["/forecastle"]