-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci: update goreleaser config to build docker images
This might be broken - fixing CI stuff is annoying.
- Loading branch information
1 parent
fd01dda
commit 109e8d6
Showing
5 changed files
with
123 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
# Thanks to https://chemidy.medium.com/create-the-smallest-and-secured-golang-docker-image-based-on-scratch-4752223b7324 | ||
############################ | ||
# STEP 1 build executable binary | ||
############################ | ||
FROM golang:alpine AS builder | ||
|
||
ENV USER=certstreamserver | ||
ENV UID=10001 | ||
|
||
# Create user | ||
RUN adduser \ | ||
--disabled-password \ | ||
--gecos "" \ | ||
--home "/nonexistent" \ | ||
--shell "/sbin/nologin" \ | ||
--no-create-home \ | ||
--uid "${UID}" \ | ||
"${USER}" | ||
|
||
# Install git. Git is required for fetching the dependencies. | ||
RUN apk update && apk add --no-cache git | ||
WORKDIR $GOPATH/src/certstream-server-go/ | ||
COPY . . | ||
|
||
# Fetch dependencies. | ||
RUN go mod download | ||
|
||
# Build the binary. | ||
RUN go build -ldflags="-w -s" -o /go/bin/certstream-server-go $GOPATH/src/certstream-server-go/cmd | ||
RUN chown -R "${USER}:${USER}" /go/bin/certstream-server-go | ||
|
||
############################ | ||
# STEP 2 build a small image | ||
############################ | ||
FROM alpine | ||
|
||
WORKDIR /app | ||
|
||
# Import the user and group files from the builder. | ||
COPY --from=builder /etc/passwd /etc/passwd | ||
COPY --from=builder /etc/group /etc/group | ||
|
||
# Copy our static executable. | ||
COPY --from=builder /go/bin/certstream-server-go /app/certstream-server-go | ||
COPY ./config.sample.yaml /app/config.yaml | ||
|
||
# Use an unprivileged user. | ||
USER certstreamserver:certstreamserver | ||
|
||
EXPOSE 8080 | ||
|
||
ENTRYPOINT ["/app/certstream-server-go"] |