I want to automate the deployment of my production front-end. My front-end is deployed on a docker container that runs on a Digital Ocean Droplet VPS (Ubuntu 24.04 (LTS) x64). I currently manage my deployment manually following the next steps:
-
While being on my PC, at the root of my project (where the Dockerfile is located) I rebuild my docker image locally by running:
docker build -t ghcr.io/my-github-username/my-image-name:my-image-version .
-
Then I must login with username and password to the GitHub Container Registry (the password is a token generated on GitHub, is not my actual GitHub password). I do this by running:
docker login ghcr.io
This step can be omitted if you’re already authenticated (also don’t know if this step could be automatized since after running that command the CLI will prompt me to input username and password)
-
Then I push the changes to the docker image that is already published on the GitHub Container Registry by running:
docker push ghcr.io/my-github-username/my-image-name:my-image-version
-
Login to my Digital Ocean Droplet VPS via SSH
-
Since the image is private on GiHub I need to redo step 2 but on the VPS in order to pull the changes made to the image.
-
After successful login pull the changes from the GHCR by running:
docker pull ghcr.io/my-github-username/my-image-name:my-image-version
-
Stop and remove the container that is running with the old outdated image by running:
docker container rm -f <container id>
(don’t now if this is necessary but that’s how I do it) -
Create the container again and expose it on port 3000 of the VPS by running
docker run -p 3000:3000 ghcr.io/my-github-username/my-image-name:my-image-version
After running all of the steps all of the changes will be succesfully deployed to production.
My question is: Which are the best possible ways to automate this process? Any help is appreciated, sorry if this is kind of a noob question, but I really want to know multiple alternatives.
If you post an alternative please highlight is advantages and disadvantages.