-
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.
Merge pull request #27 from yzewei/main
add
- Loading branch information
Showing
14 changed files
with
344 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
FROM lcr.loongnix.cn/library/alpine:3.19 | ||
|
||
# gitlab-runner-helper will try to resolve `sh` from the path. We ensure the PATH is populated by default, as some container runtimes do no longer set a default (e.g. containerd v1.2.8) | ||
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 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 | ||
|
||
COPY ./scripts/ /usr/bin/ | ||
|
||
## 下载gitlab-runner-helper | ||
RUN wget -nv "https://github.com/Loongson-Cloud-Community/gitlab-runner/releases/download/v13.11.0-abi2/gitlab-runner-helper-linux-loong64" -O /usr/bin/gitlab-runner-helper \ | ||
&& chmod +x /usr/bin/gitlab-runner-helper \ | ||
&& gitlab-runner-helper -v | ||
|
||
RUN echo 'hosts: files dns' >> /etc/nsswitch.conf | ||
|
||
# NOTE: The ENTRYPOINT metadata is not preserved on export, so we need to reapply this metadata on import. | ||
# See https://gitlab.com/gitlab-org/gitlab-runner/-/merge_requests/2058#note_388341301 | ||
ENTRYPOINT ["/usr/bin/dumb-init", "/entrypoint"] | ||
CMD ["sh"] |
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,28 @@ | ||
# This file is generated by the template. | ||
|
||
REGISTRY?=lcr.loongnix.cn | ||
ORGANIZATION?=gitlab | ||
REPOSITORY?=gitlab-runner-helper | ||
TAG?=13.11 | ||
LATEST?=true | ||
|
||
IMAGE=$(REGISTRY)/$(ORGANIZATION)/$(REPOSITORY):$(TAG) | ||
LATEST_IMAGE=$(REGISTRY)/$(ORGANIZATION)/$(REPOSITORY):latest | ||
|
||
default: image | ||
|
||
image: | ||
docker build \ | ||
--build-arg http_proxy=$(http_proxy) \ | ||
--build-arg https_proxy=$(https_proxy) \ | ||
-t $(IMAGE) \ | ||
. | ||
|
||
push: | ||
docker push $(IMAGE) | ||
#latest image | ||
@if [ $(LATEST) = "true" ]; \ | ||
then \ | ||
docker tag $(IMAGE) $(LATEST_IMAGE); \ | ||
docker push $(LATEST_IMAGE); \ | ||
fi |
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,14 @@ | ||
param( | ||
[string]$TargetFile, | ||
[string]$ExpectedHash | ||
) | ||
|
||
$hash = Get-FileHash -Path $TargetFile -Algorithm SHA256 | ||
|
||
if (-not ($hash.Hash -eq $ExpectedHash)) { | ||
Write-Warning "SHA256 checksum for $TargetFile is invalid" | ||
exit 1 | ||
} | ||
|
||
Write-Output "SHA256 checksum for $TargetFile is valid" | ||
exit 0 |
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,21 @@ | ||
#!/bin/bash | ||
|
||
# gitlab-runner data directory | ||
DATA_DIR="/etc/gitlab-runner" | ||
# custom certificate authority path | ||
CA_CERTIFICATES_PATH=${CA_CERTIFICATES_PATH:-$DATA_DIR/certs/ca.crt} | ||
LOCAL_CA_PATH="/usr/local/share/ca-certificates/ca.crt" | ||
|
||
update_ca() { | ||
echo "Updating CA certificates..." | ||
cp "${CA_CERTIFICATES_PATH}" "${LOCAL_CA_PATH}" | ||
update-ca-certificates --fresh >/dev/null | ||
} | ||
|
||
if [ -f "${CA_CERTIFICATES_PATH}" ]; then | ||
# update the ca if the custom ca is different than the current | ||
cmp -s "${CA_CERTIFICATES_PATH}" "${LOCAL_CA_PATH}" || update_ca | ||
fi | ||
|
||
# launch CMD passing all arguments | ||
exec "$@" |
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,10 @@ | ||
@echo off | ||
|
||
IF NOT DEFINED LOCAL_CA_PATH (SET LOCAL_CA_PATH="C:\GitLab-Runner\certs\ca.crt") | ||
|
||
IF EXIST %LOCAL_CA_PATH% ( | ||
echo "Adding CA certificate..." | ||
certutil -addstore "Root" %LOCAL_CA_PATH% | ||
) | ||
|
||
%* |
3 changes: 3 additions & 0 deletions
3
gitlab/gitlab-runner-helper/13.11/scripts/gitlab-runner-build
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,3 @@ | ||
#!/bin/bash | ||
umask 0000 | ||
exec /bin/bash |
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,28 @@ | ||
FROM lcr.loongnix.cn/library/alpine:3.19 | ||
|
||
RUN adduser -D -S -h /home/gitlab-runner gitlab-runner | ||
|
||
# hadolint ignore=DL3018 | ||
RUN apk add --no-cache \ | ||
bash \ | ||
ca-certificates \ | ||
git \ | ||
tzdata \ | ||
openssh-client | ||
|
||
# COPY gitlab-runner-linux-* /usr/bin/ | ||
COPY install-deps install-gitlab-runner /tmp/ | ||
|
||
# Install GNU wget for "-nv" flag support | ||
# hadolint ignore=DL3018 | ||
RUN apk add --no-cache --virtual .fetch-deps wget curl && \ | ||
/tmp/install-deps && \ | ||
apk del .fetch-deps | ||
|
||
COPY entrypoint / | ||
RUN chmod +x /entrypoint | ||
|
||
STOPSIGNAL SIGQUIT | ||
VOLUME ["/etc/gitlab-runner", "/home/gitlab-runner"] | ||
ENTRYPOINT ["/usr/bin/dumb-init", "/entrypoint"] | ||
CMD ["run", "--user=gitlab-runner", "--working-directory=/home/gitlab-runner"] |
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,28 @@ | ||
# This file is generated by the template. | ||
|
||
REGISTRY?=lcr.loongnix.cn | ||
ORGANIZATION?=gitlab | ||
REPOSITORY?=gitlab-runner | ||
TAG?=13.11-alpine | ||
LATEST?=true | ||
|
||
IMAGE=$(REGISTRY)/$(ORGANIZATION)/$(REPOSITORY):$(TAG) | ||
LATEST_IMAGE=$(REGISTRY)/$(ORGANIZATION)/$(REPOSITORY):latest | ||
|
||
default: image | ||
|
||
image: | ||
docker build \ | ||
--build-arg http_proxy=$(http_proxy) \ | ||
--build-arg https_proxy=$(https_proxy) \ | ||
-t $(IMAGE) \ | ||
. | ||
|
||
push: | ||
docker push $(IMAGE) | ||
#latest image | ||
@if [ $(LATEST) = "true" ]; \ | ||
then \ | ||
docker tag $(IMAGE) $(LATEST_IMAGE); \ | ||
docker push $(LATEST_IMAGE); \ | ||
fi |
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 @@ | ||
`gitlab/gitlab-runner:alpine` is image with minimal footprint based on Alpine Linux that runs GitLab Runner. |
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,22 @@ | ||
#!/bin/sh | ||
|
||
# gitlab-runner data directory | ||
DATA_DIR="/etc/gitlab-runner" | ||
CONFIG_FILE=${CONFIG_FILE:-$DATA_DIR/config.toml} | ||
# custom certificate authority path | ||
CA_CERTIFICATES_PATH=${CA_CERTIFICATES_PATH:-$DATA_DIR/certs/ca.crt} | ||
LOCAL_CA_PATH="/usr/local/share/ca-certificates/ca.crt" | ||
|
||
update_ca() { | ||
echo "Updating CA certificates..." | ||
cp "${CA_CERTIFICATES_PATH}" "${LOCAL_CA_PATH}" | ||
update-ca-certificates --fresh >/dev/null | ||
} | ||
|
||
if [ -f "${CA_CERTIFICATES_PATH}" ]; then | ||
# update the ca if the custom ca is different than the current | ||
cmp -s "${CA_CERTIFICATES_PATH}" "${LOCAL_CA_PATH}" || update_ca | ||
fi | ||
|
||
# launch gitlab-runner passing all arguments | ||
exec gitlab-runner "$@" |
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,61 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -veEo pipefail | ||
|
||
SCRIPTPATH="$( cd "$(dirname "$0")" ; pwd -P )" | ||
|
||
TARGETPLATFORM="linux/loong64" | ||
DOCKER_MACHINE_VERSION="xxxx" | ||
DUMB_INIT_VERSION="1.2.2" | ||
GIT_LFS_VERSION="2.11.0" | ||
|
||
case "${TARGETPLATFORM}" in | ||
"linux/arm64") | ||
ARCH=arm64 | ||
DOCKER_MACHINE_ARCH=aarch64 | ||
DUMB_INIT_ARCH=aarch64 | ||
GIT_LFS_ARCH=arm64 | ||
;; | ||
"linux/amd64" | "") | ||
ARCH=amd64 | ||
DOCKER_MACHINE_ARCH=x86_64 | ||
DUMB_INIT_ARCH=x86_64 | ||
GIT_LFS_ARCH=amd64 | ||
;; | ||
"linux/s390x") | ||
ARCH=s390x | ||
DOCKER_MACHINE_ARCH=s390x | ||
DUMB_INIT_ARCH=s390x | ||
GIT_LFS_ARCH=s390x | ||
;; | ||
"linux/loong64") | ||
ARCH=loong64 | ||
DOCKER_MACHINE_ARCH=loong64 | ||
DUMB_INIT_ARCH=loong64 | ||
GIT_LFS_ARCH=loong64 | ||
;; | ||
*) | ||
echo "Unexpected TARGETPLATFORM value: ${TARGETPLATFORM}" | ||
;; | ||
esac; | ||
|
||
"${SCRIPTPATH}/install-gitlab-runner" "${ARCH}" | ||
rm "${SCRIPTPATH}/install-gitlab-runner" | ||
gitlab-runner --version | ||
|
||
mkdir -p /etc/gitlab-runner/certs | ||
chmod -R 700 /etc/gitlab-runner | ||
|
||
echo "No checksum specified for docker-machine, skipping." | ||
|
||
wget -nv "https://github.com/Loongson-Cloud-Community/dumb-init/releases/download/v1.2.2/dumb-init-loongarch64" -O /usr/bin/dumb-init | ||
chmod +x /usr/bin/dumb-init | ||
dumb-init --version | ||
|
||
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 | ||
git-lfs version | ||
|
||
# sha256sum -c -w "${SCRIPTPATH}/checksums-${ARCH}" |
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,10 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -ev | ||
|
||
curl -L -o /usr/bin/gitlab-runner https://github.com/Loongson-Cloud-Community/gitlab-runner/releases/download/v13.11.0-abi2/gitlab-runner-linux-loong64 | ||
chmod +x /usr/bin/gitlab-runner | ||
ln -s /usr/bin/gitlab-runner /usr/bin/gitlab-ci-multi-runner | ||
## 后续cloud网站上线更换 | ||
#wget http://cloud.loongnix.cn/releases/loongarch64/gitlabhq%2Fgitlab-runner%2Fv13.11.0%2Fgitlab-runner-linux-loong64.tar.gz && tar xf gitlab-runner-linux-loong64.tar.gz && mv gitlab-runner-linux-loong64 /usr/bin | ||
#mv "/usr/bin/gitlab-runner-linux-loong64" /usr/bin/gitlab-runner |
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) | ||
|