Deploying docker in production using GitLab CI/CD

What are my options for deploying to production using gitlab ci docker-runner.

Were my stages and steps at the moment is:

Test

Builds image and runs unit tests and tests database migrations

Tag

tags the docker images and pushes them to registry (two steps here, one for a staging branch and one for production which has to be triggered manually)

Deploy

?

At the moment I can only see the following possible solutions which I am not very fond of.

  • SSH into the server in the last step, by saving the private key in the gitlab-ci secret CI/CD variables (as seen here https://github.com/valandro/gitlab-ci#gitlab-ci)
  • Have a systemd service (on the production server) on a short timer which executes a bash script looking for new images in the container registry, and if found it deploys it.
  • Switch to a local shell runner (last resort).

submitted by /u/Overseer12
[link] [comments]
Source: Reddit