-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #24 from negz/continuous
Build a package using GitHub Actions
- Loading branch information
Showing
4 changed files
with
97 additions
and
63 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 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 |
---|---|---|
@@ -1,23 +1,30 @@ | ||
FROM golang:1.20 as build-stage | ||
# syntax=docker/dockerfile:1 | ||
|
||
WORKDIR /fn | ||
# We use the latest Go 1.x version unless asked to use something else. | ||
ARG GO_VERSION=1 | ||
ARG TARGETOS | ||
ARG TARGETARCH | ||
|
||
COPY go.mod go.sum ./ | ||
RUN go mod download | ||
# Setup the base environment. | ||
FROM --platform=${BUILDPLATFORM} golang:${GO_VERSION} AS base | ||
|
||
COPY input/ ./input | ||
COPY *.go ./ | ||
WORKDIR /fn | ||
ENV CGO_ENABLED=0 | ||
|
||
RUN CGO_ENABLED=0 go build -o /function . | ||
COPY go.mod go.sum ./ | ||
RUN --mount=type=cache,target=/go/pkg/mod go mod download | ||
|
||
FROM gcr.io/distroless/base-debian11 AS build-release-stage | ||
# Build the Function. | ||
FROM base AS build | ||
RUN --mount=target=. \ | ||
--mount=type=cache,target=/go/pkg/mod \ | ||
--mount=type=cache,target=/root/.cache/go-build \ | ||
GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build -o /function . | ||
|
||
# Produce the Function image. | ||
FROM gcr.io/distroless/base-debian11 AS image | ||
WORKDIR / | ||
|
||
COPY --from=build-stage /function /function | ||
|
||
COPY --from=build /function /function | ||
EXPOSE 9443 | ||
|
||
USER nonroot:nonroot | ||
|
||
ENTRYPOINT ["/function"] | ||
ENTRYPOINT ["/function"] |
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