From 30a0de244de5079e83acc69cea657c8e15cabd74aa163d448898c142aa309f3c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dan=20=C4=8Cerm=C3=A1k?= Date: Fri, 6 Sep 2024 17:47:18 +0000 Subject: [PATCH] [info=95d7ab65640c4a63682a9dd5f8924b3a] OBS-URL: https://build.opensuse.org/package/show/devel:BCI:Tumbleweed/golang-stable-image?expand=0&rev=156 --- .gitattributes | 23 +++++ .gitignore | 1 + Dockerfile | 58 ++++++++++++ README.md | 135 ++++++++++++++++++++++++++++ _constraints | 7 ++ _service | 9 ++ golang-stable-image.changes | 174 ++++++++++++++++++++++++++++++++++++ 7 files changed, 407 insertions(+) create mode 100644 .gitattributes create mode 100644 .gitignore create mode 100644 Dockerfile create mode 100644 README.md create mode 100644 _constraints create mode 100644 _service create mode 100644 golang-stable-image.changes diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..9b03811 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,23 @@ +## Default LFS +*.7z filter=lfs diff=lfs merge=lfs -text +*.bsp filter=lfs diff=lfs merge=lfs -text +*.bz2 filter=lfs diff=lfs merge=lfs -text +*.gem filter=lfs diff=lfs merge=lfs -text +*.gz filter=lfs diff=lfs merge=lfs -text +*.jar filter=lfs diff=lfs merge=lfs -text +*.lz filter=lfs diff=lfs merge=lfs -text +*.lzma filter=lfs diff=lfs merge=lfs -text +*.obscpio filter=lfs diff=lfs merge=lfs -text +*.oxt filter=lfs diff=lfs merge=lfs -text +*.pdf filter=lfs diff=lfs merge=lfs -text +*.png filter=lfs diff=lfs merge=lfs -text +*.rpm filter=lfs diff=lfs merge=lfs -text +*.tbz filter=lfs diff=lfs merge=lfs -text +*.tbz2 filter=lfs diff=lfs merge=lfs -text +*.tgz filter=lfs diff=lfs merge=lfs -text +*.ttf filter=lfs diff=lfs merge=lfs -text +*.txz filter=lfs diff=lfs merge=lfs -text +*.whl filter=lfs diff=lfs merge=lfs -text +*.xz filter=lfs diff=lfs merge=lfs -text +*.zip filter=lfs diff=lfs merge=lfs -text +*.zst filter=lfs diff=lfs merge=lfs -text diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..57affb6 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.osc diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..4ad29fb --- /dev/null +++ b/Dockerfile @@ -0,0 +1,58 @@ +# SPDX-License-Identifier: MIT + +# Copyright (c) 2024 SUSE LLC + +# All modifications and additions to the file contributed by third parties +# remain the property of their copyright owners, unless otherwise agreed +# upon. + +# The content of THIS FILE IS AUTOGENERATED and should not be manually modified. +# It is maintained by the BCI team and generated by +# https://github.com/SUSE/BCI-dockerfile-generator + +# Please submit bugfixes or comments via https://bugs.opensuse.org/ +# You can contact the BCI team via https://github.com/SUSE/bci/discussions + + +#!BuildTag: opensuse/bci/golang:stable +#!BuildTag: opensuse/bci/golang:stable-1.%RELEASE% +#!BuildTag: opensuse/bci/golang:1.23 +#!BuildTag: opensuse/bci/golang:1.23-1.%RELEASE% +#!BuildTag: opensuse/bci/golang:%%golang_version%% +#!BuildTag: opensuse/bci/golang:%%golang_version%%-1.%RELEASE% +#!BuildTag: opensuse/bci/golang:latest + +FROM opensuse/tumbleweed:latest + +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.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="%%golang_version%%" +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 org.opencontainers.image.ref.name="1.23-1.%RELEASE%" +LABEL org.opensuse.reference="registry.opensuse.org/opensuse/bci/golang:1.23-1.%RELEASE%" +LABEL org.openbuildservice.disturl="%DISTURL%" +LABEL org.opensuse.lifecycle-url="https://en.opensuse.org/Lifetime#openSUSE_BCI" +LABEL org.opensuse.release-stage="released" +# endlabelprefix +LABEL io.artifacthub.package.readme-url="https://raw.githubusercontent.com/SUSE/BCI-dockerfile-generator/Tumbleweed/golang-stable-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.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 new file mode 100644 index 0000000..3e58cc5 --- /dev/null +++ b/README.md @@ -0,0 +1,135 @@ +# Go 1.23 development 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/_constraints b/_constraints new file mode 100644 index 0000000..02387b4 --- /dev/null +++ b/_constraints @@ -0,0 +1,7 @@ + + + + 8 + + + diff --git a/_service b/_service new file mode 100644 index 0000000..0707d56 --- /dev/null +++ b/_service @@ -0,0 +1,9 @@ + + + + + Dockerfile + %%golang_version%% + go1.23 + + \ No newline at end of file diff --git a/golang-stable-image.changes b/golang-stable-image.changes new file mode 100644 index 0000000..8c83c8d --- /dev/null +++ b/golang-stable-image.changes @@ -0,0 +1,174 @@ +------------------------------------------------------------------- +Fri Sep 6 11:30:01 UTC 2024 - Dirk Mueller + +- use full version in version label + +------------------------------------------------------------------- +Fri Aug 16 16:04:16 UTC 2024 - Dirk Mueller + +- Switch to go 1.23 + +------------------------------------------------------------------- +Wed Aug 14 12:30:32 UTC 2024 - Dirk Mueller + +- install packages first + +------------------------------------------------------------------- +Thu Aug 8 19:28:10 UTC 2024 - Dirk Mueller + +- add oci.image.ref.name + +------------------------------------------------------------------- +Thu Aug 8 16:43:43 UTC 2024 - Dirk Mueller + +- remove oci reference annotation again + +------------------------------------------------------------------- +Mon Aug 5 11:38:13 UTC 2024 - Dirk Mueller + +- add OCI reference annotation + +------------------------------------------------------------------- +Sat Aug 3 08:56:51 UTC 2024 - Dirk Mueller + +- set OCI.authors attribute instead of deprecated MAINTAINER + +------------------------------------------------------------------- +Wed Jul 31 12:06:44 UTC 2024 - Dirk Mueller + +- set specific lifecycle url for openSUSE BCI + +------------------------------------------------------------------- +Mon Jul 8 10:31:08 UTC 2024 - Dirk Mueller + +- more upstream-compatible golang containers + +------------------------------------------------------------------- +Fri Jun 28 06:52:02 UTC 2024 - Dirk Mueller + +- add standard devel tools back to development containers + +------------------------------------------------------------------- +Mon Jun 24 23:55:53 UTC 2024 - Dirk Mueller + +- README fixes + +------------------------------------------------------------------- +Tue Jun 18 17:24:16 UTC 2024 - Dirk Mueller + +- use sentence style capitalization in READMEs + +------------------------------------------------------------------- +Mon Jun 10 15:11:25 UTC 2024 - Dirk Mueller + +- update README; reduce unnecessary newlines + +------------------------------------------------------------------- +Wed Jun 5 15:13:27 UTC 2024 - Dirk Mueller + +- Don't add artifacthub labels into labelprefix section + +------------------------------------------------------------------- +Tue Jun 4 12:35:15 UTC 2024 - Alexandre Vicenzi + +- Fix grammar mistake in licensing footer + +------------------------------------------------------------------- +Tue May 28 12:13:17 UTC 2024 - Alexandre Vicenzi + +- Extend README.md + +------------------------------------------------------------------- +Tue May 7 19:07:24 UTC 2024 - Dirk Mueller + +- extend READMEs; correct eula for application images + +------------------------------------------------------------------- +Wed Apr 17 09:30:41 UTC 2024 - Guillaume GARDET + +- fix typo in archexclusiveline + +------------------------------------------------------------------- +Fri Apr 12 12:03:53 UTC 2024 - Dirk Mueller + +- Don't wipe everything in /var/log, only remove log files (this omits directories owned by packages) + +------------------------------------------------------------------- +Wed Feb 7 18:41:00 UTC 2024 - Dan Čermák + +- switch golang stable to 1.22, oldstable to 1.21 + +------------------------------------------------------------------- +Wed Jan 17 14:29:14 UTC 2024 - Dan Čermák + +- Add initial README stub + +------------------------------------------------------------------- +Tue Jan 2 08:26:58 UTC 2024 - Dirk Mueller + +- update year to 2024 + +------------------------------------------------------------------- +Thu Sep 28 14:29:10 UTC 2023 - Dirk Mueller + +- add copyright and description header + +------------------------------------------------------------------- +Thu Sep 28 12:01:58 UTC 2023 - Dirk Mueller + +- correct descriptions to be more consistent + +------------------------------------------------------------------- +Fri Sep 8 12:26:59 UTC 2023 - Dirk Mueller + +- typo fix in last change + +------------------------------------------------------------------- +Wed Sep 6 16:26:08 UTC 2023 - Dirk Mueller + +- install the race subpackage only on architectures where it is available + +------------------------------------------------------------------- +Thu Aug 17 13:41:09 UTC 2023 - Dirk Mueller + +- go 1.21 is now stable, go 1.20 is now oldstable + +------------------------------------------------------------------- +Tue Aug 8 06:51:38 UTC 2023 - Dirk Mueller + +- Add go-doc and go-race subpackages for developer convenience + +------------------------------------------------------------------- +Wed Jul 12 12:55:01 UTC 2023 - Dirk Mueller + +- Remove distribution-release from the package list, it is inherited from the base image + +------------------------------------------------------------------- +Tue Jun 27 15:55:34 UTC 2023 - Dan Čermák + +- Fix reference label + +------------------------------------------------------------------- +Fri Jun 23 15:33:33 UTC 2023 - Dirk Mueller + +- label capitalization and related cleanups + +------------------------------------------------------------------- +Thu Jun 22 16:56:53 UTC 2023 - Dirk Mueller + +- Order the stability buildtag first in the list and prefix them with an stability index to avoid overlaps + +------------------------------------------------------------------- +Tue Jun 13 15:19:02 UTC 2023 - Dirk Müller + +- rename to stable + +------------------------------------------------------------------- +Tue May 30 06:52:56 UTC 2023 - Dan Čermák + +- Add release stage and lifecycle url + +------------------------------------------------------------------- +Thu Mar 16 07:23:29 UTC 2023 - SUSE Update Bot + +- First version of the Golang 1.20 BCI