-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathDockerfile
39 lines (29 loc) · 1.03 KB
/
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
# https://www.sethvargo.com/writing-github-actions-in-go/
FROM golang:1.19-buster AS builder
# Install upx to compress the binary
# https://packages.debian.org/buster/utils/upx-ucl
RUN apt-get update && apt-get -y install upx-ucl
ENV CGO_ENABLED=0
WORKDIR /src/export-workflow-logs
COPY . .
# Compile the action - the added flags instruct Go to produce a standalone binary
RUN go build \
-a \
-trimpath \
-ldflags "-s -w -extldflags '-static'" \
-installsuffix cgo \
-tags netgo \
-o /bin/action \
.
# Strip any symbols (this is not a library) then compress the action
RUN strip /bin/action
RUN upx -q -9 /bin/action
FROM scratch
# Copy over SSL certificates from the first step - this is required
# if our code makes any outbound SSL connections because it contains
# the root CA bundle.
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
# Copy over the compiled action from the first step
COPY --from=builder /bin/action /bin/action
# Specify the container's entrypoint as the action
ENTRYPOINT ["/bin/action"]