Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package golang-stable-image for openSUSE:Factory checked in at 2024-06-25 23:07:31 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/golang-stable-image (Old) and /work/SRC/openSUSE:Factory/.golang-stable-image.new.18349 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Package is "golang-stable-image" Tue Jun 25 23:07:31 2024 rev:18 rq:1183072 version:unknown Changes: -------- --- /work/SRC/openSUSE:Factory/golang-stable-image/golang-stable-image.changes 2024-06-19 16:38:31.897525566 +0200 +++ /work/SRC/openSUSE:Factory/.golang-stable-image.new.18349/golang-stable-image.changes 2024-06-25 23:08:22.124255059 +0200 @@ -1,0 +2,5 @@ +Mon Jun 24 23:55:53 UTC 2024 - Dirk Mueller <dmueller@suse.com> + +- README fixes + +------------------------------------------------------------------- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ README.md ++++++ --- /var/tmp/diff_new_pack.OVX6eh/_old 2024-06-25 23:08:23.976322572 +0200 +++ /var/tmp/diff_new_pack.OVX6eh/_new 2024-06-25 23:08:23.980322718 +0200 @@ -4,11 +4,33 @@ ## Description -[Go](https://go.dev/) (a.k.a., Golang) is a statically-typed programming language, with syntax loosely derived from C. Go offers additional features such as garbage collection, type safety, certain dynamic-typing capabilities, additional built-in types (for example, variable-length arrays and key-value maps) as well as a large standard library. +[Go](https://go.dev/) (a.k.a., Golang) is a statically-typed programming +language, with syntax loosely derived from C. Go offers additional features +such as garbage collection, type safety, certain dynamic-typing capabilities, +additional built-in types (for example, variable-length arrays and key-value +maps) as well as a large standard library. + ## Usage +We recommend using the Go image as a build environment. Thus, +the compiler does not need to be shipped as part of the images that are +deployed. Instead, we recommend to use the Go image as the +builder image only. + +There are two options to work with Go images. First, you can encapsulate your +application in a `scratch` container image, essentially an empty filesystem +image. This approach only works if your Go application does not depend on libc +or any other library or files, as they will not be available. + +The second option uses a slim base container image with just the minimal +packages required to run the Go application. + +To compile and deploy an application, copy the sources, fetch dependencies +(assuming go.mod is used for dependency management), and build the binary using +the following Dockerfile options. -To compile and deploy an application, copy the sources, fetch dependencies (assuming go.mod is used for dependency management), and build the binary: + +### Building from `scratch` ```Dockerfile # Build the application using the Go 1.22 development container image @@ -16,7 +38,8 @@ WORKDIR /app -# pre-copy/cache go.mod for pre-downloading dependencies and only redownloading them in subsequent builds if they change +# pre-copy/cache go.mod for pre-downloading dependencies and only +# redownloading them in subsequent builds if they change COPY go.mod go.sum ./ RUN go mod download && go mod verify @@ -24,7 +47,7 @@ # Make sure to build the application with CGO disabled. # This will force Go to use some Go implementations of code -# rather than those normally supplied by the host operating system. +# rather than those supplied by the host operating system. # You need this for scratch images as those supporting libraries # are not available. RUN CGO_ENABLED=0 go build -o /hello @@ -32,9 +55,9 @@ # Bundle the application into a scratch image FROM scratch -COPY --from=build /hello /hello +COPY --from=build /hello /usr/local/bin/hello -CMD ["/hello"] +CMD ["/usr/local/bin/hello"] ``` Build and run the container image: @@ -58,18 +81,49 @@ $ podman run --rm -v "$PWD":/app:Z -w /app registry.opensuse.org/opensuse/bci/golang:1.22 go test -v ``` -**Note:** The Golang image should be used as a build environment. For runtime, self-contained Go binaries should use a `scratch` image and for applications that require external dependencies use the `bci-base` image. + +### Building from SLE BCI + +The [SLE BCI General Purpose Base Containers](https://opensource.suse.com/bci-docs/documentation/general-purpose-bci/) +images offer four different options for deployment, depending on your exact requirements. + +```Dockerfile +# Build the application using the Go 1.22 development Container Image +FROM registry.opensuse.org/opensuse/bci/golang:1.22 as build + +WORKDIR /app + +# pre-copy/cache go.mod for pre-downloading dependencies and only +# redownloading them in subsequent builds if they change +COPY go.mod go.sum ./ +RUN go mod download && go mod verify + +COPY . ./ + +RUN go build -o /hello + +# Bundle the application into a scratch image +FROM registry.suse.com/bci/bci-micro:15.4 + +COPY --from=build /hello /usr/local/bin/hello + +CMD ["/usr/local/bin/hello"] +``` + +The above example uses the SLE BCI micro image as the deployment image for +the resulting application. See the [SLE BCI use with Go +documentation](https://opensource.suse.com/bci-docs/guides/use-with-golang/) +for further details. + ## Additional tools -The following additional tools are included in the image: +The following tools are also included in the image: - go1.22-race - make - git-core - - ## Licensing `SPDX-License-Identifier: MIT`