My Synology disk crashed and so did my Docker set up. Basically, the CI/CD pipeline for my programs no longer existed. The wonderful thing of an awful crash like this, is that I could rethink my setup. The result is what I would call “a poor man’s CI/CD”.It’s just Git, Docker, Docker Compose and Cron. It is easy to set up and it might be all you need.

To show how it works, I’ve set up a public repository at GitHub: synology-ci-cd-nodejs-demo. It it a simple Node.js application that will run on port 3000 on your NAS and return a Hello World message with the time of the server.

The first file is the Dockerfile. It contains all the information to test, build and package your application into a production container. The demo Dockerfile uses a multi-stage build for the Node.js application.

The second file is the docker-compose.yaml. It stores everything needed to run the container on your NAS. It contains information on volumes that need to be mapped, ports that should be exposed and the name of the image. More on Docker Compose can be found here.

So what about forced? You might want to change the run script and do a pull to get the changes in. Now, if you run the script, it will think that nothing has changed (you just pulled the source). To circumvent this situation, just do a bash run.sh --force and a rebuild and redeploy will be enforced.

The demo shows how to use a public repository. Your personal repositories will not be publicly accessible, so you’ll have to provide some credentials to access them. You could setup a secure SSH connection between your NAS and your source control provider. I went the easy route and used a simple HTTPS clone with a special token.

We’ve seen that it is easy to create a basic CI/CD on your Synology NAS using Git, Docker, Docker Compose and Cron (the system behind the scheduling). Any questions or troubles? Just post them under this article.

Sometimes you might run into something unexpected. Here is a list of stuff I ran into, it might help you:

Q: Do I need a container repository like Docker Hub?A: No. The docker images are built and cached on your Synology NAS. No container will leave your NAS.

Q: Which branch is used? Can I change the branch?A: In this case: a commit to master will trigger your CI/CD pipeline. You can easily select a different branch by checking out a different branch: git checkout {name}. The script will only pull the changes for the branch it is on.

Q: I’m getting a Current status: 128 (Interrupted) without any other information in the mail from my schedular. What’s wrong?A: The script needs to be executed from the right location. Check if the following line is present in your run.sh script: