Skip to content

Instantly share code, notes, and snippets.

@szabba
Created January 24, 2024 18:23
Show Gist options
  • Save szabba/850f8c39c7bc95dc9b01fa9298888bd2 to your computer and use it in GitHub Desktop.
Save szabba/850f8c39c7bc95dc9b01fa9298888bd2 to your computer and use it in GitHub Desktop.
VERSION 0.6
binary:
FROM golang:1.19.0
WORKDIR /work
COPY go.mod go.sum ./src
RUN (cd ./src && go mod download)
COPY . ./src
COPY . ./original-src
RUN (cd ./src && go mod tidy)
RUN git diff --no-index ./src ./original-src
RUN (cd ./src && go fmt ./...)
RUN git diff --no-index ./src ./original-src
RUN (cd ./src && CI_GOBIN_PREFIX=/.. go generate -x ./...)
RUN git diff --no-index ./src ./original-src
RUN (cd ./src && go build ./...)
RUN (cd ./src && go test -shuffle=on ./...)
RUN (cd ./src && CGO_ENABLED=0 go build -trimpath -o ${PWD}/../.bin/app ./cmd/app )
SAVE ARTIFACT ./.bin/app
alpine:
FROM alpine:edge
WORKDIR /work
RUN apk update
RUN apk add tzdata
SAVE ARTIFACT /usr/share/zoneinfo /zoneinfo
container-image:
FROM scratch
BUILD +binary
COPY +binary/app /app
COPY +alpine/zoneinfo /zoneinfo
ENV ZONEINFO /zoneinfo
ENV PORT 4447
ENTRYPOINT ["/app"]
SAVE IMAGE app
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment