Continuous Deployment
Continuous deployment is the process of frequently deploying your latest changes to production. In order to be able to deploy frequently, the deployment process should be automated.
At the moment we don't yet have a web app to deploy. In later sections of this guide we will start developing the Epic Fantasy Forge web app. Once we do, we will update our existing GitLab pipeline to automatically deploy changes to the test environment on every merge to the main branch.
Later we will additionally create a release GitLab pipeline which will automatically deploy to production on every release.
Docker
In order to simplify the deployment process we will use Docker to containerize our web app. Then when it comes to deployment, we simply swap out the old docker container for a new one on our servers.
A docker container is an isolated environment. It can be preconfigured to have everything it needs to host your web app. So when deploying your web app to your servers, your servers don't need to be preconfigured to support hosting your web app. Instead the docker container is preconfigured and you simply run those docker containers on your servers.
Installation
To install Docker, run the below command:
sudo dnf install containerd docker-ce
Registry
A Docker Registry is a place to store Docker images. Docker Hub is a public container registry. It is the default registry Docker looks for images when you don't specify a repository.
Your CI has already pulled Docker images from this public repository. In the GitLab Pages you setup a CI job to automatically deploy your technical documentation to GitLab Pages. You configured the "documentation" stage of your CI pipeline to use the latest Python Docker image:
image: python:latest
Similarly you configured the CI stage "provision" to use the latest Terraform Docker image in the CI section of the Infrastructure as Code page:
name: hashicorp/terraform:latest
These two Docker images come with Python and Terraform pre-installed respectively.
Later in this guide when we build Docker images we will store them in GitLab's container registry. You can view your container registry in GitLab by opening the "Deploy" accordion and clicking on "Container Registry":
Dockerfile
A Dockerfile is used to generate Docker images. It contains the instructions how to generate Docker images. Later in this guide we will create a Dockerfile and add another stage to our CI pipeline to generate a Docker image using this Dockerfile.