-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: yzewei <[email protected]>
- Loading branch information
Showing
4 changed files
with
96 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
|