Git Product home page Git Product logo

golang-docker's Introduction

golang-docker

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 go-1.x.yaml configuration files are used in the build pipeline. User can now specify a Go version in app.yaml via runtime: go1.x, where 1.x 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 gcr.io/gcp-runtimes/go1-builder 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 go1-builder 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 go1-builder 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 go-1.x.yaml files for configuration file. The builder image's ENTRYPOINT is the go-build.sh 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 /app directory.

The build script will build the application as referenced in _gopath/main-package-path 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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.