添加 deployment/example.gitlab-ci.yml

This commit is contained in:
loveuer 2024-04-07 12:23:01 +08:00
parent 1000a39dc5
commit ed5324326f

View File

@ -0,0 +1,37 @@
stages:
- config
- build
- run
config hello:
stage: config
image: repository.umisen.com/external/kubectl:latest
tags:
- rancher-dev
script:
- kubectl -n gitlab-runner create configmap hello-config --from-file=etc/config.json
build hello:
stage: build
image: repository.umisen.com/external/kaniko:latest
tags:
- rancher-dev
script:
- export CI_REGISTRY="repository.umisen.com"
- export CI_REGISTRY_IMAGE="${CI_REGISTRY}/build/tools/hello:latest"
- export CI_DOCKERFILE="$CI_PROJECT_DIR/Dockerfile"
- export CI_REGISTRY_AUTH_API="${CI_REGISTRY}/v1"
- export CI_REGISTRY_USERNAME="gitlab-runner"
- export CI_REGISTRY_PASSWORD="sonar@404"
- echo '10.220.10.17 repository.umisen.com' >> /etc/hosts
- mkdir -p /kaniko/.docker
- echo "{\"auths\":{\"${CI_REGISTRY_AUTH_API}\":{\"auth\":\"$(printf "%s:%s" "${CI_REGISTRY_USERNAME}" "${CI_REGISTRY_PASSWORD}" | base64 | tr -d '\n')\"}}}" > /kaniko/.docker/config.json
- /kaniko/executor --skip-tls-verify-registry "${CI_REGISTRY}" --context "${CI_PROJECT_DIR}" --dockerfile "${CI_DOCKERFILE}" --destination "${CI_REGISTRY_IMAGE}" #--insecure --insecure-registry
run hello:
stage: run
image: repository.umisen.com/external/kubectl:latest
tags:
- rancher-dev
script:
- kubectl apply -f hello.yaml