Skip to content

Commit

Permalink
add golang 1.19-alpine
Browse files Browse the repository at this point in the history
Signed-off-by: yzewei <[email protected]>
  • Loading branch information
yzewei committed Apr 8, 2024
1 parent ae9d2c2 commit 93f48b3
Show file tree
Hide file tree
Showing 4 changed files with 96 additions and 6 deletions.
13 changes: 9 additions & 4 deletions gitlab/gitlab-runner-helper/13.11/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,15 @@ FROM lcr.loongnix.cn/library/alpine:3.19
ENV PATH="${PATH:-/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin}"

# hadolint ignore=DL3018
RUN apk add --no-cache bash ca-certificates dumb-init git git-lfs miniperl wget\
&& ln -s miniperl /usr/bin/perl

RUN git lfs install --skip-repo
RUN apk add --no-cache bash ca-certificates dumb-init git miniperl wget \
&& ln -s miniperl /usr/bin/perl \
&& wget https://github.com/git-lfs/git-lfs/releases/download/v3.5.1/git-lfs-linux-loong64-v3.5.1.tar.gz -O git-lfs.tar.gz \
&& tar xf git-lfs.tar.gz \
&& mv git-lfs-3.5.1/git-lfs /usr/bin \
&& chmod +x /usr/bin/git-lfs \
&& rm -rf git-lfs*

RUN git-lfs install --skip-repo

COPY ./helpers/entrypoint /
RUN chmod +x /entrypoint
Expand Down
3 changes: 1 addition & 2 deletions gitlab/gitlab-runner/13.11-alpine/install-deps
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,7 @@ wget -nv "https://github.com/Loongson-Cloud-Community/dumb-init/releases/downloa
chmod +x /usr/bin/dumb-init
dumb-init --version

#wget -nv "https://github.com/Loongson-Cloud-Community/git-lfs/releases/download/v2.11.0/git-lfs-linux-loong64" -O /usr/bin/git-lfs
wget -nv "https://github.com/Loongson-Cloud-Community/git-lfs/releases/download/v2.11.0-abi2.0/git-lfs-linux-loong64" -O /usr/bin/git-lfs
wget https://github.com/git-lfs/git-lfs/releases/download/v3.5.1/git-lfs-linux-loong64-v3.5.1.tar.gz -O git-lfs.tar.gz && tar xf git-lfs.tar.gz && cp git-lfs-3.5.1/git-lfs /usr/bin
ls -l /usr/bin/git-lfs
chmod +x /usr/bin/git-lfs
/usr/bin/git-lfs install --skip-repo
Expand Down
67 changes: 67 additions & 0 deletions library/golang/1.19-alpine/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
FROM lcr.loongnix.cn/library/alpine:3.19

RUN apk add --no-cache ca-certificates

# 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.19.11

RUN set -eux; \
build=1; \
# https://github.com/golang/go/issues/38536#issuecomment-616897960
url='http://ftp.loongnix.cn/toolchain/golang/go-1.19/abi2.0/go1.19.11.src.tar.gz'; \
sha256='92fbf94d2c77b222d1b75fd9f3edc8f7d05c13aa986d4a5e5c1bafb6f262ee97'; \
export GOARCH='loong64' GOOS='linux'; \
\
wget -O go.tgz "$url"; \
echo "$sha256 *go.tgz" | sha256sum -c -; \
\
tar -C /usr/local -xzf go.tgz; \
rm go.tgz; \
\
if [ -n "$build" ]; then \
apk add --no-cache --virtual .build-deps \
bash \
gcc \
go \
musl-dev \
; \
\
export GOCACHE='/tmp/gocache'; \
\
( \
cd /usr/local/go/src; \
# set GOROOT_BOOTSTRAP + GOHOST* such that we can build Go successfully
export GOROOT_BOOTSTRAP="$(go env GOROOT)" GOHOSTOS="$GOOS" GOHOSTARCH="$GOARCH"; \
if [ "${GOARCH:-}" = '386' ]; then \
# https://github.com/golang/go/issues/52919; https://github.com/docker-library/golang/pull/426#issuecomment-1152623837
export CGO_CFLAGS='-fno-stack-protector'; \
fi; \
./make.bash; \
); \
\
apk del --no-network .build-deps; \
\
# remove a few intermediate / bootstrapping files the official binary release tarballs do not contain
rm -rf \
/usr/local/go/pkg/*/cmd \
/usr/local/go/pkg/bootstrap \
/usr/local/go/pkg/obj \
/usr/local/go/pkg/tool/*/api \
/usr/local/go/pkg/tool/*/go_bootstrap \
/usr/local/go/src/cmd/dist/dist \
"$GOCACHE" \
; \
fi; \
\
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.19-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.19-alpine

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

default: image

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

push:
docker push $(IMAGE)

0 comments on commit 93f48b3

Please sign in to comment.