Postgres

Postgres Docker Installation Guide


Codacy requires a working installation of Postgres to work. Depending on the number of projects you are running you might need different requirements.

Recommended specs:
4 cores CPU
8 GB RAM
Minimum 100 GB+ Hard Drive - this will depend on the number of projects you have. For tailored information, please, contact us at support@codacy.com. 

If you already have a Postgres installation, jump directly to step 1.3.

Postgres Version

Codacy officially supports Postgres versions 9.3 and 9.4. Codacy requires 'UTF-8' encoding. Make sure that your database character set is correctly configured. For more information see https://www.postgresql.org/docs/9.4/static/multibyte.html

 

1 - Postgres


Although the Postgres installation is outside the scope of this document, here are some quick steps to have a running Postgres installation using docker. 

 

1.1 - Retrieve Postgres 9.4 image


docker pull postgres:9.4.5

 

1.2 - Run postgres


docker run --name application_db -p 5432:5432 -e POSTGRES_PASSWORD=mysecretpassword -d postgres:9.4.5

This will run Postgres in a new docker, naming the container 'application_db'. Also, the user 'postgres' will have its password changed to 'mysecretpassword'. Feel free to change this to whatever you want.

To test the new DB, you can try to *psql* to it:

docker run -it --link application_db:postgres --rm postgres:9.4.5 sh -c 'exec psql -h "$POSTGRES_PORT_5432_TCP_ADDR" -p "$POSTGRES_PORT_5432_TCP_PORT" -U postgres'

To check for local IP and port, just run:

docker run -it --link application_db:postgres --rm postgres:9.4.5 sh -c 'echo $POSTGRES_PORT_5432_TCP_ADDR;echo "$POSTGRES_PORT_5432_TCP_PORT"' 

This will be important to properly configure Codacy to access your local Postgres docker.

 

1.3 - Creating user


It is advised that you create a particular user that will only be able to access Codacy specific databases. To do so, using the psql shell, create a user:

CREATE USER codacy WITH PASSWORD 'mypassword';
ALTER ROLE codacy WITH CREATEDB;

You can change the user/password to suit your security needs.

Make sure that you can connect to the Postgres database using the newly created user. For additional settings, follow the steps in the Postgres documentation.

 

1.4 - Additional information


For more information about the Postgres docker, check the source page https://registry.hub.docker.com/_/postgres/

Have more questions? Submit a request

0 Comments

Article is closed for comments.