sudo curl -L --output /usr/local/bin/gitlab-runner https://gitlab-runner-downloads.s3.amazonaws.com/latest/binaries/gitlab-runner-linux-amd64
sudo chmod +x /usr/local/bin/gitlab-runner
sudo useradd --comment 'GitLab Runner' --create-home gitlab-runner --shell /bin/bash
sudo gitlab-runner install --user=gitlab-runner --working-directory=/home/gitlab-runner
sudo gitlab-runner start
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | stages: - build variables: HOST: "true" # 定义一个变量,用于存储主机地址 host: "0.0.0.0" build-cert: tags: - cert stage: build script: - echo "Gen certs..." - sh deploy/https/generate_certs.sh $host # 使用变量替换之前的硬编码地址 - echo $HOST - echo $host only: variables: - $HOST == "true" artifacts: paths: - tj.registry.com/ |
---|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | stages: - build before_script: - docker info build-job: stage: build image: docker:cli tags: - shell script: - pwd - echo "Compiling the code..." - echo "Compile complete." - docker build -t gpu-expotter:v1 . - docker tag gpu-expotter:v1 tj.inner1.harbor.com/gitlab-ci/gpu-expotter:v1 # 替换 CI_REGISTRY_IMAGE 为你的镜像仓库地址 - docker login -u admin -p zjlab12345 tj.inner1.harbor.com # 使用 CI/CD 变量进行认证 - docker push tj.inner1.harbor.com/gitlab-ci/gpu-expotter:v1 # 推送镜像到 GitLab 的容器注册表或其他镜像仓库 |
---|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | stages: - build build-bin: tags: - bin stage: build script: - echo "Compiling the code..." - pwd - go build -o ./bin/image-operator cmd/image-operator/main.go # 使用变量替换之前的硬编码地址 artifacts: paths: - bin/ |
---|
gitlab-ctl reconfigure gitlab-ctl restart
10.11.140.85 gitlab.private.com
1 | sudo apt install docker-buildx |
---|
1 | docker run --privileged --rm tonistiigi/binfmt --install all |
---|
1 | docker buildx build --platform linux/arm64 -t helloword:v3 . |
---|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | stages: - build before_script: - docker info build-job: stage: build image: docker:cli tags: - shell script: - pwd - docker buildx build --platform linux/arm64 -t helloword:v3 . - docker tag helloword:v3 tj.inner1.harbor.com/gitlab-ci/helloword:v3 - docker login -u admin -p **** tj.inner1.harbor.com - docker push tj.inner1.harbor.com/gitlab-ci/helloword:v3 |
---|
1 | docker run -d -u 0 -p 8080:8080 -p 50000:50000 -v /home/jenkins/:/var/jenkins_home -v /var/run/docker.sock:/var/run/docker.sock -v /usr/bin/docker:/usr/bin/docker -v /root/go:/root/go --privileged jenkins/jenkins |
---|
通过挂载二进制方式,让docker 的Jenkins 可以使用 docker 和 golang