-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
40 lines (26 loc) · 897 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
FROM golang:1.23-alpine3.20 AS builder
ARG GITHUB_TOKEN=""
# Setup base software for building app
RUN apk update && \
apk add bash ca-certificates git gcc g++ libc-dev binutils file
# Setup token to access private repositories in gitlab. Temp solution.
RUN git config --global --add \
url."https://oauth2:${GITHUB_TOKEN}@github.com/goverland-labs/".insteadOf "https://github.com/goverland-labs/"
WORKDIR /opt
# Set up go env
RUN go env -w GOPRIVATE=github.com/goverland-labs/*
# Download dependencies
COPY go.mod go.sum ./
RUN go mod download && go mod verify
# Copy an application's source
COPY . .
# Build an application
RUN go build -o bin/application .
# Prepare executor image
FROM alpine:3.20 AS production
RUN apk update && \
apk add ca-certificates libc6-compat && \
rm -rf /var/cache/apk/*
WORKDIR /opt
COPY --from=builder /opt/bin/ ./
CMD ["./application"]