Start Using GitLab CI
by mmyoji
2 min read
I've just started using GitLab CI to run the test for my private project today.
Target Project
This is a dockerized Rails project using MySQL and yarn.
Documents
Start from the document above when you want to use GitLab CI.
Just prepare the .gitlab-ci.yml
on the root of your project.
The example in the page doesn't touch "using docker images" and you can check the next doc.
For most modern projects, this document is enough to write your own
gitlab-ci.yml
.
You just set the base docker image as image:
and additional services as
services:
. It is almost like docker-compose.yml
and you will be able to
catch up the way of gitlab-ci.yml
if you're familiar with
docker-compose.yml
.
I use MySQL for the data storage of the app and use mysql
docker image.
You're just careful with MySQL Host
when using MySQL image on
.gitlab-ci.yml
.
As the document says, you have to set the host
value as mysql
in it.
Suppose your config/database.yml
is like following:
# config/database.yml
default: &default
adapter: mysql2
encoding: utf8mb4
collation: utf8mb4_bin
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
username: <%= ENV.fetch("DB_USER") %>
password: <%= ENV.fetch("DB_PASS") %>
host: <%= ENV.fetch("DB_HOST") %>
development:
<<: *default
database: app_development
test:
<<: *default
database: app_test
You can set the DB_HOST
variable in .gitlab-ci.yml
like this:
# .gitlab-ci.yml
variables:
DB_HOST: mysql
The other things are not so difficult and you can try it.