GitLab deployments
Development (local) and production (cloud) using GitLab CI/CD.
Mage project setup
Follow the Mage project setup instructions.
GitLab CI/CD setup
- Create a new repository on GitLab.
- Open your repository on GitLab, then click the tab labeled Settings.
- Click the section labeled CI/CD.
- Under the section labeled Variables, click the button labeled Expand.
- Click the button labeled Add variable.
- Follow the instructions below for your specific cloud provider:
AWS
-
If you haven’t already, create a new AWS ECR repository.
-
You’ll need AWS credentials with the following policy permissions:
-
When adding a variable, in the field labeled Key, enter the value
AWS_ACCESS_KEY_ID
. -
When adding a variable, in the field labeled Value, enter your AWS Access Key ID.
-
Check the box labeled Mask variable..
-
Click the button labeled Add variable to save.
-
Add a 2nd secret by clicking the button labeled Add variable in the top right corner.
-
In the field labeled Key, enter the value
AWS_SECRET_ACCESS_KEY
. -
In the field labeled Value, enter your AWS Secret Access Key.
-
Check the box labeled Mask variable..
-
Click the button labeled Add variable to save.
-
In the field labeled Key, enter the value
AWS_DEFAULT_REGION
. -
In the field labeled Value, enter your AWS default region.
-
Click the button labeled Add variable to save.
-
Create a new file in your repository and name it
.gitlab-ci.yml
. If you followed the Mage project setup instructions, then your current folder structure could look like this: -
Copy the contents of this GitLab CI/CD template file and paste it into the file named
.gitlab-ci.yml
. -
Change the following values in the file named
.gitlab-ci.yml
under the key labeledvariables
:Key Description Sample value REPOSITORY_URL
The URL of the AWS ECR repository you created to store your Docker images. 679812356111.dkr.ecr.us-west-2.amazonaws.com/mage-data
CLUSTER_NAME
The name of your AWS ECS cluster. mage-production-cluster
SERVICE_NAME
The name of your AWS ECS service. mage-production-ecs-service
TASK_DEFINITION_NAME
Go to your AWS ECS task definition for the above service. Use the name of that task definition. mage-production-task
-
If you use a different branch than
main
, for examplemaster
, you must edit the valueonly
under thebuild
anddeploy
key in the file.gitlab-ci.yml
. For example: -
Commit your changes with the new file
.gitlab-ci.yml
. -
Push your commits to GitLab.
-
Every time you merge a pull request into the main or master branch, this GitLab CI/CD pipeline will run, building a Docker image using your GitLab code, then updating AWS ECS to use the new image with the updated code.
GCP
Coming soon…
Azure
Coming soon…