diff --git a/library/golang/1.26-buster/Makefile b/library/golang/1.26-buster/Makefile index 9612efce..d1a8ced3 100644 --- a/library/golang/1.26-buster/Makefile +++ b/library/golang/1.26-buster/Makefile @@ -12,7 +12,7 @@ IMAGE = $(REGISTRY)/$(ORGANIZATION)/$(REPOSITORY):$(TAG) ALIAS0 = $(REGISTRY)/$(ORGANIZATION)/$(REPOSITORY):$(GOMAJOR) ALIAS1 = $(REGISTRY)/$(ORGANIZATION)/$(REPOSITORY):$(GOMAJOR).$(GOMINOR)-$(OSVERSION) ALIAS2 = $(REGISTRY)/$(ORGANIZATION)/$(REPOSITORY):$(GOMAJOR).$(GOMINOR) -LATEST = $(REGISTRY)/$(ORGANIZATION)/$(REPOSITORY):latest +LATEST = default: image diff --git a/library/golang/1.27-alpine/Dockerfile b/library/golang/1.27-alpine/Dockerfile new file mode 100644 index 00000000..3d1d1a6d --- /dev/null +++ b/library/golang/1.27-alpine/Dockerfile @@ -0,0 +1,32 @@ +FROM cr.loongnix.cn/library/alpine:3.11 + +RUN apk --no-cache upgrade +RUN apk add --no-cache ca-certificates wget + +# set up nsswitch.conf for Go's "netgo" implementation +# - https://github.com/golang/go/blob/go1.9.1/src/net/conf.go#L194-L275 +# - docker run --rm debian grep '^hosts:' /etc/nsswitch.conf +RUN [ ! -e /etc/nsswitch.conf ] && echo 'hosts: files dns' > /etc/nsswitch.conf + +ENV PATH /usr/local/go/bin:$PATH + +ENV GOLANG_VERSION 1.27.1 + +RUN set -eux; \ + url='http://ftp.loongnix.cn/toolchain/golang/go-1.27/abi1.0/go1.27.1.linux-loong64.tar.gz'; \ + sha256='e4f8920f59c1da3604fba3ff2d668e7ff607d74b4fd548230149e8c8e513dff8'; \ + wget -O go.tgz "$url" --progress=dot:giga; \ + echo "$sha256 *go.tgz" | sha256sum -c -; \ + tar -C /usr/local -xzf go.tgz; \ + rm go.tgz; \ + go version + +RUN apk del wget + +ENV GOTOOLCHAIN=local +ENV GOPATH /go +ENV PATH $GOPATH/bin:$PATH +RUN mkdir -p "$GOPATH/src" "$GOPATH/bin" && chmod -R 1777 "$GOPATH" +WORKDIR $GOPATH + + diff --git a/library/golang/1.27-alpine/Makefile b/library/golang/1.27-alpine/Makefile new file mode 100644 index 00000000..59808d29 --- /dev/null +++ b/library/golang/1.27-alpine/Makefile @@ -0,0 +1,24 @@ +# This file is generated by the template. + +REGISTRY ?= cr.loongnix.cn +ORGANIZATION ?= library +REPOSITORY ?= golang +GOMAJOR ?= 1.27 +GOMINOR ?= 1 +OSVERSION ?= alpine +TAG ?= $(GOMAJOR)-$(OSVERSION) + +IMAGE = $(REGISTRY)/$(ORGANIZATION)/$(REPOSITORY):$(TAG) +ALIAS0 = $(REGISTRY)/$(ORGANIZATION)/$(REPOSITORY):$(GOMAJOR).$(GOMINOR)-$(OSVERSION) + +default: image + +image: + docker build -t $(IMAGE) . + +push: alias + docker push $(IMAGE) + docker push $(ALIAS0) + +alias: + docker tag $(IMAGE) $(ALIAS0) diff --git a/library/golang/1.27-buster/Dockerfile b/library/golang/1.27-buster/Dockerfile new file mode 100644 index 00000000..40b7a49a --- /dev/null +++ b/library/golang/1.27-buster/Dockerfile @@ -0,0 +1,32 @@ +FROM cr.loongnix.cn/library/buildpack-deps:buster-scm + +# install cgo-related dependencies +RUN set -eux; \ + apt-get update; \ + apt-get dist-upgrade -y; \ + apt-get install -y --no-install-recommends \ + g++ \ + gcc \ + libc6-dev \ + make \ + pkg-config \ + ; \ + apt-get autoclean all; \ + rm -rf /var/lib/apt/lists/* + +ENV PATH /usr/local/go/bin:$PATH +ENV GOLANGVERSION 1.27.1 + +RUN set -eux; \ + url='http://ftp.loongnix.cn/toolchain/golang/go-1.27/abi1.0/go1.27.1.linux-loong64.tar.gz'; \ + sha256='e4f8920f59c1da3604fba3ff2d668e7ff607d74b4fd548230149e8c8e513dff8'; \ + wget -O go.tgz "$url" --progress=dot:giga; \ + echo "$sha256 *go.tgz" | sha256sum -c -; \ + tar -C /usr/local -xzf go.tgz; \ + rm go.tgz; \ + go version + +ENV GOPATH /go +ENV PATH $GOPATH/bin:$PATH +RUN mkdir -p "$GOPATH/src" "$GOPATH/bin" && chmod -R 777 "$GOPATH" +WORKDIR $GOPATH diff --git a/library/golang/1.27-buster/Makefile b/library/golang/1.27-buster/Makefile new file mode 100644 index 00000000..37feb3c4 --- /dev/null +++ b/library/golang/1.27-buster/Makefile @@ -0,0 +1,36 @@ +# This file is generated by the template. + +REGISTRY ?= cr.loongnix.cn +ORGANIZATION ?= library +REPOSITORY ?= golang +GOMAJOR ?= 1.27 +GOMINOR ?= 1 +OSVERSION ?= buster +TAG ?= $(GOMAJOR)-$(OSVERSION) + +IMAGE = $(REGISTRY)/$(ORGANIZATION)/$(REPOSITORY):$(TAG) +ALIAS0 = $(REGISTRY)/$(ORGANIZATION)/$(REPOSITORY):$(GOMAJOR) +ALIAS1 = $(REGISTRY)/$(ORGANIZATION)/$(REPOSITORY):$(GOMAJOR).$(GOMINOR)-$(OSVERSION) +ALIAS2 = $(REGISTRY)/$(ORGANIZATION)/$(REPOSITORY):$(GOMAJOR).$(GOMINOR) +LATEST = $(REGISTRY)/$(ORGANIZATION)/$(REPOSITORY):latest + +default: image + +image: + docker build -t $(IMAGE) . + +push: alias + docker push $(IMAGE) + docker push $(ALIAS0) + docker push $(ALIAS1) + docker push $(ALIAS2) + +ifneq ($(LATEST),) + docker tag $(IMAGE) $(LATEST) + docker push $(LATEST) +endif + +alias: + docker tag $(IMAGE) $(ALIAS0) + docker tag $(IMAGE) $(ALIAS1) + docker tag $(IMAGE) $(ALIAS2)