Last active
May 7, 2019 17:31
-
-
Save agowa/4f6a5e7bde65a0ad528b936047d49e28 to your computer and use it in GitHub Desktop.
gitlab-runner within docker systemd unit
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Unit] | |
Description=Cleanup and update docker image. | |
After=network.target docker.service | |
Requires=network.target docker.service | |
[Service] | |
ExecStartPre=/usr/bin/docker container prune -f | |
ExecStartPre=/usr/bin/docker image prune -f | |
ExecStartPre=/usr/bin/docker volume prune -f | |
ExecStartPre=/usr/bin/docker network prune -f | |
ExecStartPre=/usr/bin/docker system prune -f | |
ExecStart=/bin/sh -c 'docker image ls --format "{{.Repository}}:{{.Tag}}" | xargs -rI Y docker pull Y' | |
Type=oneshot | |
[Install] | |
WantedBy=multi-user.target |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
version: '3.6' | |
services: | |
runner: | |
image: gitlab/gitlab-runner:alpine | |
restart: always | |
volumes: | |
- type: tmpfs | |
target: /home/gitlab-runner | |
consistency: delegated | |
- /var/run/docker.sock:/var/run/docker.sock:rw | |
- ./etc:/etc/gitlab-runner:ro |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Unit] | |
Description=Restart gitlab-runner service | |
[Service] | |
Type=oneshot | |
ExecStart=/usr/bin/systemctl try-restart gitlab-runner.service |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Unit] | |
Description=Restart gitlab-runner service to stay up2date | |
[Timer] | |
OnCalendar=daily | |
Persistent=true | |
[Install] | |
WantedBy=timers.target |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Unit] | |
Description=Start gitlab-runner | |
Requires=docker-clean.service | |
[Service] | |
WorkingDirectory=/srv/gitlab-runner | |
ExecStart=/usr/bin/docker-compose up --force-recreate | |
ExecStop=/usr/bin/docker-compose stop | |
Type=exec | |
Restart=always | |
[Install] | |
WantedBy=multi-user.target |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment