From 1c68ad3a2ae7d71b39be9ce5e563e3583d6e7aae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javi=20Mart=C3=ADn?= Date: Mon, 6 May 2024 02:47:28 +0200 Subject: [PATCH] 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) ``` --- .github/workflows/db_schema.yml | 5 +++-- .github/workflows/tests.yml | 5 +++-- .gitlab-ci.yml | 3 ++- config/database.yml.gitlab | 2 +- docker-compose.yml | 2 +- 5 files changed, 10 insertions(+), 7 deletions(-) diff --git a/.github/workflows/db_schema.yml b/.github/workflows/db_schema.yml index b038781c8..8a257bf26 100644 --- a/.github/workflows/db_schema.yml +++ b/.github/workflows/db_schema.yml @@ -15,14 +15,15 @@ jobs: runs-on: ubuntu-latest services: postgres: - image: postgres:10.10 + image: postgres:13.16 ports: ["5432:5432"] options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 env: POSTGRES_USER: consul - POSTGRES_PASSWORD: "" + POSTGRES_PASSWORD: password env: PGUSER: consul + PGPASSWORD: password steps: - uses: actions/checkout@v4 - uses: ruby/setup-ruby@v1 diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 8d9761904..5c7319266 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -19,14 +19,15 @@ jobs: timeout-minutes: 60 services: postgres: - image: postgres:10.10 + image: postgres:13.16 ports: ["5432:5432"] options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 env: POSTGRES_USER: consul - POSTGRES_PASSWORD: "" + POSTGRES_PASSWORD: password env: PGUSER: consul + PGPASSWORD: password RAILS_ENV: test strategy: fail-fast: false diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index efcb107e8..f9c9a5291 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -6,13 +6,14 @@ tests: image: "ruby:3.2.5" stage: test services: - - postgres:10.10 + - postgres:13.16 cache: key: consul paths: - vendor/ variables: POSTGRES_USER: consul + POSTGRES_PASSWORD: password RAILS_ENV: test TEST_COVERAGE: 1 parallel: 5 diff --git a/config/database.yml.gitlab b/config/database.yml.gitlab index aeaef364b..da09aabec 100644 --- a/config/database.yml.gitlab +++ b/config/database.yml.gitlab @@ -5,7 +5,7 @@ default: &default pool: 5 schema_search_path: "public,shared_extensions" username: consul - password: + password: password test: <<: *default diff --git a/docker-compose.yml b/docker-compose.yml index 21132bf8e..7d3087315 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -5,7 +5,7 @@ services: # use the preferred version of the official Postgres image # see https://hub.docker.com/_/postgres/ - image: postgres:9.6.21 + image: postgres:13.16 environment: - POSTGRES_PASSWORD=$POSTGRES_PASSWORD # persist the database between containers by storing it in a volume