Created
January 7, 2019 06:02
-
-
Save bamnet/c8122fc7748278975e799b1d1a895114 to your computer and use it in GitHub Desktop.
Multiarch Go Builds + Google Cloud Build
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
steps: | |
- name: 'gcr.io/cloud-builders/docker' | |
id: 'amd64' | |
args: | |
- 'build' | |
- '--build-arg=CGO_ENABLED=0' | |
- '--build-arg=GOARCH=amd64' | |
- '--tag=gcr.io/$PROJECT_ID/village:amd64' | |
- '.' | |
waitFor: ['-'] | |
- name: 'gcr.io/cloud-builders/docker' | |
id: 'push-amd64' | |
args: | |
- 'push' | |
- 'gcr.io/$PROJECT_ID/village:amd64' | |
waitFor: ['amd64'] | |
- name: 'gcr.io/cloud-builders/docker' | |
id: 'arm' | |
args: | |
- 'build' | |
- '--build-arg=GOARCH=arm' | |
- '--build-arg=GOARM=6' | |
- '--tag=gcr.io/$PROJECT_ID/village:arm32v6' | |
- '.' | |
waitFor: ['-'] | |
- name: 'gcr.io/cloud-builders/docker' | |
id: 'push-arm' | |
args: | |
- 'push' | |
- 'gcr.io/$PROJECT_ID/village:arm32v6' | |
waitFor: ['arm'] | |
- name: 'gcr.io/cloud-builders/docker' | |
id: 'manifest' | |
env: | |
- 'DOCKER_CLI_EXPERIMENTAL=enabled' | |
args: | |
- 'manifest' | |
- 'create' | |
- 'gcr.io/$PROJECT_ID/village:$COMMIT_SHA' | |
- 'gcr.io/$PROJECT_ID/village:arm32v6' | |
- 'gcr.io/$PROJECT_ID/village:amd64' | |
waitFor: ['push-amd64', 'push-arm'] | |
- name: 'gcr.io/cloud-builders/docker' | |
id: 'annotate-manifest' | |
env: | |
- 'DOCKER_CLI_EXPERIMENTAL=enabled' | |
args: | |
- 'manifest' | |
- 'annotate' | |
- 'gcr.io/$PROJECT_ID/village:$COMMIT_SHA' | |
- 'gcr.io/$PROJECT_ID/village:arm32v6' | |
- '--os=linux' | |
- '--arch=arm' | |
waitFor: ['manifest'] | |
- name: 'gcr.io/cloud-builders/docker' | |
id: 'push-manifest' | |
env: | |
- 'DOCKER_CLI_EXPERIMENTAL=enabled' | |
args: | |
- 'manifest' | |
- 'push' | |
- 'gcr.io/$PROJECT_ID/village:$COMMIT_SHA' | |
waitFor: ['annotate-manifest'] | |
images: | |
- 'gcr.io/$PROJECT_ID/village:amd64' | |
- 'gcr.io/$PROJECT_ID/village:arm32v6' |
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
FROM golang:alpine as builder | |
RUN apk update && apk add git && apk add tzdata | |
COPY . $GOPATH/src/github.com/bamnet/village | |
WORKDIR $GOPATH/src/github.com/bamnet/village | |
ARG CGO_ENABLED=0 | |
ARG GOARCH=amd64 | |
ARG GOARM=6 | |
RUN env CGO_ENABLED=${CGO_ENABLED} GOARCH=${GOARCH} GOARM=${GOARM} go build -o /go/bin/show | |
FROM scratch | |
COPY --from=builder /usr/local/go/lib/time/zoneinfo.zip /usr/local/go/lib/time/ | |
COPY --from=builder /go/bin/show /go/bin/show | |
ENTRYPOINT ["/go/bin/show"] | |
CMD [] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment