-
Notifications
You must be signed in to change notification settings - Fork 2
/
Dockerfile
32 lines (22 loc) · 891 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
ARG ALPINE_VERSION="3.17"
ARG GO_VERSION="1.19-alpine3.17"
##
FROM golang:${GO_VERSION} AS binary_builder
# Install the system dependencies.
RUN apk add --no-cache upx
# Install the project dependencies.
WORKDIR /build
COPY go.mod go.sum ./
RUN go mod download
# Build and compress the binary for the target architecture and operating system.
COPY . .
RUN CGO_ENABLED=0 go build -v -ldflags="-w -s" -o dist/ . && \
upx --best --lzma dist/ghcr-cleaning-action
##
FROM alpine:${ALPINE_VERSION}
# No USER instruction as a container GitHub action must be run as root.
# See https://docs.github.com/en/actions/creating-actions/dockerfile-support-for-github-actions#user
# Copy the static executable from the builder stage.
COPY --from=binary_builder /build/dist/ghcr-cleaning-action /usr/local/bin/
# Set the container entrypoint.
ENTRYPOINT ["/usr/local/bin/ghcr-cleaning-action"]