-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
38 lines (28 loc) · 847 Bytes
/
Dockerfile
File metadata and controls
38 lines (28 loc) · 847 Bytes
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
FROM golang:1.25.5-alpine3.23 AS build
LABEL site="auth"
LABEL stage="builder"
WORKDIR /src/
ARG WAUTH_VERSION_ARG
ARG WAUTH_COMMIT_ARG
RUN apk --no-cache add ca-certificates
# Stores our dependencies
COPY go.mod .
COPY go.sum .
# Download dependencies
RUN go mod download
# Copy source
COPY . .
# Set build variables
RUN echo -n "-X 'main.Version=$WAUTH_VERSION_ARG" > ./ldflags && \
tr -d \\n < ./ldflags > ./temp && mv ./temp ./ldflags && \
echo -n "' -X 'main.Commit=$WAUTH_COMMIT_ARG" >> ./ldflags && \
tr -d \\n < ./ldflags > ./temp && mv ./temp ./ldflags && \
echo -n "'" >> ./ldflags
# Build the executable
RUN GOOS=linux GOARCH=amd64 go build -ldflags="$(cat ./ldflags)" -o /bin/auth
# Run the executable
FROM scratch
LABEL site="auth"
# Copy binary
COPY --from=build /bin/auth /bin/auth
ENTRYPOINT ["/bin/auth"]