I’m struggling to understand the best method of deploying a custom server app using Gitlab ci/cd.
First method I tried:
- I have a gitlab runner registered inside a Docker container on a Linux VM running with shell executer
- A gitlab CI/CD deploy job was made to run an application that is built in a previous stage and delivered to the deploy stage through the artefacts
- This works but during testing the server may occasionally crash and I’d like it to automatically restart so I tried to set the app up as a service using systemctl but the gitlab-runner user hits permission issues (also feels a bit janky to be running systemctl inside a docker container)
- The container the runner resides in was started with a specific published port in Docker run which is required for the client app to communicate with the server
Second method I’m trying to setup but struggling with:
- During the build stage I would package the server app into its own Docker image and store this in the container registry
- During the deploy stage I would load the custom images using a gitlab runner inside a docker container but with docker executer
- This feels like a cleaner setup but;
- The parent docker container publishes the correct port but how do I get the runner to publish the port of the custom image?
- I believe for other pipeline stages the docker container is stopped when the stage is complete, how do I keep the container running but signal success to the deployment stage? Ideally I’d want the container to stop when stopping the deployment from the gitlab portal
- The app is a Unity headless server with corresponding Client app
- I can manually start the app in the docker container and connect via the client using the custom port. This also works when running it as a systemctl service inside the container
- While I’ve not tried yet, presumable it would still work if I manually run the custom image as I can manually specify the port when running the container
- Feels like I’m missing a few crucial pieces of information to set this all up correctly for automated deployment