Chapter 5. Container images with Go Toolset

Go Toolset is available as container images for Red Hat Enterprise Linux 7 and Red Hat Enterprise Linux 8. Container images can be downloaded from the Red Hat Container Registry.

5.1. Container images contents

The Red Hat Enterprise Linux 7 and Red Hat Enterprise Linux 8 container images provide content corresponding to the following packages:

ComponentVersionPackage

Go

1.15

RHEL 7 — go-toolset-1.15.11
RHEL 8 — go-toolset-1.15.7

5.2. Accessing container images

To pull the required image, run the following command as root:

  • For the Red Hat Enterprise Linux 7 container images:
# podman pull registry.redhat.io/devtools/go-toolset-rhel7
# podman pull registry.redhat.io/ubi7/go-toolset
Note

The two Red Hat Enterprise Linux 7 container images provide the same content.

  • For the Red Hat Enterprise Linux 8 container images:
# podman pull registry.redhat.io/rhel8/go-toolset
# podman pull registry.redhat.io/ubi8/go-toolset
Note

The two Red Hat Enterprise Linux 8 container images provide the same content.

5.3. Using container images as Source-to-Image builder images

The Go Toolset container image is prepared for use as a Source-to-Image (S2I) builder image in Red Hat Enterprise Linux 7. Source-to-Image is not supported on Red Hat Enterprise Linux 8.

To do so, set the following build environment variables:

IMPORT_URL
Set this variable to a URL specifying the location of the code. The rules for the go get command option apply.
INSTALL_URL

Set this variable to a URL specifying the location of the package that will provide the application’s main executable file when built. The rules for the go install command option apply.

This variable can be omitted if the main package location is identical with the location specified by the IMPORT_URL variable.

Example 5.1. Building a Go application image using Source-to-Image

To build the md2man package from its GitHub repository:

$ s2i build -e IMPORT_URL='github.com/cpuguy83/go-md2man' -e INSTALL_URL='github.com/cpuguy83/go-md2man' git://github.com/cpuguy83/go-md2man  registry.access.redhat.com/devtools/go-toolset-rhel7 md2man-app

A locally available application image md2man-app is built from the repository on GitHub using the Go Toolset container image.

To fully leverage the Go as a S2I builder image, build custom images based on it, with modified S2I assemble scripts and further modifications to accomodate the particular application being built.

A detailed description of the Go usage with Source-to-Image is beyond the scope of this document. For more information about Source-to-Image, see:

5.4. Additional resources