Member-only story
How to use CockrachDB in GitLab CI
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.
Thank you and see you in the next article!