-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
71 lines (54 loc) · 2.41 KB
/
Copy pathDockerfile
File metadata and controls
71 lines (54 loc) · 2.41 KB
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# Unified image for services-control-plane.
#
# Contains BOTH the Go control-freak binary (serve / operator) and the Next.js
# web app (BFF). The same image runs either entrypoint:
# - server/operator: ./control-freak serve|operator (default CMD)
# - web app: node /app/web/server.js (override command)
#
# Build from the repo root: docker build -t control-freak:local .
# --- Go build stage ---------------------------------------------------------
FROM golang:1.26-alpine AS go-builder
WORKDIR /app
RUN apk add --no-cache git curl
COPY go.mod go.sum ./
RUN go mod download
COPY . .
RUN CGO_ENABLED=0 GOOS=linux go build -installsuffix cgo -o control-freak ./cmd/control-freak
# Download migrate tool (pre-built binary)
RUN curl -L https://github.com/golang-migrate/migrate/releases/download/v4.18.3/migrate.linux-amd64.tar.gz | tar xvz && \
mv migrate /usr/local/bin/migrate
# --- Web build stage --------------------------------------------------------
FROM node:24-alpine AS web-builder
RUN corepack enable
WORKDIR /app/web
COPY web/package.json web/pnpm-lock.yaml ./
RUN pnpm install --frozen-lockfile
COPY web/ ./
RUN pnpm run build
# --- Final stage (Node base so it can run the web app too) ------------------
FROM node:24-alpine
RUN apk --no-cache add ca-certificates bash
WORKDIR /app
# Go server binary + migrate tooling
COPY --from=go-builder /app/control-freak ./control-freak
COPY --from=go-builder /usr/local/bin/migrate /usr/local/bin/migrate
COPY store/psql/migrations /app/store/psql/migrations
COPY script /app/script
# .proto files are read at runtime by the web app's gRPC client.
COPY proto /app/proto
COPY proto-internal /app/proto-internal
# Next.js standalone output (server.js + pruned node_modules) and assets.
COPY --from=web-builder /app/web/.next/standalone /app/web
COPY --from=web-builder /app/web/.next/static /app/web/.next/static
COPY --from=web-builder /app/web/public /app/web/public
# Set up MOTD for interactive shells
RUN echo '[ -f /app/script/motd.sh ] && /app/script/motd.sh' >> /etc/profile.d/motd.sh
ENV MIGRATE_BINARY="migrate" \
MIGRATIONS_PATH="/app/store/psql/migrations" \
PROTO_DIR="/app" \
NODE_ENV="production"
# gRPC (9000) for the server, HTTP (3000) for the web app.
EXPOSE 9000 3000
# Default entrypoint is the control-freak server; the web Deployment overrides
# the command to `node /app/web/server.js`.
CMD ["./control-freak", "serve", "--plaintext"]