Skip to content

Commit

Permalink
[stacks-blockchain-api]: fix postgres restore from archive file
Browse files Browse the repository at this point in the history
  • Loading branch information
deantchi authored Aug 8, 2024
1 parent 7d42b99 commit fa6f2e5
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 5 deletions.
2 changes: 1 addition & 1 deletion hirosystems/stacks-blockchain-api/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,4 @@ sources:
- https://github.com/hirosystems/stacks-blockchain-api
- https://docs.hiro.so/api
- https://docs.hiro.so/get-started/stacks-blockchain-api
version: 5.0.10
version: 5.0.11
27 changes: 23 additions & 4 deletions hirosystems/stacks-blockchain-api/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1589,11 +1589,9 @@ postgresql:
# scripts:
# 0_restore_archive.sh: |
# #!/bin/sh
# install_packages curl
# curl https://archive.dev.hiro.so/mainnet/stacks-blockchain-api-pg/stacks-blockchain-api-pg-15-latest.dump -o /opt/stacks-blockchain-api-postgres.dump
# export PGPASSWORD=${POSTGRES_PASSWORD}
# pg_restore --username postgres --verbose --jobs 4 --dbname stacks_blockchain_api /opt/stacks-blockchain-api-postgres.dump
# rm -f /opt/stacks-blockchain-api-postgres.dump
# pg_restore --username postgres --verbose --jobs 4 --dbname stacks_blockchain_api /bitnami/postgresql/stacks-blockchain-api-postgres.dump
# rm -f /bitnami/postgresql/stacks-blockchain-api-postgres.dump
# 1_configure_schema.sql: |
# REVOKE ALL ON DATABASE stacks_blockchain_api FROM public;
# GRANT ALL PRIVILEGES ON DATABASE stacks_blockchain_api TO postgres;
Expand All @@ -1605,5 +1603,26 @@ postgresql:
# REVOKE ALL ON SCHEMA public FROM public;
# REVOKE ALL ON SCHEMA stacks_blockchain_api FROM public;
# GRANT ALL ON SCHEMA stacks_blockchain_api TO postgres;
initContainers:
- name: pg-init-helper
image: google/cloud-sdk:alpine
command:
- /bin/sh
- -c
- --
- |
if [ -z "$(ls -A /bitnami/postgresql)" ]; then
echo "Postgres dir is empty, downloading archive file..."
curl https://archive.hiro.so/mainnet/stacks-blockchain-api-pg/stacks-blockchain-api-pg-15-latest.dump -o /bitnami/postgresql/stacks-blockchain-api-postgres.dump
else
echo "Postgres dir is not empty, exiting..."
fi
securityContext:
runAsGroup: 0
runAsNonRoot: true
runAsUser: 1337
volumeMounts:
- mountPath: /bitnami/postgresql
name: data
persistence:
size: 50Gi

0 comments on commit fa6f2e5

Please sign in to comment.