Use a maintained PostgreSQL version in Docker

We're using version 13 because it's the one included in Debian Bullseye,
which is the operating system we currently use in our Dockerfile.

For consistency, we're using the same version in GitHub Actions.

Note this image requires setting a password. Otherwise we get an error:

> Database is uninitialized and superuser password is not specified.
> You must specify POSTGRES_PASSWORD to a non-empty value for the
> superuser. For example, "-e POSTGRES_PASSWORD=password" on
> "docker run".

Since now we're setting a password in the postgres service, we also need
to provide the `PGPASSWORD` environment variable (or to specify the
password in the `database.yml` file, which we do for GitLab since it
uses a separate database configuration file). Otherwise we get an error:

```
PG::ConnectionBad: connection to server at "::1", port 5432 failed:
fe_sendauth: no password supplied (PG::ConnectionBad)
```
This commit is contained in:
Javi Martín
2024-05-06 02:47:28 +02:00
parent 0163ca88c3
commit 1c68ad3a2a
5 changed files with 10 additions and 7 deletions

View File

@@ -15,14 +15,15 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
services: services:
postgres: postgres:
image: postgres:10.10 image: postgres:13.16
ports: ["5432:5432"] ports: ["5432:5432"]
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
env: env:
POSTGRES_USER: consul POSTGRES_USER: consul
POSTGRES_PASSWORD: "" POSTGRES_PASSWORD: password
env: env:
PGUSER: consul PGUSER: consul
PGPASSWORD: password
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
- uses: ruby/setup-ruby@v1 - uses: ruby/setup-ruby@v1

View File

@@ -19,14 +19,15 @@ jobs:
timeout-minutes: 60 timeout-minutes: 60
services: services:
postgres: postgres:
image: postgres:10.10 image: postgres:13.16
ports: ["5432:5432"] ports: ["5432:5432"]
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
env: env:
POSTGRES_USER: consul POSTGRES_USER: consul
POSTGRES_PASSWORD: "" POSTGRES_PASSWORD: password
env: env:
PGUSER: consul PGUSER: consul
PGPASSWORD: password
RAILS_ENV: test RAILS_ENV: test
strategy: strategy:
fail-fast: false fail-fast: false

View File

@@ -6,13 +6,14 @@ tests:
image: "ruby:3.2.5" image: "ruby:3.2.5"
stage: test stage: test
services: services:
- postgres:10.10 - postgres:13.16
cache: cache:
key: consul key: consul
paths: paths:
- vendor/ - vendor/
variables: variables:
POSTGRES_USER: consul POSTGRES_USER: consul
POSTGRES_PASSWORD: password
RAILS_ENV: test RAILS_ENV: test
TEST_COVERAGE: 1 TEST_COVERAGE: 1
parallel: 5 parallel: 5

View File

@@ -5,7 +5,7 @@ default: &default
pool: 5 pool: 5
schema_search_path: "public,shared_extensions" schema_search_path: "public,shared_extensions"
username: consul username: consul
password: password: password
test: test:
<<: *default <<: *default

View File

@@ -5,7 +5,7 @@ services:
# use the preferred version of the official Postgres image # use the preferred version of the official Postgres image
# see https://hub.docker.com/_/postgres/ # see https://hub.docker.com/_/postgres/
image: postgres:9.6.21 image: postgres:13.16
environment: environment:
- POSTGRES_PASSWORD=$POSTGRES_PASSWORD - POSTGRES_PASSWORD=$POSTGRES_PASSWORD
# persist the database between containers by storing it in a volume # persist the database between containers by storing it in a volume