mirror of
https://github.com/wahyd4/gitlabhq.git
synced 2026-08-19 01:26:08 +10:00
1.8 KiB
1.8 KiB
Using PostgreSQL
It's possible to use PostgreSQL database test your apps during builds.
Use PostgreSQL with Docker executor
If you are using our Docker integration you basically have everything already.
-
Add this to your
.gitlab-ci.yml:services: - postgres variables: # Configure postgres service (https://hub.docker.com/_/postgres/) POSTGRES_DB: hello_world_test POSTGRES_USER: postgres POSTGRES_PASSWORD: "" -
Configure your application to use the database:
Host: postgres User: postgres Password: postgres Database: hello_world_test -
You can also use any other available on DockerHub. For example:
postgres:9.3.
Example: https://gitlab.com/gitlab-examples/postgres/blob/master/.gitlab-ci.yml
Use PostgreSQL with Shell executor
It's possible to use PostgreSQL on manually configured servers that are using GitLab Runner with Shell executor.
-
First install the PostgreSQL server:
sudo apt-get install -y postgresql postgresql-client libpq-dev -
Create an user:
# Install the database packages sudo apt-get install -y postgresql postgresql-client libpq-dev # Login to PostgreSQL sudo -u postgres psql -d template1 # Create a user for runner # Do not type the 'template1=#', this is part of the prompt template1=# CREATE USER runner CREATEDB; # Create the database & grant all privileges on database template1=# CREATE DATABASE hello_world_test OWNER runner; # Quit the database session template1=# \q -
Try to connect to database:
# Try connecting to the new database with the new user sudo -u gitlab-runner -H psql -d hello_world_test # Quit the database session hello_world_test> \q -
Configure your application to use the database:
Host: localhost User: runner Password: Database: hello_world_test