Skip to content

Commit

Permalink
Merge branch 'main' of github.com:Loongson-Cloud-Community/dockerfile…
Browse files Browse the repository at this point in the history
…s into main
  • Loading branch information
yzewei committed Jul 15, 2024
2 parents 7ed6cee + 91f09e5 commit a5c6558
Show file tree
Hide file tree
Showing 15 changed files with 741 additions and 149 deletions.
82 changes: 82 additions & 0 deletions kubernetes/etcd/3.5.14/0001-support-loong64.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
From bd6b2f4a97deeb4fec0d8054ef7fddd78b9be919 Mon Sep 17 00:00:00 2001
From: Lan Liang <[email protected]>
Date: Tue, 9 Jul 2024 03:59:09 +0000
Subject: [PATCH] support-loong64

Signed-off-by: Lan Liang <[email protected]>
---
Dockerfile-release.loong64 | 15 +++++++++++++++
Makefile | 8 +++++---
server/etcdmain/etcd.go | 1 +
3 files changed, 21 insertions(+), 3 deletions(-)
create mode 100644 Dockerfile-release.loong64

diff --git a/Dockerfile-release.loong64 b/Dockerfile-release.loong64
new file mode 100644
index 000000000..cd94364bb
--- /dev/null
+++ b/Dockerfile-release.loong64
@@ -0,0 +1,15 @@
+ARG BASE_IMG=cr.loongnix.cn/prometheus/busybox:glibc
+FROM ${BASE_IMG}
+ENV ETCD_UNSUPPORTED_ARCH=loong64
+
+COPY etcd /usr/local/bin/
+COPY etcdctl /usr/local/bin/
+COPY etcdutl /usr/local/bin/
+
+WORKDIR /var/etcd/
+WORKDIR /var/lib/etcd/
+
+EXPOSE 2379 2380
+
+# Define default command.
+CMD ["/usr/local/bin/etcd"]
\ No newline at end of file
diff --git a/Makefile b/Makefile
index 8cfd790e0..f122e3d7f 100644
--- a/Makefile
+++ b/Makefile
@@ -53,7 +53,8 @@ docker-remove:
docker rm --force `docker ps -a -q` || true
docker rmi --force `docker images -q` || true

-
+IMAGE ?= gcr.io/etcd-development/etcd:$(ETCD_VERSION)
+BASE_IMG ?= cr.loongnix.cn/prometheus/busybox:glibc

GO_VERSION ?= $(shell cat .go-version)
ETCD_VERSION ?= $(shell git rev-parse --short HEAD || echo "GitNotFound")
@@ -223,14 +224,15 @@ build-docker-release-main:
cp ./Dockerfile-release.$(ARCH) ./bin/Dockerfile-release.$(ARCH)
docker build \
--network=host \
- --tag gcr.io/etcd-development/etcd:$(ETCD_VERSION) \
+ --build-arg BASE_IMG=$(BASE_IMG) \
+ --tag $(IMAGE) \
--file ./bin/Dockerfile-release.$(ARCH) \
./bin
rm -f ./bin/Dockerfile-release.$(ARCH)

docker run \
--rm \
- gcr.io/etcd-development/etcd:$(ETCD_VERSION) \
+ $(IMAGE) \
/bin/sh -c "/usr/local/bin/etcd --version && /usr/local/bin/etcdctl version && /usr/local/bin/etcdutl version"

push-docker-release-main:
diff --git a/server/etcdmain/etcd.go b/server/etcdmain/etcd.go
index 9921b89df..0ac9c6737 100644
--- a/server/etcdmain/etcd.go
+++ b/server/etcdmain/etcd.go
@@ -471,6 +471,7 @@ func checkSupportArch() {
// to add a new platform, check https://github.com/etcd-io/website/blob/main/content/en/docs/next/op-guide/supported-platform.md
if runtime.GOARCH == "amd64" ||
runtime.GOARCH == "arm64" ||
+ runtime.GOARCH == "loong64" ||
runtime.GOARCH == "ppc64le" ||
runtime.GOARCH == "s390x" {
return
--
2.45.2

52 changes: 52 additions & 0 deletions kubernetes/etcd/3.5.14/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# This file is generated by the template.

REGISTRY?=cr.loongnix.cn
ORGANIZATION?=kubernetes
REPOSITORY?=etcd
TAG?=v3.5.14
LATEST?=true

GO_IMG?=cr.loongnix.cn/library/golang:1.21
GOPROXY=https://goproxy.cn,https://mirrors.aliyun.com/goproxy/,https://goproxy.io,direct

IMAGE=$(REGISTRY)/$(ORGANIZATION)/$(REPOSITORY):$(patsubst v%,%,$(TAG))
LATEST_IMAGE=$(REGISTRY)/$(ORGANIZATION)/$(REPOSITORY):latest

SOURCE_URL=https://github.com/etcd-io/etcd.git
SOURCE=$(shell echo $(SOURCE_URL) | awk -F '/' '{print $$NF}' | awk -F '.' '{print $$1}')
PATCH=0001-support-loong64.patch

default: image

src/$(SOURCE):
git clone -b $(TAG) --depth=1 $(SOURCE_URL) $@
cd $@ && \
git apply ../../$(PATCH)

build: src/$(SOURCE)
docker run --rm \
-e GOARCH=loong64 \
-e ETCD_UNSUPPORTED_ARCH=loong64 \
-e GOPROXY=$(GOPROXY) \
-e FORCE_HOST_GO=1 \
-e HTTPS_PROXY=$(http_proxy) -e HTTP_PROXY=$(http_proxy) \
-v `pwd`/src/$(SOURCE):/v -w /v \
$(GO_IMG) make build


image: src/$(SOURCE) build
export ETCD_UNSUPPORTED_ARCH=loong64 && \
ARCH=loong64 IMAGE=$(IMAGE) \
BASE_IMG=cr.loongnix.cn/prometheus/busybox:glibc \
make -C src/$(SOURCE) build-docker-release-main

push:
docker push $(IMAGE)
@if [ $(LATEST) = "true" ]; \
then\
docker tag $(IMAGE) $(LATEST_IMAGE); \
docker push $(LATEST_IMAGE); \
fi

clean:
rm -rf src
82 changes: 9 additions & 73 deletions library/golang/1.21-alpine/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
FROM cr.loongnix.cn/library/alpine:3.11

RUN apk add --no-cache ca-certificates
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
Expand All @@ -9,85 +10,20 @@ RUN [ ! -e /etc/nsswitch.conf ] && echo 'hosts: files dns' > /etc/nsswitch.conf

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

ENV GOLANG_VERSION 1.21.5
ENV GOLANG_VERSION 1.21.11

# Bootstrap for Go1.21 requires minimum Go1.17, now build Go1.19 as bootstrap for Go1.21.x
RUN set -eux; \
build=1; \
url='http://ftp.loongnix.cn/toolchain/golang/go-1.19/abi1.0/go1.19.7.src.tar.gz'; \
sha256='3b423c46d1ed679520bb8af7bf28594f93b2a81854d7fd22320f569f7dc4715d'; \
export GOARCH='loong64' GOOS='linux'; \
\
wget -O go.tgz "$url"; \
url='http://ftp.loongnix.cn/toolchain/golang/go-1.21/abi1.0/go1.21.11.linux-loong64.tar.gz'; \
sha256='b9319df453c355cad74dc378e23613105d53a5da7f92ba338ff221e0fbb10fcf'; \
wget -O go.tgz "$url" --progress=dot:giga; \
echo "$sha256 *go.tgz" | sha256sum -c -; \
\
tar -C /usr/local -xzf go.tgz; \
rm go.tgz; \
\
apk add --no-cache --virtual .build-deps bash gcc go musl-dev; \
\
cd /usr/local/go/src; \
export GOCACHE='/tmp/gocache'; \
export GOROOT_BOOTSTRAP="$(go env GOROOT)" GOHOSTOS="$GOOS" GOHOSTARCH="$GOARCH"; \
./make.bash; \
\
cd ../../ && mv go go-bootstrap; \
rm -rf "$GOCACHE"; \
\
/usr/local/go-bootstrap/bin/go version


RUN set -eux; \
build=1; \
# https://github.com/golang/go/issues/38536#issuecomment-616897960
url='http://ftp.loongnix.cn/toolchain/golang/go-1.21/abi1.0/go1.21.5.src.tar.gz'; \
sha256='ae56f26d2118096e45366604c5ffdac112a06cddcd18b8c1451c2a57ae67f0f3'; \
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="/usr/local/go-bootstrap" 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" \
/usr/local/go-bootstrap \
; \
fi; \
\
go version

## clean
RUN apk del wget

ENV GOPATH /go
ENV PATH $GOPATH/bin:$PATH
RUN mkdir -p "$GOPATH/src" "$GOPATH/bin" && chmod -R 777 "$GOPATH"
Expand Down
6 changes: 3 additions & 3 deletions library/golang/1.21-buster/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ RUN set -eux; \

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

ENV GOLANG_VERSION 1.21.5
ENV GOLANG_VERSION 1.21.11

RUN set -eux; \
url='http://ftp.loongnix.cn/toolchain/golang/go-1.21/abi1.0/go1.21.5.linux-loong64.tar.gz'; \
sha256='68c0d5ba6cdf55ab3cd26cb67fccf1ad0c9a79e3f69a99c5cafff18c88eee3f3'; \
url='http://ftp.loongnix.cn/toolchain/golang/go-1.21/abi1.0/go1.21.11.linux-loong64.tar.gz'; \
sha256='b9319df453c355cad74dc378e23613105d53a5da7f92ba338ff221e0fbb10fcf'; \
wget -O go.tgz "$url" --progress=dot:giga; \
echo "$sha256 *go.tgz" | sha256sum -c -; \
tar -C /usr/local -xzf go.tgz; \
Expand Down
10 changes: 5 additions & 5 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 @@ -20,10 +20,10 @@ push: alias
docker push $(IMAGE)
docker push $(ALIAS)

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

alias:
docker tag $(IMAGE) $(ALIAS)
62 changes: 8 additions & 54 deletions library/golang/1.22-alpine/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
FROM cr.loongnix.cn/library/alpine:3.11

RUN apk add --no-cache ca-certificates
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
Expand All @@ -9,66 +10,19 @@ RUN [ ! -e /etc/nsswitch.conf ] && echo 'hosts: files dns' > /etc/nsswitch.conf

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

ENV GOLANG_VERSION 1.22.0
ENV GOLANG_VERSION 1.22.4

RUN set -eux; \
build=1; \
url='http://ftp.loongnix.cn/toolchain/golang/go-1.21/abi1.0/go1.21.5.linux-loong64.tar.gz'; \
sha256='68c0d5ba6cdf55ab3cd26cb67fccf1ad0c9a79e3f69a99c5cafff18c88eee3f3'; \
\
wget -O go.tgz "$url"; \
url='http://ftp.loongnix.cn/toolchain/golang/go-1.22/abi1.0/go1.22.4.linux-loong64.tar.gz'; \
sha256='6f4c493e362569ae44c63637d05684f5d8cd4986108929d895d55c33dc9068b3'; \
wget -O go.tgz "$url" --progress=dot:giga; \
echo "$sha256 *go.tgz" | sha256sum -c -; \
\
tar -C /usr/local -xzf go.tgz && rm go.tgz; \
cd /usr/local && mv go go-bootstrap; \
/usr/local/go-bootstrap/bin/go version

RUN set -eux; \
build=1; \
# https://github.com/golang/go/issues/38536#issuecomment-616897960
url='http://ftp.loongnix.cn/toolchain/golang/go-1.22/abi1.0/go1.22.0.src.tar.gz'; \
sha256='d8932410dbe6b9d02dc723e17ee66858e356b0e83a02bd8b1f22ab334f98ad37'; \
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 \
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="/usr/local/go-bootstrap" GOHOSTOS="$GOOS" GOHOSTARCH="$GOARCH"; \
./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" \
/usr/local/go-bootstrap \
; \
fi; \
\
go version

RUN apk del wget

ENV GOPATH /go
ENV PATH $GOPATH/bin:$PATH
RUN mkdir -p "$GOPATH/src" "$GOPATH/bin" && chmod -R 777 "$GOPATH"
Expand Down
7 changes: 3 additions & 4 deletions library/golang/1.22-buster/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,11 @@ RUN set -eux; \
rm -rf /var/lib/apt/lists/*

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

ENV GOLANG_VERSION 1.22.0
ENV GOLANGVERSION 1.22.4

RUN set -eux; \
url='http://ftp.loongnix.cn/toolchain/golang/go-1.22/abi1.0/go1.22.0.linux-loong64.tar.gz'; \
sha256='89275a1328d31222a82677520b7a1f6911e6f74567b1e73469b13225b5820ac8'; \
url='http://ftp.loongnix.cn/toolchain/golang/go-1.22/abi1.0/go1.22.4.linux-loong64.tar.gz'; \
sha256='6f4c493e362569ae44c63637d05684f5d8cd4986108929d895d55c33dc9068b3'; \
wget -O go.tgz "$url" --progress=dot:giga; \
echo "$sha256 *go.tgz" | sha256sum -c -; \
tar -C /usr/local -xzf go.tgz; \
Expand Down
8 changes: 4 additions & 4 deletions library/golang/1.22-buster/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ push: alias
docker push $(IMAGE)
docker push $(ALIAS)

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

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

0 comments on commit a5c6558

Please sign in to comment.