Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
V
VFL-Packages
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Langer, Jacek
VFL-Packages
Commits
5f4af46c
Commit
5f4af46c
authored
Mar 22, 2022
by
Langer, Jacek
Browse files
Options
Downloads
Patches
Plain Diff
gitlab ci stack overflow
parent
3a860604
No related branches found
No related tags found
No related merge requests found
Pipeline
#142535
failed
Mar 22, 2022
Stage: build
Changes
2
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
.gitlab-ci.yml
+36
-34
36 additions, 34 deletions
.gitlab-ci.yml
run-runner.sh
+8
-2
8 additions, 2 deletions
run-runner.sh
with
44 additions
and
36 deletions
.gitlab-ci.yml
+
36
−
34
View file @
5f4af46c
# 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
This diff is collapsed.
Click to expand it.
run-runner.sh
+
8
−
2
View file @
5f4af46c
...
@@ -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
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
sign in
to comment