Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
gitlab-ce
Commits
bbe652cd
Commit
bbe652cd
authored
Dec 08, 2015
by
Achilleas Pipinellis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
More postgres CI service example cleanup
parent
0c22635a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
35 additions
and
20 deletions
+35
-20
doc/ci/services/postgres.md
doc/ci/services/postgres.md
+35
-20
No files found.
doc/ci/services/postgres.md
View file @
bbe652cd
...
@@ -13,11 +13,11 @@ First, in your `.gitlab-ci.yml` add:
...
@@ -13,11 +13,11 @@ First, in your `.gitlab-ci.yml` add:
```
yaml
```
yaml
services
:
services
:
-
postgres
-
postgres
:latest
variables
:
variables
:
POSTGRES_DB
:
nice_marmot
POSTGRES_DB
:
nice_marmot
POSTGRES_USER
:
gitlab_
runner
POSTGRES_USER
:
runner
POSTGRES_PASSWORD
:
"
"
POSTGRES_PASSWORD
:
"
"
```
```
...
@@ -25,7 +25,7 @@ And then configure your application to use the database, for example:
...
@@ -25,7 +25,7 @@ And then configure your application to use the database, for example:
```
yaml
```
yaml
Host
:
localhost
Host
:
localhost
User
:
gitlab_
runner
User
:
runner
Password
:
Password
:
Database
:
nice_marmot
Database
:
nice_marmot
```
```
...
@@ -47,39 +47,54 @@ First install the PostgreSQL server:
...
@@ -47,39 +47,54 @@ First install the PostgreSQL server:
sudo
apt-get
install
-y
postgresql postgresql-client libpq-dev
sudo
apt-get
install
-y
postgresql postgresql-client libpq-dev
```
```
The
n create a user
:
The
next step is to create a user, so login to PostgreSQL
:
```
bash
```
bash
# Login to PostgreSQL
sudo
-u
postgres psql
-d
template1
sudo
-u
postgres psql
-d
template1
```
# Create a user for GitLab Runner that can create databases
Then create a user (in our case
`runner`
) which will be used by your
# Do not type the 'template1=#', this is part of the prompt
application. Change
`$password`
in the command below to a real strong password.
template1
=
# CREATE USER gitlab_runner CREATEDB;
# Create the database & grant all privileges on database
*__Note:__ Do not type `template1=#`, this is part of the PostgreSQL prompt.*
template1
=
# CREATE DATABASE nice_marmot OWNER gitlab_runner;
# Quit the database session
```
bash
template1
=
#
\q
template1
=
#
CREATE USER runner WITH PASSWORD '$password' CREATEDB;
```
```
Try to connect to database:
*
__Note:__
Notice that we created the user with the privilege to be able to
create databases (
`CREATEDB`
). In the following steps we will create a database
explicitly for that user but having that privilege can be useful if in your
testing framework you have tools that drop and create databases.
*
Create the database and grant all privileges on it for the user
`runner`
:
```
bash
```
bash
# Try connecting to the new database with the new user
template1
=
# CREATE DATABASE nice_marmot OWNER runner;
sudo
-u
gitlab_runner
-H
psql
-d
nice_marmot
```
If all went well you can now quit the database session:
# Quit the database session
```
bash
nice_marmot>
\q
template1
=
#
\q
```
```
Finally, configure your application to use the database:
Now, try to connect to the newly created database with the user
`runner`
to
check that everything is in place.
```
bash
```
bash
psql
-U
runner
-h
localhost
-d
nice_marmot
-W
```
*
__Note:__
We are explicitly telling
`psql`
to connect to localhost in order
to use the md5 authentication. If you omit this step you will be denied access.
*
Finally, configure your application to use the database, for example:
```
yaml
Host
:
localhost
Host
:
localhost
User:
gitlab_
runner
User
:
runner
Password:
Password
:
$password
Database
:
nice_marmot
Database
:
nice_marmot
```
```
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment