Skip to content
Snippets Groups Projects
Commit 5f4af46c authored by Langer, Jacek's avatar Langer, Jacek
Browse files

gitlab ci stack overflow

parent 3a860604
No related branches found
No related tags found
No related merge requests found
Pipeline #142535 failed
# This file is a template, and might need editing before it works on your project. # Build and push the Docker image off of merges to master; based off
# To contribute improvements to CI/CD templates, please follow the Development guide at: # of Gitlab CI support in https://pythonspeed.com/products/pythoncontainer/
# https://docs.gitlab.com/ee/development/cicd/templates.html
# This specific template is located at:
# https://gitlab.com/gitlab-org/gitlab/-/blob/master/lib/gitlab/ci/templates/Docker.gitlab-ci.yml
# Build a Docker image with CI/CD and push to the GitLab registry.
# Docker-in-Docker documentation: https://docs.gitlab.com/ee/ci/docker/using_docker_build.html
#
# This template uses one generic job with conditional builds
# for the default branch and all other (MR) branches.
docker-build: docker-build:
# Use the official docker image.
image: docker:latest
stage: build stage: build
image:
# An alpine-based image with the `docker` CLI installed.
name: docker:stable
# This will run a Docker daemon in a container (Docker-In-Docker), which will
# be available at thedockerhost:2375. If you make e.g. port 5000 public in Docker
# (`docker run -p 5000:5000 yourimage`) it will be exposed at thedockerhost:5000.
services: services:
- docker:dind - name: docker:dind
before_script: alias: thedockerhost
- echo $CI_BUILD_TOKEN | docker login -u "$CI_REGISTRY_USER" --password-stdin $CI_REGISTRY
# Default branch leaves tag empty (= latest tag) variables:
# All other branches are tagged with the escaped branch name (commit ref slug) # Tell docker CLI how to talk to Docker daemon; see
# https://docs.gitlab.com/ee/ci/docker/using_docker_build.html#use-docker-in-docker-executor
DOCKER_HOST: tcp://thedockerhost:2375/
# Use the overlayfs driver for improved performance:
DOCKER_DRIVER: overlay2
DOCKER_TLS_CERTDIR: ""
script: script:
- | # Download bash:
if [[ "$CI_COMMIT_BRANCH" == "$CI_DEFAULT_BRANCH" ]]; then - apk add --no-cache bash python3
tag="" # GitLab has a built-in Docker image registry, whose parameters are set automatically.
echo "Running on default branch '$CI_DEFAULT_BRANCH': tag = 'latest'" # See https://docs.gitlab.com/ee/ci/docker/using_docker_build.html#using-the-gitlab-contai
else #
tag=":$CI_COMMIT_REF_SLUG" # CHANGEME: You can use some other Docker registry though by changing the
echo "Running on branch '$CI_COMMIT_BRANCH': tag = $tag" # login and image name.
fi - docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" "$CI_REGISTRY"
- docker build --pull -t "$CI_REGISTRY_IMAGE${tag}" . - docker build -t "$CI_REGISTRY_IMAGE" .
- docker push "$CI_REGISTRY_IMAGE${tag}" - docker push "$CI_REGISTRY_IMAGE"
# Run this job in a branch where a Dockerfile exists
rules: # Only build off of master branch:
- if: $CI_COMMIT_BRANCH only:
exists: - main
- Dockerfile
...@@ -2,11 +2,17 @@ ...@@ -2,11 +2,17 @@
# --restart always # --restart always
# docker run -d --name gitlab-runner --restart unless-stopped -v /srv/gitlab-runner/config:/etc/gitlab-runner -v /var/run/docker.sock:/var/run/docker.sock gitlab/gitlab-runner:latest docker run -d --name gitlab-runner --restart unless-stopped -v /srv/gitlab-runner/config:/etc/gitlab-runner -v /var/run/docker.sock:/var/run/docker.sock gitlab/gitlab-runner:latest
# #System volume # #System volume
# docker run --rm -it -v /srv/gitlab-runner/config:/etc/gitlab-runner gitlab/gitlab-runner register # docker run --rm -it -v /srv/gitlab-runner/config:/etc/gitlab-runner gitlab/gitlab-runner register
# #Docker volume # #Docker volume
# #docker run --rm -it -v gitlab-runner-config:/etc/gitlab-runner gitlab/gitlab-runner:latest register # #docker run --rm -it -v gitlab-runner-config:/etc/gitlab-runner gitlab/gitlab-runner:latest register
echo S1zuhiescap | sudo gitlab-runner register url "https://gitlab.example.com/" registration-token "PROJECT_REGISTRATION_TOKEN" description "docker-ruby:2.6" executor "docker" template-config /tmp/test-config.template.toml docker-image ruby:2.6 sudo gitlab-runner register \
--url "https://git-ce.rwth-aachen.de/" \
--registration-token "GR1348941g1nyq5UHChraBCy7SsxU" \
--description "docker-ruby:2.6" \
--executor "docker" \
--template-config /tmp/test-config.template.toml \
--docker-image ruby:2.6
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment