-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDockerfile
45 lines (30 loc) · 840 Bytes
/
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
# Cache gogcc alpine
FROM --platform=$BUILDPLATFORM golang:1.23-alpine as gogcc
# Accept the target architecture as a build argument
ARG TARGETARCH
ENV GOOS=linux
ENV CGO_ENABLED=0
RUN apk update && apk add --no-cache \
gcc \
musl-dev
# Set the GOARCH environment variable based on the TARGETARCH build argument
ENV GOARCH=$TARGETARCH
# Build the binary
FROM gogcc as builder
WORKDIR /app
# Download dependencies
COPY go.mod ./
COPY go.sum ./
RUN go mod download
# Build /app/bin
COPY . .
RUN go build -ldflags="-s -w" -o bin -v ./cmd/dashboard/main.go
# Serve the binary with pb_public
FROM alpine:latest as bin
RUN apk update && apk add --no-cache \
ca-certificates
WORKDIR /app/
COPY pb_public ./pb_public
COPY --from=builder /app/bin .
EXPOSE 8080
CMD ["/app/bin", "serve", "--http=0.0.0.0:8090"]