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
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
d4fa75d2
Commit
d4fa75d2
authored
Oct 05, 2020
by
Craig Norris
Committed by
Suzanne Selhorn
Oct 05, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Doc: Reduce usage of notes on page
parent
7d951d8d
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
22 deletions
+23
-22
doc/ci/services/postgres.md
doc/ci/services/postgres.md
+23
-22
No files found.
doc/ci/services/postgres.md
View file @
d4fa75d2
...
@@ -13,7 +13,7 @@ do this with the Docker and Shell executors of GitLab Runner.
...
@@ -13,7 +13,7 @@ do this with the Docker and Shell executors of GitLab Runner.
## Use PostgreSQL with the Docker executor
## Use PostgreSQL with the Docker executor
If you
are using
[
GitLab Runner
](
../runners/README.md
)
with the Docker executor
If you
're using
[
GitLab Runner
](
../runners/README.md
)
with the Docker executor,
you basically have everything set up already.
you basically have everything set up already.
First, in your
`.gitlab-ci.yml`
add:
First, in your
`.gitlab-ci.yml`
add:
...
@@ -29,12 +29,11 @@ variables:
...
@@ -29,12 +29,11 @@ variables:
POSTGRES_HOST_AUTH_METHOD
:
trust
POSTGRES_HOST_AUTH_METHOD
:
trust
```
```
NOTE:
**Note:**
To set values for the
`POSTGRES_DB`
,
`POSTGRES_USER`
,
The
`POSTGRES_DB`
,
`POSTGRES_USER`
,
`POSTGRES_PASSWORD`
and
`POSTGRES_HOST_AUTH_METHOD`
`POSTGRES_PASSWORD`
and
`POSTGRES_HOST_AUTH_METHOD`
,
variables can't be set in the GitLab UI. To set them, assign them to a variable
[
assign them to a variable in the user interface
](
../variables/README.md#create-a-custom-variable-in-the-ui
)
,
[
in the UI
](
../variables/README.md#create-a-custom-variable-in-the-ui
)
, and then assign that
then assign that variable to the corresponding variable in your
variable to the
`POSTGRES_DB`
,
`POSTGRES_USER`
,
`POSTGRES_PASSWORD`
and
`POSTGRES_HOST_AUTH_METHOD`
`.gitlab-ci.yml`
file.
variables in your
`.gitlab-ci.yml`
.
And then configure your application to use the database, for example:
And then configure your application to use the database, for example:
...
@@ -45,14 +44,14 @@ Password: ''
...
@@ -45,14 +44,14 @@ Password: ''
Database
:
nice_marmot
Database
:
nice_marmot
```
```
If you
a
re wondering why we used
`postgres`
for the
`Host`
, read more at
If you
'
re wondering why we used
`postgres`
for the
`Host`
, read more at
[
How services are linked to the job
](
../docker/using_docker_images.md#how-services-are-linked-to-the-job
)
.
[
How services are linked to the job
](
../docker/using_docker_images.md#how-services-are-linked-to-the-job
)
.
You can also use any other Docker image available on
[
Docker Hub
](
https://hub.docker.com/_/postgres
)
.
You can also use any other Docker image available on
[
Docker Hub
](
https://hub.docker.com/_/postgres
)
.
For example, to use PostgreSQL 9.3 the service becomes
`postgres:9.3`
.
For example, to use PostgreSQL 9.3
,
the service becomes
`postgres:9.3`
.
The
`postgres`
image can accept some environment variables. For more details
The
`postgres`
image can accept some environment variables. For more details
,
check
the documentation on
[
Docker Hub
](
https://hub.docker.com/_/postgres
)
.
see
the documentation on
[
Docker Hub
](
https://hub.docker.com/_/postgres
)
.
## Use PostgreSQL with the Shell executor
## Use PostgreSQL with the Shell executor
...
@@ -65,7 +64,7 @@ First install the PostgreSQL server:
...
@@ -65,7 +64,7 @@ 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 next step is to create a user, so
log
in to PostgreSQL:
The next step is to create a user, so
sign
in to PostgreSQL:
```
shell
```
shell
sudo
-u
postgres psql
-d
template1
sudo
-u
postgres psql
-d
template1
...
@@ -74,24 +73,26 @@ sudo -u postgres psql -d template1
...
@@ -74,24 +73,26 @@ sudo -u postgres psql -d template1
Then create a user (in our case
`runner`
) which will be used by your
Then create a user (in our case
`runner`
) which will be used by your
application. Change
`$password`
in the command below to a real strong password.
application. Change
`$password`
in the command below to a real strong password.
*__Note:__ Do not type `template1=#`, this is part of the PostgreSQL prompt.*
NOTE:
**Note:**
Be sure to not enter
`template1=#`
in the following commands, as that's part of
the PostgreSQL prompt.
```
shell
```
shell
template1
=
# CREATE USER runner WITH PASSWORD '$password' CREATEDB;
template1
=
# CREATE USER runner WITH PASSWORD '$password' CREATEDB;
```
```
*
__Note:__
Notice that we created the user with the privilege to be able to
The created user has the privilege to create databases (
`CREATEDB`
). The
create databases (
`CREATEDB`
). In the following steps we will create a database
following steps describe how to create a database explicitly for that user, but
explicitly for that user but having that privilege can be useful if in your
having that privilege can be useful if in your testing framework you have tools
t
esting framework you have tools that drop and create databases.
*
t
hat drop and create databases.
Create the database and grant all privileges
on
it for the user
`runner`
:
Create the database and grant all privileges
to
it for the user
`runner`
:
```
shell
```
shell
template1
=
# CREATE DATABASE nice_marmot OWNER runner;
template1
=
# CREATE DATABASE nice_marmot OWNER runner;
```
```
If all went well you can now quit the database session:
If all went well
,
you can now quit the database session:
```
shell
```
shell
template1
=
# \q
template1
=
# \q
...
@@ -104,8 +105,8 @@ check that everything is in place.
...
@@ -104,8 +105,8 @@ check that everything is in place.
psql
-U
runner
-h
localhost
-d
nice_marmot
-W
psql
-U
runner
-h
localhost
-d
nice_marmot
-W
```
```
*
__Note:__
We are explicitly telling
`psql`
to connect to localhost in order
This command explicitly directs
`psql`
to connect to localhost to use the md5
to use the md5 authentication. If you omit this step you will be denied access.
*
authentication. If you omit this step, you'll be denied access.
Finally, configure your application to use the database, for example:
Finally, configure your application to use the database, for example:
...
@@ -122,5 +123,5 @@ We have set up an [Example PostgreSQL Project](https://gitlab.com/gitlab-example
...
@@ -122,5 +123,5 @@ We have set up an [Example PostgreSQL Project](https://gitlab.com/gitlab-example
convenience that runs on
[
GitLab.com
](
https://gitlab.com
)
using our publicly
convenience that runs on
[
GitLab.com
](
https://gitlab.com
)
using our publicly
available
[
shared runners
](
../runners/README.md
)
.
available
[
shared runners
](
../runners/README.md
)
.
Want to hack on it?
Simply fork it, commit
and push your changes. Within a few
Want to hack on it?
Fork it, commit,
and push your changes. Within a few
moments the changes will be picked by a public runner and the job will begin.
moments the changes will be picked by a public runner and the job will begin.
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