Skip to content

Commit

Permalink
library/golang:: add 1.22-{buster,alpine} support
Browse files Browse the repository at this point in the history
  • Loading branch information
abner-chenc committed Jun 15, 2024
1 parent 131679a commit a474f2c
Show file tree
Hide file tree
Showing 5 changed files with 110 additions and 7 deletions.
14 changes: 7 additions & 7 deletions library/golang/1.21-buster/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ TAG ?= 1.21-buster

IMAGE = $(REGISTRY)/$(ORGANIZATION)/$(REPOSITORY):$(TAG)
ALIAS = $(REGISTRY)/$(ORGANIZATION)/$(REPOSITORY):1.21
LATEST = $(REGISTRY)/$(ORGANIZATION)/$(REPOSITORY):latest
LATEST =

default: image

Expand All @@ -17,13 +17,13 @@ image:
.

push: alias
docker push $(IMAGE)
docker push $(ALIAS)
docker push $(IMAGE)
docker push $(ALIAS)

@if [ -n $(LATEST) ]; then \
docker tag $(IMAGE) $(LATEST); \
docker push $(LATEST); \
fi
@if [ -n $(LATEST) ]; then \
docker tag $(IMAGE) $(LATEST); \
docker push $(LATEST); \
fi

alias:
docker tag $(IMAGE) $(ALIAS)
Expand Down
21 changes: 21 additions & 0 deletions library/golang/1.22-alpine/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
FROM lcr.loongnix.cn/library/alpine:3.19

RUN apk --no-cache upgrade
RUN apk add --no-cache ca-certificates gcc musl-dev bash wget

ENV PATH /usr/local/go/bin:$PATH
ENV GOLANG_VERSION 1.22.4

RUN set -eux; \
url='http://ftp.loongnix.cn/toolchain/golang/go-1.22/abi2.0/go1.22.4.linux-loong64.tar.gz'; \
sha256='5912a81cdaf3109f68e2d76e2db19378bd48ff60acd86c9c04becd0d48556aba'; \
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
19 changes: 19 additions & 0 deletions library/golang/1.22-alpine/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# This file is generated by the template.

REGISTRY ?= lcr.loongnix.cn
ORGANIZATION ?= library
REPOSITORY ?= golang
TAG ?= 1.22-alpine

IMAGE = $(REGISTRY)/$(ORGANIZATION)/$(REPOSITORY):$(TAG)

default: image

image:
docker build \
-t $(IMAGE) \
.

push:
docker push $(IMAGE)

34 changes: 34 additions & 0 deletions library/golang/1.22-buster/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
FROM lcr.loongnix.cn/library/debian:sid

# install cgo-related dependencies
RUN set -eux; \
apt-get update; \
apt-get install -y --no-install-recommends \
g++ \
gcc \
libc6-dev \
make \
wget \
pkg-config \
; \
apt-get autoclean all; \
rm -rf /var/lib/apt/lists/*

ENV PATH /usr/local/go/bin:$PATH

ENV GOLANG_VERSION 1.22.4

RUN set -eux; \
url='http://ftp.loongnix.cn/toolchain/golang/go-1.22/abi2.0/go1.22.4.linux-loong64.tar.gz'; \
sha256='5912a81cdaf3109f68e2d76e2db19378bd48ff60acd86c9c04becd0d48556aba'; \
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

29 changes: 29 additions & 0 deletions library/golang/1.22-buster/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# This file is generated by the template.

REGISTRY ?= lcr.loongnix.cn
ORGANIZATION ?= library
REPOSITORY ?= golang
TAG ?= 1.22-buster

IMAGE = $(REGISTRY)/$(ORGANIZATION)/$(REPOSITORY):$(TAG)
ALIAS = $(REGISTRY)/$(ORGANIZATION)/$(REPOSITORY):1.22
LATEST = $(REGISTRY)/$(ORGANIZATION)/$(REPOSITORY):latest

default: image

image:
docker build \
-t $(IMAGE) \
.

push: alias
docker push $(IMAGE)
docker push $(ALIAS)
@if [ -n $(LATEST) ]; then \
docker tag $(IMAGE) $(LATEST); \
docker push $(LATEST); \
fi

alias:
docker tag $(IMAGE) $(ALIAS)

0 comments on commit a474f2c

Please sign in to comment.