forked from Jont828/cluster-api-visualizer
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Dockerfile
55 lines (37 loc) · 1.05 KB
/
Dockerfile
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
# syntax=docker/dockerfile:1
# Build
ARG ARCH
# Build the web app.
FROM node:20 as web-builder
WORKDIR /app
COPY ./web /app
RUN npm config set registry http://registry.npmjs.org/
RUN npm install --verbose
RUN npm run build
# Build the Go binary.
# Alpine is chosen for its small footprint
# compared to Ubuntu
FROM golang:1.21-alpine as builder
# Need to redeclare ARCH to use in Go build stage
ARG ARCH
ARG ldflags
# Set working directory
WORKDIR /app
# Download necessary Go modules
COPY go.mod ./
COPY go.sum ./
RUN --mount=type=cache,target=/go/pkg/mod \
go mod download
COPY ./main.go /app/
COPY ./internal /app/internal
COPY ./version /app/version
COPY ./api /app/api
RUN CGO_ENABLED=0 GOARCH=${ARCH} go build -trimpath -ldflags "${ldflags} -extldflags '-static'" -o main
# Build production image
FROM gcr.io/distroless/static:nonroot-${ARCH}
# Set working directory
WORKDIR /app
COPY --from=builder /app/main /app/main
COPY --from=web-builder /app/dist /app/web/dist
EXPOSE 8081
ENTRYPOINT [ "/app/main", "-host", "0.0.0.0", "-generate-config" ]