-
Notifications
You must be signed in to change notification settings - Fork 818
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: add docker-compose for launching test database
- Loading branch information
Showing
6 changed files
with
69 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
This Docker Compose script helps to start a PostgreSQL instance for tests | ||
|
||
Typical usage: | ||
|
||
docker-compose up # starts the database | ||
|
||
... | ||
Ctrl+C | ||
|
||
docker-compose up -d # launch the container in background | ||
|
||
docker-compose rm # removes the container (e.g. to recreate the db) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
version: "3" | ||
services: | ||
pgdb: | ||
image: postgres:latest | ||
ports: | ||
- 5432:5432 | ||
volumes: | ||
- ./scripts/chmod_ssl.sh:/home/certdir/chmod_ssl.sh | ||
- ./scripts/init-user-db.sh:/docker-entrypoint-initdb.d/init-user-db.sh | ||
- ../.travis/travis_ssl_users.sh:/home/scripts/travis_ssl_users.sh | ||
- ../certdir/server:/home/certdir | ||
entrypoint: | ||
- bash | ||
- /home/certdir/chmod_ssl.sh | ||
environment: | ||
- POSTGRES_USER=postgres | ||
- POSTGRES_PASSWORD= | ||
- POSTGRES_DB=postgres | ||
- GITHUB_ACTIONS=true | ||
command: >- | ||
postgres | ||
-c 'hba_file=/home/pg_hba.conf' | ||
-c 'ssl=on' | ||
-c 'ssl_cert_file=/home/certdir/server.crt' | ||
-c 'ssl_key_file=/home/certdir/server.key' | ||
-c 'ssl_ca_file=/home/certdir/root.crt' | ||
-c 'max_prepared_transactions=64' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#!/usr/bin/env bash | ||
|
||
whoami | ||
chown postgres:postgres /home/certdir/*.key | ||
chmod 0600 /home/certdir/*.key | ||
|
||
cp /home/certdir/pg_hba.conf /home/pg_hba.conf | ||
sed -i 's/127.0.0.1\/32/0.0.0.0\/0/g' /home/pg_hba.conf | ||
|
||
docker-entrypoint.sh $@ |
4 changes: 0 additions & 4 deletions
4
.github/workflows/init-user-db.sh → docker/scripts/init-user-db.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,10 @@ | ||
#!/bin/bash | ||
set -e | ||
|
||
whoami | ||
|
||
psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" --dbname "$POSTGRES_DB" <<-EOSQL | ||
SET password_encryption='scram-sha-256'; | ||
CREATE USER test with password 'test'; | ||
CREATE DATABASE test OWNER test; | ||
CREATE USER root; | ||
CREATE DATABASE root OWNER root; | ||
EOSQL | ||
|
||
/home/scripts/travis_ssl_users.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters