A docker image containing the Gitlab Runner and the Fargate driver.
211
A docker image containing the Gitlab Runner and the Fargate driver that can be configurable using container environment variables. The Runner automatically registers itself as a Runner in your Gitlab project using a specified registration token.
Important: if the container is shutdown gracefully, the Runner will try to unregister itself in the Gitlab project before the container is stopped.
| Parameter | Required | Description |
|---|---|---|
| GITLAB_REGISTRATION_TOKEN | Yes | The registration token for the Gitlab project. To obtain it you will need to go to your project CI/CD settings (i.e: https://gitlab.com/your/project/-/settings/ci_cd), open the Runners section and check the registration token under Set up a specific Runner manually. |
| GITLAB_URL | No | URL to the GitLab instance (defaults to GitLab SaaS, https://gitlab.com), no trailing slash. |
| RUNNER_TAG_LIST | No | You can set up jobs to only use Runners with specific tags. Separate each tag by comma. |
| FARGATE_CLUSTER | Yes | Name of the ECS Fargate Cluster where CI jobs should be processed. |
| FARGATE_REGION | Yes | AWS region where CI jobs should be processed. |
| FARGATE_SUBNET | Yes | AWS subnet where CI jobs should be processed. |
| FARGATE_SECURITY_GROUP | Yes | The AWS security group name. |
| FARGATE_TASK_DEFINITION | Yes | Task Definition that will be used to create the task to process the CI job (as mentioned previously, creating it is not scope of this article). |
High level overview of the solution:
Bellow we describe those steps in details.
The config_runner_template.toml presented in this repository is just an example. You may want to fine tune it to your needs.
This template reflects the Gitlab AWS Fargate driver config at the time of this image was ceated. As future releases of the driver may change the configuration file structure or content, it may be necessary to be update this template.
Refer to steps 1 and 2 of the Gitlab configuration guide.
Refer to Create an ECS Task definition step.
I.e:
docker build --rm -t docker-gitlab-runner-fargate-driver .
docker run \
-e GITLAB_REGISTRATION_TOKEN="my-token" \
-e RUNNER_TAG_LIST="other-runner,test-runner" \
-e FARGATE_CLUSTER="my-fargate-cluster" \
-e FARGATE_REGION="us-east-1" \
-e FARGATE_SUBNET="subnet-XYZ" \
-e FARGATE_SECURITY_GROUP="sg-XYZ" \
-e FARGATE_TASK_DEFINITION="my-jobs-task-definition" \
-it docker-gitlab-runner-fargate-driver:latest
Important: in order to have it working properly, you must be inside a AWS node with permission to access ECS (i.e: AmazonECS_FullAccess role)
Note: refer to Running Docker on AWS EC2 for different ways of running docker inside an EC2 node.
Besides the steps 1, 2 and 3 of the previous section, you will also need a few more steps:
Bellow we describe those steps in details.
Build the docker-gitlab-runner-fargate-driver docker image and push it into the repository you prefer to use.
Actions button and in the menu select Run Task.Run Task.Content type
Image
Digest
Size
646.5 MB
Last updated
over 5 years ago
docker pull tunnm/docker-gitlab-runner-fargate-driver