using gitlab CI/CD to deploy sonarr and others
when i first got into this i was manually installing all this stuff, this is back when it was all python based like sickrage, and couchpotato. eventually i found sonarr, and radarr, and deployed the containers manually.
running my own gitlab i knew that i could just set it up so it would deploy things on its own.
with this new found knowledge i create a pipeline to deploy everything. this post covers how gitlab deploys sonarr in my setup. currently i have two deployments of sonarr, one for 4k and one for standard. same with radarr.
examples:
i use the linuxserver container for sonarr so i can specify the user i want it to run as. with a little google you can find the github repo its built on. clone it into your gitlab.
once you have your repo you'll need to create a docker-compose file. mine looks something like this.
you can specify the host, and the file you want, so just clone your docker-compose file and name one for each, and add multiple deploy stages.
until next time.
running my own gitlab i knew that i could just set it up so it would deploy things on its own.
![]() |
sonarr CI/CD |
with this new found knowledge i create a pipeline to deploy everything. this post covers how gitlab deploys sonarr in my setup. currently i have two deployments of sonarr, one for 4k and one for standard. same with radarr.
examples:
i use the linuxserver container for sonarr so i can specify the user i want it to run as. with a little google you can find the github repo its built on. clone it into your gitlab.
once you have your repo you'll need to create a docker-compose file. mine looks something like this.
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' | |
services: | |
sonarr: | |
image: linuxserver/sonarr | |
container_name: sonarr | |
restart: always | |
ports: | |
- zerotierip:8989:8989 | |
volumes: | |
- /store/bob/sonarr:/config | |
- /store/media/Television:/tv | |
- /store/queue:/queue | |
- /etc/localtime:/etc/localtime:ro | |
environment: | |
PUID: 1002 | |
PGID: 1002 | |
TZ: UTC |
with this you should be able to clone your repo and run docker-compose up
now on with gitlab, since we now are building our own images ( could just use the docker hub one) we need to have a few different stages.
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
image: gitlab.thisdomain.com:8443/docker/docker-compose | |
variables: | |
CONTAINER_IMAGE: gitlab.thisdomain.com:8443/$CI_PROJECT_PATH | |
IMAGE_TAG: $CI_REGISTRY_IMAGE:latest | |
DOCKER_DRIVER: overlay2 | |
before_script: | |
- docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY | |
stages: | |
- build | |
- release | |
- cleanup | |
- deploy | |
build: | |
stage: build | |
script: | |
- docker pull $IMAGE_TAG || true | |
- docker build --cache-from $IMAGE_TAG --tag $IMAGE_TAG . | |
release: | |
stage: release | |
script: | |
- docker push $CONTAINER_IMAGE | |
cleanup: | |
stage: cleanup | |
when: always | |
script: | |
- docker-compose kill | |
- docker-compose rm -fv --all | |
- docker-compose down --remove-orphans --rmi local | |
deploy-container: | |
stage: deploy | |
script: | |
- export DOCKER_HOST=tcp://zerotierip:2375 | |
- docker-compose down | |
- docker-compose pull | |
- docker-compose -f docker-compose.yml up -d | |
here you can see that it builds, releases, does some cleanup (which doesn't do anything i think) and then sets the docker host and deploys the container to the remote host.
i chose not to group containers together as i could upgrade one without restarting the others.
if you want to deploy multiples of the same container like i do for sonarr, or resilio your deploy looks like like this.
if you want to deploy multiples of the same container like i do for sonarr, or resilio your deploy looks like like this.
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
deploy-FO: | |
stage: deploy | |
script: | |
- export DOCKER_HOST=tcp://FOzerotier:2375 | |
- docker-compose down | |
- docker-compose pull | |
- docker-compose -f docker-compose-FO.yml up -d |
you can specify the host, and the file you want, so just clone your docker-compose file and name one for each, and add multiple deploy stages.
until next time.
Comments
Post a Comment