From 121e831de5f6689841609751f5ebc1764c45ef8d086e494f076585278e4b64a1 Mon Sep 17 00:00:00 2001 From: Dominique Leuenberger Date: Sat, 17 Aug 2024 10:41:07 +0000 Subject: [PATCH] Accepting request 1194429 from devel:BCI:Tumbleweed MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 🤖: sync package with devel:BCI:Tumbleweed from OBS OBS-URL: https://build.opensuse.org/request/show/1194429 OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/golang-unstable-image?expand=0&rev=4 --- Dockerfile | 32 ++++---- README.md | 136 +++++++++++++++++++++++++++++++++- _service | 2 +- golang-unstable-image.changes | 5 ++ 4 files changed, 158 insertions(+), 17 deletions(-) diff --git a/Dockerfile b/Dockerfile index b63ff69..362cc17 100644 --- a/Dockerfile +++ b/Dockerfile @@ -16,36 +16,40 @@ #!BuildTag: opensuse/bci/golang:unstable #!BuildTag: opensuse/bci/golang:unstable-%RELEASE% -#!BuildTag: opensuse/bci/golang:1.22 -#!BuildTag: opensuse/bci/golang:1.22-%RELEASE% +#!BuildTag: opensuse/bci/golang:1.23 +#!BuildTag: opensuse/bci/golang:1.23-%RELEASE% FROM opensuse/tumbleweed:latest -MAINTAINER openSUSE (https://www.opensuse.org/) +RUN set -euo pipefail; zypper -n in --no-recommends go1.23 go1.23-doc make curl findutils gawk git-core procps util-linux; zypper -n clean; rm -rf /var/log/{lastlog,tallylog,zypper.log,zypp/history,YaST2} # Define labels according to https://en.opensuse.org/Building_derived_containers # labelprefix=org.opensuse.bci.golang -LABEL org.opencontainers.image.title="openSUSE Tumbleweed BCI Go 1.22 development" -LABEL org.opencontainers.image.description="Go 1.22 development container based on the openSUSE Tumbleweed Base Container Image." -LABEL org.opencontainers.image.version="1.22" +LABEL org.opencontainers.image.authors="openSUSE (https://www.opensuse.org/)" +LABEL org.opencontainers.image.title="openSUSE Tumbleweed BCI Go 1.23 development" +LABEL org.opencontainers.image.description="Go 1.23 development container based on the openSUSE Tumbleweed Base Container Image." +LABEL org.opencontainers.image.version="1.23" LABEL org.opencontainers.image.url="https://www.opensuse.org" LABEL org.opencontainers.image.created="%BUILDTIME%" LABEL org.opencontainers.image.vendor="openSUSE Project" LABEL org.opencontainers.image.source="%SOURCEURL%" -LABEL io.artifacthub.package.readme-url="https://raw.githubusercontent.com/SUSE/BCI-dockerfile-generator/Tumbleweed/golang-unstable-image/README.md" -LABEL org.opensuse.reference="registry.opensuse.org/opensuse/bci/golang:1.22-%RELEASE%" +LABEL org.opencontainers.image.ref.name="1.23-%RELEASE%" +LABEL org.opensuse.reference="registry.opensuse.org/opensuse/bci/golang:1.23-%RELEASE%" LABEL org.openbuildservice.disturl="%DISTURL%" -LABEL org.opensuse.lifecycle-url="https://en.opensuse.org/Lifetime" +LABEL org.opensuse.lifecycle-url="https://en.opensuse.org/Lifetime#openSUSE_BCI" LABEL org.opensuse.release-stage="released" - # endlabelprefix - -RUN set -euo pipefail; zypper -n in --no-recommends go1.22 go1.22-doc make git-core; zypper -n clean; rm -rf /var/log/* +LABEL io.artifacthub.package.readme-url="https://raw.githubusercontent.com/SUSE/BCI-dockerfile-generator/Tumbleweed/golang-unstable-image/README.md" ENV GOLANG_VERSION="%%golang_version%%" ENV GOPATH="/go" +ENV GOTOOLCHAIN="local" ENV PATH="/go/bin:/usr/local/go/bin:/root/go/bin/:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" # only available on go's tsan_arch architectures -#!ArchExclusiveLine x86_64 aarch64 s390x ppc64le -RUN set -euo pipefail; if zypper -n install go1.22-race; then zypper -n clean; rm -rf /var/log/*; fi +#!ArchExclusiveLine: x86_64 aarch64 s390x ppc64le +RUN set -euo pipefail; if zypper -n install go1.23-race; then zypper -n clean; fi +RUN set -euo pipefail; install -m 755 -d /go/bin /go/src +RUN set -euo pipefail; rm -rf /var/log/{lastlog,tallylog,zypper.log,zypp/history,YaST2} +WORKDIR /go + diff --git a/README.md b/README.md index 46ca76a..3e58cc5 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,135 @@ -# The openSUSE Tumbleweed BCI Go 1.22 development Container image +# Go 1.23 development container image -Go 1.22 development container based on the openSUSE Tumbleweed Base Container Image. +![Redistributable](https://img.shields.io/badge/Redistributable-Yes-green) + +## 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. + + +## 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. + + +### Building from `scratch` + +```Dockerfile +# Build the application using the Go 1.23 development container image +FROM registry.opensuse.org/opensuse/bci/golang:1.23 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 . ./ + +# Make sure to build the application with CGO disabled. +# This will force Go to use some Go implementations of code +# 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 + +# Bundle the application into a scratch image +FROM scratch + +COPY --from=build /hello /usr/local/bin/hello + +CMD ["/usr/local/bin/hello"] +``` + +Build and run the container image: + +```ShellSession +$ podman build -t my-golang-app . +$ podman run -it --rm my-golang-app +``` + +There are situations when you don't want to run an application inside a container. + +To compile the application, without running it inside a container instance, use the following command: + +```ShellSession +$ podman run --rm -v "$PWD":/app:Z -w /app registry.opensuse.org/opensuse/bci/golang:1.23 go build -v +``` + +To run the application tests inside a container, use the following command: + +```ShellSession +$ podman run --rm -v "$PWD":/app:Z -w /app registry.opensuse.org/opensuse/bci/golang:1.23 go test -v +``` + + +### 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.23 development Container Image +FROM registry.opensuse.org/opensuse/bci/golang:1.23 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 + +In addition to the standard SLE BCI development packages, the following tools +are included in the image: + +- go1.23-race +- make + +## Licensing + +`SPDX-License-Identifier: MIT` + +This documentation and the build recipe are licensed as MIT. +The container itself contains various software components under various open source licenses listed in the associated +Software Bill of Materials (SBOM). + +This image is based on [openSUSE Tumbleweed](https://get.opensuse.org/tumbleweed/). diff --git a/_service b/_service index 63f40d2..0707d56 100644 --- a/_service +++ b/_service @@ -4,6 +4,6 @@ Dockerfile %%golang_version%% - go1.22 + go1.23 \ No newline at end of file diff --git a/golang-unstable-image.changes b/golang-unstable-image.changes index 3c63629..594abe9 100644 --- a/golang-unstable-image.changes +++ b/golang-unstable-image.changes @@ -1,3 +1,8 @@ +------------------------------------------------------------------- +Thu Aug 15 12:01:13 UTC 2024 - Dirk Mueller + +- Switch to go 1.23 + ------------------------------------------------------------------- Mon Jan 29 09:18:52 UTC 2024 - Dirk Mueller