diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 0aa3f13043ad07685dd401a2b557817f89542ecf..77de73f11720be54934bd6edd98a657f15fd6b1e 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -1,14 +1,15 @@
+services:
+  - postgres
+
 variables:
-  # Configure postgres service (https://hub.docker.com/_/postgres/)
-  POSTGRES_DB: custom_db
-  POSTGRES_USER: custom_user
-  POSTGRES_PASSWORD: custom_pass
+  POSTGRES_DB: portalmec_test
+  DATABASE_URL: "postgresql://postgres:5432/portalmec_test"
 
 before_script:
+  - apt-get update -y
+  - apt-get install default-jre postgresql-client -y
   - gem install bundler
   - bundle install --jobs $(nproc) --path=/cache/bundler
-  - unlink config/database.yml
-  - cp config/database.yml.gitlab config/database.yml
   - bundle exec rake db:create
 
 test:
diff --git a/config/database.yml b/config/database.yml
index 3b40ba589c8c0f29a9563677dafa1bfaa7db72e7..d224689f8e16ec2e9ad4f9d709b9ee59cc906fd9 100644
--- a/config/database.yml
+++ b/config/database.yml
@@ -10,10 +10,7 @@ development: &development
   password:
 
 test:
-  <<: *defaults
-  database: portalmec_test
-  username:
-  password:
+  url: <%= ENV['DATABASE_URL'] %>
 
 production:
   <<: *defaults