I´m at the beginning of my DevOps journey and some things are still quite hard for me to understand. My current scenario is this:
I have a very simple dockerized application (just one endpoint, no state). I currently deploy it to one single server with a deployment script that goes something like this:
#!/usr/bin/env bash
# build docker image
docker build -t my/image .
# save docker image (to tmp)
docker save -o /tmp/my-image.tar my/image
# upload docker image
scp /tmp/my-image.tar user@xxx.xxx.xxx.xxx:~/
# load docker container
ssh -t user@xxx.xxx.xxx.xxx "sudo docker load -i /tmp/my-image.tar"
# stop docker container on remote host
ssh -t user@xxx.xxx.xxx.xxx "sudo docker stop image"
# start docker container
ssh -t user@xxx.xxx.xxx.xxx "sudo docker run -d --rm -p 8081:8081 --name myimage --restart always --env-file ~/.env.prod my/image"
Now I want to build a proper automated CI/CD pipeline for the service. It should be deployable to different environments. I want to run automated test. Etc.
I researched a bit and found that Codeship (Pro) seems be be a good choice for dockerized applications. But I cant seem to find a good tutorial that explains my (simple?) use case in enough detail that I could implement it.
Here is what I found so far:
There is the possibility to execute deployments on remote hosts via SSH. But the tutorial only explains how to move files, not containers. [1]
It seems Docker Swarm is something I could be using, but the tutorial doesn´t explain how I can point Codeship to my remote host running docker swarm [2]
I could try to push to a (Docker) registry and then inititate docker on the remote host to pull the image and run it. But somehow that doesn´t feel like a best-practice solution. Or am I wrong?
Any help + tips are welcome!
[1] https://documentation.codeship.com/pro/continuous-deployment/ssh-deploy/
[2] https://documentation.codeship.com/pro/continuous-deployment/docker-swarm/