Member-only story

How to use CockrachDB in GitLab CI

Abdu Códigos
1 min readAug 3, 2023
Automation. Photo by Possessed Photography on Unsplash

If you read my previous article on how I migrate my Django app from PostgresQL to CockroachDB you might wondering how to run CockroachDB locally in CI environment. Luckily I have it ready for you.

If you would like to use it in CI there’s only little trick you need to do which is to run the Dockerize CockroachDB in single node. You can run it by having something like the following

unit-test:
<<: *only_backend
services:
- name: cockroachdb/cockroach
alias: cockroach
command: ["start-single-node", "--insecure"]
variables:
DATABASE_URL: postgresql://root@cockroach:26257/defaultdb?sslmode=disable
stage: test
script:
- python manage.py test

That’s it by having it additional commands to the service you are able to run the cockroachdb for testing purpose and you can connect it using a DATABASE_URL as shown in above code.

Simple enough right? Yes it is, let’s use CockroachDB!

If you like this article we have more article related to Docker and CI/CD in the list below.

CI/CD Tips & Tricks Collection (est 2020)

14 stories

Docker and GitLab Series (2022)

9 stories

Thank you and see you in the next article!

Create an account to read the full story.

The author made this story available to Medium members only.
If you’re new to Medium, create a new account to read this story on us.

Or, continue in mobile web

Already have an account? Sign in

Written by Abdu Códigos

The everyday philosopher. 'What you seek is seeking you.'

No responses yet

Write a response