-
Notifications
You must be signed in to change notification settings - Fork 92
/
Dockerfile
30 lines (21 loc) · 955 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
# Define argument for linker flags
ARG LDFLAGS=-s -w
# Use a temporary build image based on Golang 1.20-alpine
FROM golang:1.23-alpine as builder
# Set environment variables: linker flags and disable CGO
ENV LDFLAGS=$LDFLAGS CGO_ENABLED=0
# Add the current directory contents to the work directory in the container
ADD . /work
# Set the current work directory inside the container
WORKDIR /work
# Install git and build the edgevpn binary with the provided linker flags
# --no-cache flag ensures the package cache isn't stored in the layer, reducing image size
RUN apk add --no-cache git && \
go build -ldflags="$LDFLAGS" -o edgevpn
# TODO: move to distroless
# Use a new, clean alpine image for the final stage
FROM alpine
# Copy the edgevpn binary from the builder stage to the final image
COPY --from=builder /work/edgevpn /usr/bin/edgevpn
# Define the command that will be run when the container is started
ENTRYPOINT ["/usr/bin/edgevpn"]