Coder Social home page Coder Social logo

go-build's Introduction

go

CI status

Container image for building Go applications.

Get It!

The image is available on cgr.dev:

docker pull cgr.dev/chainguard/go:latest

Supported tags

Tag Digest Arch
1 1.19 1.19.2 1.19.2-r0 latest sha256:1cb14d9f908c7b03389830a4879f741ecaea5b0f112a7aa0fd6da936f05b31f9
View entry in Rekor
386 amd64 arm64 armv6 armv7 ppc64le riscv64 s390x
1.19.1-r0 sha256:38adede21243fda456da1a69eaaa0e2291c145dd9ab648332a5a932c0bc61490
View entry in Rekor
386 amd64 arm64 armv6 armv7 ppc64le riscv64 s390x
1.19.1 1.19.1-r2 sha256:ec841359408345c28596a5765253da3870c8364d010cfd55455f6f31e129faf2
View entry in Rekor
386 amd64 arm64 armv6 armv7 ppc64le riscv64 s390x
1.19.1-r0-glibc sha256:5e7e08f7ed1eb9a214bb5ac2680eb7c2a0ad741f6d8827e384396b7fd7787ef3
View entry in Rekor
amd64
1.19.1-r1 sha256:fc6136ed867b98663f6cd5388805eae81bd21de20944b4fe4a4b6748673d36cf
View entry in Rekor
386 amd64 arm64 armv6 armv7 ppc64le riscv64 s390x

Usage

Host architecture example

To build the Go application in examples/hello/main.go using the host architecture:

docker run --rm -v "${PWD}:/work" -w /work/examples/hello \
    -e GOOS="$(go env GOOS)" -e GOARCH="$(go env GOARCH)" \
    cgr.dev/chainguard/go build -o /work/hello .

The example application will be built to ./hello:

$ ./hello
Hello World!

Dockerfile example

The following example Dockerfile builds a hello-world program in Go and copies it on top of the cgr.dev/chainguard/static:latest base image:

# syntax=docker/dockerfile:1.4
FROM cgr.dev/chainguard/go:latest as build

WORKDIR /work

COPY <<EOF go.mod
module hello
go 1.19
EOF

COPY <<EOF main.go
package main
import "fmt"
func main() {
    fmt.Println("Hello World!")
}
EOF
RUN go build -o hello .

FROM cgr.dev/chainguard/static:latest

COPY --from=build /work/hello /hello
CMD ["/hello"]

Run the following command to build the demo image and tag it as go-hello-world:

docker build -t go-hello-world  .

Now you can run the image with:

docker run go-hello-world

You should get output like this:

Hello World!

It’s worth noting how small the resulting image is:

docker images go-hello-world
REPOSITORY       TAG       IMAGE ID       CREATED       SIZE
go-hello-world   latest    859fedabd532   5 hours ago   3.21MB

Signing

All Chainguard Images are signed using Sigstore!


To verify the image, download cosign and run:
COSIGN_EXPERIMENTAL=1 cosign verify cgr.dev/chainguard/go:latest | jq

Output:

Verification for cgr.dev/chainguard/go:latest --
The following checks were performed on each of these signatures:
  - The cosign claims were validated
  - Existence of the claims in the transparency log was verified offline
  - Any certificates were verified against the Fulcio roots.
[
  {
    "critical": {
      "identity": {
        "docker-reference": "ghcr.io/chainguard-images/go"
      },
      "image": {
        "docker-manifest-digest": "sha256:1cb14d9f908c7b03389830a4879f741ecaea5b0f112a7aa0fd6da936f05b31f9"
      },
      "type": "cosign container image signature"
    },
    "optional": {
      "1.3.6.1.4.1.57264.1.1": "https://token.actions.githubusercontent.com",
      "1.3.6.1.4.1.57264.1.2": "push",
      "1.3.6.1.4.1.57264.1.3": "f4ca71dfbb3c460f398bb4d801021215f1ce3f91",
      "1.3.6.1.4.1.57264.1.4": "Create Release",
      "1.3.6.1.4.1.57264.1.5": "chainguard-images/go",
      "1.3.6.1.4.1.57264.1.6": "refs/heads/main",
      "Bundle": {
        "SignedEntryTimestamp": "MEYCIQDOiDYofb8vhxNfIU5pmc4pmVx8FB1+Zm0b4iVL3gQU0AIhAMmLO6RDPKzlQRdYv/MdHvK2j8Tlpb4Q2DGvTpJWDAwN",
        "Payload": {
          "body": "eyJhcGlWZXJzaW9uIjoiMC4wLjEiLCJraW5kIjoiaGFzaGVkcmVrb3JkIiwic3BlYyI6eyJkYXRhIjp7Imhhc2giOnsiYWxnb3JpdGhtIjoic2hhMjU2IiwidmFsdWUiOiJhNzhjYzMwZGQyYTNiZjVlMmE5MTdkNTU1OGY1MzA5NjQwNzNhNWZhZTIwN2I0Mjg1ZDFmZmEzODBhMTQ3OTYzIn19LCJzaWduYXR1cmUiOnsiY29udGVudCI6Ik1FVUNJUURjOX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VkZsWGVFVnFhMUk0Y0dNeFVucFBha3A0TTI5M1EyZFpTUXBMYjFwSmVtb3dSVUYzVFVSaFFVRjNXbEZKZDA4MFRtWmpPVEY1UkhwSlF6UkxTalEzU1VwSGRVaFFkMmxVZUU5emNGUm5PRkY1UlZwUVQyeEJXWGhsQ2tObWJrVm5TV3BNVVVwUGFrSmtkMUpXYVRrMlFXcEZRWFp1TTA1aWNHODFURFV3TWt3NVVVRTFiRk42ZG0xRGVtaDRUMXBXWkZCWVFsWjVjRlpUVFhjS0wyTTJZVE4wUkZKdWMwcEVSVFZMZEZCbVdXOHlNVTFoQ2kwdExTMHRSVTVFSUVORlVsUkpSa2xEUVZSRkxTMHRMUzBLIn19fX0=",
          "integratedTime": 1665688432,
          "logIndex": 5045721,
          "logID": "c0d23d6ad406973f9559f3ba2d1ca01f84147d8ffc5b8445c224f98b9591801d"
        }
      },
      "Issuer": "https://token.actions.githubusercontent.com",
      "Subject": "https://github.com/chainguard-images/go/.github/workflows/release.yaml@refs/heads/main",
      "githubWorkflowName": "Create Release",
      "githubWorkflowRef": "refs/heads/main",
      "githubWorkflowRepository": "chainguard-images/go",
      "githubWorkflowSha": "f4ca71dfbb3c460f398bb4d801021215f1ce3f91",
      "githubWorkflowTrigger": "push",
      "run_attempt": "1",
      "run_id": "3245006470",
      "sha": "f4ca71dfbb3c460f398bb4d801021215f1ce3f91"
    }
  }
]

You can verify that the image was built in Github Actions in this repository from the Issuer and Subject fields.

Build

This image is built with apko.

go-build's People

Contributors

amouat avatar cpanato avatar dependabot[bot] avatar github-actions[bot] avatar imjasonh avatar jdolitsky avatar kaniini avatar patflynn avatar priyawadhwa avatar rawlingsj avatar strongjz avatar

Watchers

 avatar

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.