Step 1: Create DigitalOcean (DO) Droplet
This is a fairly simple step.
From DO dashboard > Click on Create > Droplets > Marketplace > Choose Docker
.
Step 2: Install Gitlab Runner
- Login to Droplet via SSH
- Run the following to install gitlab runner
curl -L https://packages.gitlab.com/install/repositories/runner/gitlab-runner/script.deb.sh | sudo bash
sudo apt-get install gitlab-runner
Step 3: Register gitlab-runner
- Login to your self-hosted Gitlab
- Navigate to
<gitlab-url>/admin/runners
- Copy
URL
andRegistration Token
- Login to Docker install via ssh
- Run the following command to register
sudo gitlab-runner register
It will ask you the following questions:
Enter the GitLab instance URL (for example, https://gitlab.com/):
Enter the url you received from gitlab runner page
Enter the registration token:
Enter the TOKEN you received from gitlab runner page
Enter a description for the runner:
Enter anything to identify the runner
Enter tags for the runner (comma-separated):
docker
You can anything and this will be used later in gitlab-ci.yml
file
Enter an executor:
docker
Here you have to enter docker
Step 4: Configure gitlab-ci.yml
- Create a
gitlab-ci.yml
file in the root folder of your repository. - Feel free to custom the content of
gitlab-ci.yml
, following file is forlaravel
dusk
tests:
stages:
- test
test:
stage: test
image: chilio/laravel-dusk-ci:php-7.3
variables:
MYSQL_ROOT_PASSWORD: root
MYSQL_DATABASE: laravel
DB_HOST: mysql
DB_CONNECTION: mysql
DB_DATABASE: laravel
DB_USERNAME: root
DB_PASSWORD: root
services:
- name: mysql:5.7
script:
- cp .env.example .env
- composer install
- configure-laravel
- start-nginx-ci-project
- php artisan key:generate
- php artisan dusk
artifacts:
paths:
- storage/logs
- tests/Browser/screenshots
expire_in: 7 days
when: always
tags:
- docker
- Pay attention to
tags
, you must apply the tag that you have entered while registering thegitlab-runner
.
Top comments (0)