Build and publish a Go binary as a minimal OCI image
gopack
uses your locally installed version of Go to cross-compile your
application, building an OCI image with the resulting binary, and pushing your
image to a remote repository or a locally running daemon. Docker not required.
gopack
can be installed using the command:
go install github.com/ryanfowler/gopack/cmd/gopack@latest
Go 1.18+ is required.
Use the gopack run
command to build and publish an image. Although all flags
are optional, some notable flags are:
--base
: image to use as the base (default:gcr.io/distroless/static:nonroot
)--repository
: repository to push the final image to (default: Go binary name)--platform
: platform(s) to build the image(s) for (default:linux/amd64
)--tag
: tag(s) to push the image with (default:latest
)--daemon
: push the final image to a local daemon, instead of the remote repository (e.g.docker
)
gopack run ./cmd/gopack -b myimage:tag
gopack run ./cmd/gopack -r ghcr.io/OWNER/gopack
gopack run ./cmd/gopack -p linux/amd64 -p linux/arm64
gopack run ./cmd/gopack -t latest -t 12345678
gopack run ./cmd/gopack --daemon docker
Please run gopack run -h
for more information about the available options.
Copyright 2023 Ryan Fowler
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.