GitLab cicd runner
DIND
ํ์ฌ yml ํ์ผ ๊ธฐ์ค์ผ๋ก ์ ์ผ ์์ ์๋ image ๊ฐ ํ์ฌ build๋ ์ด๋ฏธ์ง์ด๋ฆ์
Pytorch Docker image alpine
Alpine Linux ์ด๋ฏธ์ง ์ด๊ธฐ ๋๋ฌธ์ apt-get ์ด ์๋๋ผ
apt-get update ๋์ apk update
apt-get install ๋์ apk add pkgname ์ ์ฌ์ฉํด์ผ ํ๋ค.
Gitlab Runner in Docker Container (Docker in Docker setting)
- Run gitlab runner inside Docker Container
https://docs.gitlab.com/runner/install/docker.html
make docker container for gitlab-runner
docker run ํ ๋ privileged
args๋ฅผ ์ค์ผ์ง ์๋์ ๊ฐ์ ์๋ฌ๊ฐ ๋์ง ์๋๋ค.
๋ํ config.toml ์์๋ privileged๋ true๋ฅผ ์ค์ผ ํจ.
์๋ฌ๋ฉ์์ง: docker: Cannot connect to the Docker daemon at tcp://docker:2375. Is the docker daemon running?
ํด๊ฒฐ๋ฐฉ๋ฒ:
docker run -d --name gitlab-runner --privileged \
-v /home/yilgukseo/DL/Vision/FridaGAN/gitlab-runner:/etc/gitlab-runner \
-v /var/run/docker.sock:/var/run/docker.sock \
gitlab/gitlab-runner:latest
toml ํ์ผ์ด ์๋ ์ฒ๋ผ๋์ด์ผ ํ๊ธฐ ๋๋ฌธ์ mount๋ toml ํ์ผ์์ volumes์ ๊ธฐ์กด์ ์๋ "/certs/client"
๋ฅผ ์ถ๊ฐํด์ฃผ๋ฉด ๋๋ค.
[[runners]]
url = "https://gitlab.com/"
token = TOKEN
executor = "docker"
[runners.docker]
tls_verify = false
image = "docker:19.03.12"
privileged = true
disable_cache = false
volumes = ["/certs/client", "/cache"]
[runners.cache]
[runners.cache.s3]
[runners.cache.gcs]
https://docs.gitlab.com/ee/ci/docker/using_docker_build.html#docker-in-docker-with-tls-enabled
- register gitlab-runner inside docker container
gitlab-runner register
์ ๋ช ๋ น์ด๋ก gitlab-runner๋ฅผ ๋ฑ๋กํ๋ฉด ๋ค์๊ณผ ๊ฐ์ ๊ณผ์ ์ ๊ฑฐ์น๋ค.
- Enter the GitLab instance URL (for example, https://gitlab.com/):
- https://gitlab.com/
- Enter the registration token:
- your token from
settings/cicd/runners
- your token from
- Enter a description for the runner:
- your desc
- Enter tags for the runner (comma-separated):
- your tag
- Enter an executor: ssh, docker-ssh+machine, kubernetes, docker, parallels, shell, virtualbox, docker+machine, custom, docker-ssh:
- docker
- Enter the default Docker image (for example, ruby:2.6):
- docker:tagsyouwant
- message
Enter the GitLab instance URL (for example, https://gitlab.com/):
https://gitlab.com/
Enter the registration token:
{token}
Enter a description for the runner:
[dffbcd38570c]: jason3
Enter tags for the runner (comma-separated):
ceta3
Registering runnerโฆ succeeded runner=abcdefg
Enter an executor: ssh, docker-ssh+machine, kubernetes, docker, parallels, shell, virtualbox, docker+machine, custom, docker-ssh:
docker
Enter the default Docker image (for example, ruby:2.6):docker:latest
Runner registered successfully. Feel free to start it, but if itโs running already the config should be automatically reloaded!
์ด ์ํ๊ฐ ๋๊ณ ๋์ web์ ๊ฐ์ settings/cicd/runners
์ ๊ฐ๋ณด๋ฉด ์ด๋ก๋ถ์ด ์ผ์ ธ ์์ด์ผ ํ๋ค.
๋ค๋ง ์๊ฐ์ด ์ข ๊ฑธ๋ฆฌ๊ธฐ ๋๋ฌธ์ ์ข ๊ธฐ๋ค๋ฆฌ๋ฉด ๋ถ์ด ์ผ์ ธ์์์ ์ ์ ์๋ค.
Docker in Docker network
๊ธฐ์กด์ unittest ๊ตฌ์ฑ๋ฐฉ์ local ์์ ์งํํ๋ ๋ฐฉ์์ด์ด์ Docker in Docker (a.k.a. DinD) ํ๊ฒฝ์ด ์๋์๊ธฐ ๋๋ฌธ์ ์ปจํ
์ด๋๊ฐ ์ ์์ด ๊ฐ๋ฅํ๋ค.
ํ์ง๋ง ํ์ฌ๋ DinD ์ด๊ธฐ ๋๋ฌธ์ ํ์ฌ ๊น์ง ์์๋ณธ ๋ฐ๋ก๋ ๋์ปค ๋คํธ์ํฌ๋ฅผ gitlab-runner ๋์ปค๋ด๋ถ์์ ๊ตฌ์ฑํด์ค์ผ ํ๊ธฐ ๋๋ฌธ์ ๊ณจ์น๊ฐ
Docker image ๋งจ๋ค args
๊ธฐ์กด parse_args๋ก ์ฌ์ฉ์ด ๊ฐ๋ฅํจ.
docker run --net test_network --rm -e RABBITMQ_ENABLED -e RABBITMQ_HOST -e REDIS_ENABLED -e REDIS_HOST --name $CI_TEST_CONTAINER_NAME $CI_REGISTRY_IMAGE:$CI_COMMIT_TAG --debug --asset-url $CI_TEST_ASSET_URL_BASE --assets $CI_TEST_ASSET_0 --assets $CI_TEST_ASSET_1 --assets $CI_TEST_ASSET_2
- ENTRYPOINT์์ bracket์ผ๋ก ๊ฐ์ธ์ค์ผํ๊ณ โโ์ ์ฌ์ฉํด์ผ args๊ฐ ์ ๋๋ก ์๋ํจ.
Appendix
git mv
git mv oldname newname
is just shorthand for:
mv oldname newname
git add newname
git rm oldname
ref: https://stackoverflow.com/questions/1094269/whats-the-purpose-of-git-mv
Leave a comment