Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(db): inherit from scl image, enforce PG_ENCRYPT_KEY #129

Merged
merged 19 commits into from
Oct 30, 2023
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion db/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,2 +1,9 @@
# FROM registry.redhat.io/rhel8/postgresql-15:latest
FROM docker.io/library/postgres:15
COPY ./pgcrypto.sql /docker-entrypoint-initdb.d/

RUN ln -s /usr/local/bin/docker-entrypoint.sh /usr/local/bin/postgres-entrypoint.sh

ENTRYPOINT ["/usr/local/bin/cryostat-db-entrypoint.bash"]

COPY ./pgcrypto.sql /docker-entrypoint-initdb.d/pgcrypto.sql
COPY ./entrypoint.bash /usr/local/bin/cryostat-db-entrypoint.bash
14 changes: 14 additions & 0 deletions db/entrypoint.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/usr/bin/env bash

if [ "${DEBUG}" = "true" ]; then
set -xEeo pipefail
fi

if [ "$1" = "postgres" ]; then
shift
fi

exec /usr/local/bin/postgres-entrypoint.sh \
postgres \
-c encrypt.key="${PG_ENCRYPT_KEY?:\$PG_ENCRYPT_KEY must be set and non-empty}" \
"$@"
7 changes: 1 addition & 6 deletions smoketest/compose/db.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,14 @@ services:
db:
image: quay.io/cryostat/cryostat3-db:dev
build: ../../db
entrypoint:
- /usr/local/bin/docker-entrypoint.sh
command:
- postgres
- -c
- encrypt.key=REPLACEME
hostname: db
expose:
- "5432"
environment:
POSTGRES_USER: cryostat3
POSTGRES_PASSWORD: cryostat3
PG_ENCRYPT_KEY: REPLACEME
DEBUG: "true"
volumes:
- postgresql:/var/lib/postgresql/data
restart: always
Expand Down
3 changes: 2 additions & 1 deletion src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ quarkus.datasource.devservices.enabled=true
quarkus.datasource.devservices.image-name=quay.io/cryostat/cryostat3-db

# !!! prod databases must set this configuration parameter some other way via a secret !!!
quarkus.datasource.devservices.command=postgres -c encrypt.key=REPLACEME
quarkus.datasource.devservices.container-env.PG_ENCRYPT_KEY=examplekey
quarkus.datasource.devservices.container-env.DEBUG=true
# !!!

storage.buckets.archives.name=archivedrecordings
Expand Down
Loading