From 3729cc89de09dd005071aba73e5a36fc968e9dd5 Mon Sep 17 00:00:00 2001 From: Mariusz Kogen Date: Mon, 4 Dec 2023 22:52:14 +0100 Subject: [PATCH] migrate pg main cluster * fix permissions --- Dockerfile | 2 +- docker_entrypoint.sh | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index 97e7662..11d1c75 100644 --- a/Dockerfile +++ b/Dockerfile @@ -47,7 +47,7 @@ RUN pnpm run build FROM nginx:bookworm -RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends postgresql-15 && rm -rf /var/lib/apt/lists/* +RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends postgresql-15 && rm -rf /var/lib/apt/lists/* && mv /var/lib/postgresql/15/main /var/lib/ # Copy binaries COPY --from=rust-builder /build/vss-rs/target/release/vss-rs /app/vss-rs diff --git a/docker_entrypoint.sh b/docker_entrypoint.sh index e9c13e4..502ec3e 100755 --- a/docker_entrypoint.sh +++ b/docker_entrypoint.sh @@ -8,6 +8,8 @@ RUST_LOG=debug #Start and Configure PostgreSQL echo 'Starting PostgreSQL database server for the first time...' + mkdir -p $POSTGRES_DATADIR $POSTGRES_CONFIG + mv /var/lib/main $POSTGRES_DATADIR chown -R postgres:postgres $POSTGRES_DATADIR chown -R postgres:postgres $POSTGRES_CONFIG chmod -R 700 $POSTGRES_DATADIR @@ -30,9 +32,9 @@ RUST_LOG=debug echo 'Granting db permissions...' su - postgres -c 'psql -c "grant all privileges on database '$POSTGRES_DB' to '$POSTGRES_USER';"' echo 'Creating .pgpass file...' - su - postgres -c 'echo "localhost:5432:'$POSTGRES_USER':'$POSTGRES_PASSWORD'" >> .pgpass' - su - postgres -c "chmod -R 0600 .pgpass" - chmod -R 0600 /var/lib/postgresql/.pgpass + echo "localhost:5432:'$POSTGRES_USER':'$POSTGRES_PASSWORD'" > $POSTGRES_DATADIR/../.pgpass + chmod -R 0600 $POSTGRES_DATADIR/../.pgpass + chown postgres:postgres $POSTGRES_DATADIR/../.pgpass /app/vss-rs & /app/ln-websocket-proxy &