Install Gitlab Runner 참고 {: .prompt-info }
1stages:
2 - build
3 - test
4
5variables:
6 # DOCKER_HOST: tcp://docker:2376
7 # DOCKER_HOST: tcp://docker:2375
8 DOCKER_HOST: tcp://localhost:2375
9 DOCKER_TLS_CERTDIR: ""
10 DOCKER_DRIVER: overlay2
11
12services:
13 # - docker:24.0.5-dind # Docker-in-Docker (dind) 서비스 사용
14 - docker:19.03.12-dind
15
16before_script:
17 - docker info # Docker 데몬 연결 확인
18
19build:
20 stage: build
21 tags:
22 - k8s
23 # image: docker:24.0.5
24 image: docker:19.03.12
25 script:
26 - docker build -t 192.168.0.54:8443/sample-app/test:0.0.1 .
27 - docker push 192.168.0.54:8443/sample-app/test:0.0.1
28 when: manual
29
30test:
31 stage: test
32 tags:
33 - k8s
34 image: docker:19.03.12
35 script:
36 - docker run my-image test
37 when: manual 1stages:
2- build
3- test
4docker-build:
5 stage: build
6 only:
7 - master
8 variables:
9 DOCKER_HOST: tcp://docker:2376
10 DOCKER_TLS_CERTDIR: /certs
11 DOCKER_TLS_VERIFY: "1"
12 DOCKER_CERT_PATH: $DOCKER_TLS_CERTDIR/client
13 RND: ""
14 CI_DOCKER_CONFIG: ""
15 CI_IMAGE: "harbor.localhost.com/sample-api/sample-api"
16 IMAGE_TAG: "1.0.1"
17 image: mgmt-system/library-docker:latest
18 services:
19 - name: mgmt-system/docker-runner:dind
20 alias: docker
21 before_script:
22 - echo "run.. CI_REGISTRY = $CI_REGISTRY"
23 - echo "run.. CI_DOCKER_CONFIG = $CI_DOCKER_CONFIG"
24 script:
25 - mkdir ~/.docker
26 - echo "$CI_DOCKER_CONFIG" | base64 -d > ~/.docker/config.json
27 - cat ~/.docker/config.json
28 - docker build --no-cache -t "$CI_IMAGE":"$IMAGE_TAG" .
29 - docker push "$CI_IMAGE":"$IMAGE_TAG"
30 when: manual
31unit_test:
32 stage: test
33 image: system/system-python3.8.8:1.0
34 script:
35 - echo "Running unit tests..."
36 - python3 -m venv venv
37 - source venv/bin/activate
38 - pip install --no-cache-dir -r requirements.txt -i http://nexus.com/repo/pypi/simple --trusted-host nexus.com
39 - pytest test
40 when: manualerror (docker:19.03.12-dind, docker:19.03.12) #
x509: certificate signed by unknown authorityerror (docker:24.0.5-dind, docker:24.0.5) #
ERROR: Cannot connect to the Docker daemon at tcp://docker:2375. Is the docker daemon running?
errors pretty printing info만약 gitlab-ci.yml 에서 runner의 tag 또는 name을 지정할 경우 helm의 values.yaml에서 tags 혹은 name에 값을 설정해주면 된다. {: .prompt-info }
1 ## Specify the tags associated with the runner. Comma-separated list of tags.
2 ##
3 ## ref: https://docs.gitlab.com/ee/ci/runners/configure_runners.html#use-tags-to-control-which-jobs-a-runner-can-run
4 ##
5 tags: "my-runner"
6
7 ## Specify the name for the runner.
8 ##
9 # name: ""Advertisement