-
Notifications
You must be signed in to change notification settings - Fork 18
/
Dockerfile
48 lines (31 loc) · 1018 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
46
47
48
FROM node:20-bookworm-slim AS uibuilder
ARG TARGETOS
ARG TARGETARCH
RUN echo "I am building ui for OS:$TARGETOS, ARCH:$TARGETARCH" > /log
# set up ui build
RUN mkdir -p /wt_build
WORKDIR /wt_build
COPY ui/ ./ui
RUN npm install yarn
WORKDIR /wt_build/ui
# run ui build
RUN yarn install
RUN yarn build
FROM golang:1.23-bookworm AS gobuilder
ARG TARGETOS
ARG TARGETARCH
WORKDIR /work
# copy ui build from previous stage
COPY --from=uibuilder /wt_build/ui/dist ./ui/dist
COPY . ./
RUN echo "I am building go for GOOS:$TARGETOS, GOARCH:$TARGETARCH" > /log
RUN CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} go mod download && go mod verify
RUN CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build -ldflags="-w -s" -v -o /wiretap wiretap.go
FROM alpine:3.20.3 AS runner
ARG TARGETPLATFORM
ARG BUILDPLATFORM
RUN echo "I am running on $TARGETPLATFORM, was built on $BUILDPLATFORM" > /log
# copy only the built binary
COPY --from=gobuilder /wiretap /wiretap
ENV PATH=$PATH:/
ENTRYPOINT ["wiretap"]