by GoogleCloudPlatform

GoogleCloudPlatform / golang-docker

Docker images for Go on Google App Engine

203 Stars 73 Forks Last release: Not found Apache License 2.0 198 Commits 0 Releases

Available items

No Items, yet!

The developer of this repository has not created any items for sale yet. Need a bug fixed? Help with integration? A different license? Create a request here:


Build Status

This repository contains sources for the Go App Engine Flex build pipeline. This build pipeline utilizes Google Cloud Build to produce the application image. The

configuration files are used in the build pipeline. User can now specify a Go version in app.yaml via
runtime: go1.x
, where
can be 1.8, 1.9, etc. The resulting application image uses gcr.io/distroless/base as the base image, which contains a minimal Linux, glibc-based system.

The builder image

is tagged with supported Go major versions for builds to be able to target specific Go version to build against. Run the following gcloud command to list supported versions --
$ gcloud container images list-tags gcr.io/gcp-runtimes/go1-builder

Use only the Go major version tags e.g. 1.8, 1.9, instead of the unique version-datetime tags.

There are different ways to reuse the

image outside of AppEngine Flex. Here are a couple of examples.

Multi-stage Dockerfile

Read up on how to use Docker's multi-stage builds.

Following is a trivial example of a Dockerfile with multi-stage build using the

image to bring in the Go SDK. The Go SDK is located under /usr/local/go of the builder image.
FROM gcr.io/gcp-runtimes/go1-builder:1.9 as builder

WORKDIR /go/src/app COPY main.go .

RUN /usr/local/go/bin/go build -o app .

Application image.

FROM gcr.io/distroless/base:latest

COPY --from=builder /go/src/app/app /usr/local/bin/app

CMD ["/usr/local/bin/app"]

Google Cloud Build

Read up on Google Cloud Build.

You can use one of the

files for configuration file. The builder image's
is the
script, which expects a certain layout of the uploaded directory. In particular, it expects --
  • _gopath/src
    directory containing Go source files within package directory structure.
  • _gopath/main-package-path
    file containing the import path of the main application to be built.
  • top level directory can contain resource files that will be bundled into the application image's

The build script will build the application as referenced in

file and produce an application Dockerfile which the next step will run a docker build on.

You can customize your own cloudbuild.yaml file with your own Dockerfile.

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.