Skip to content

Commit

Permalink
Generate a container with one Ephemera project in it.
Browse files Browse the repository at this point in the history
  • Loading branch information
tpendragon committed Jul 15, 2024
1 parent 7985040 commit be8ef7a
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 4 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,5 @@ dpul_collections-*.tar
# In case you use Node.js/npm, you want to ignore these.
npm-debug.log
/assets/node_modules/

figgy-fixture-container/fixture-exports/*.binary
figgy-fixture-container/fixture-exports/*.sql
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,13 @@ Run Docker Image: `docker run -t -p 4000:4000 -e DATABASE_URL='ecto://postgres:@
1. Connect to VPN
1. `BRANCH=<branch> ./bin/deploy staging`

## Figgy Fixtures

We copy fixtures from Figgy's production database into a Docker container so that we can easily use it for testing indexing. To rebuild that container:

`brew install lastpass-cli`
`cd figgy-fixture-container && ./build-and-push.sh`

## Learn more

* Official website: https://www.phoenixframework.org/
Expand Down
3 changes: 3 additions & 0 deletions figgy-fixture-container/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
FROM postgres:15
ADD fixture-exports /tmp/fixture-exports
ADD import-container-fixtures.sh /docker-entrypoint-initdb.d/import-container-fixtures.sh
10 changes: 10 additions & 0 deletions figgy-fixture-container/build-and-push.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash

./create-fixture-exports.sh
echo "Enter lastpass username:"
read USERNAME
lpass login $USERNAME
export CR_PAT=$(lpass show "Shared-ITIMS-Passwords/dpul_collections_fixture_container_github_token" --notes)
echo $CR_PAT | docker login ghcr.io -u pulbot --password-stdin
docker buildx create --name multiarch --driver docker-container --use || true
docker buildx build --push --platform linux/arm64,linux/amd64 -t ghcr.io/pulibrary/dpul-collections:figgy-fixtures .
6 changes: 3 additions & 3 deletions figgy-fixture-container/create-fixture-exports.sh
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,6 @@ END
ssh [email protected] "cd /opt/figgy/current && PGPASSWORD=\$FIGGY_DB_RO_PASSWORD psql -d \$FIGGY_DB -U \$FIGGY_DB_RO_USERNAME -h \$FIGGY_DB_HOST -c \"\\copy ($VOCABULARY_QUERY) TO '/tmp/project-vocabulary-export.binary' BINARY\""

# Get the DB schema
#
#
ssh [email protected] "cd /opt/figgy/current && PGPASSWORD=\$FIGGY_DB_RO_PASSWORD pg_dump -U \$FIGGY_DB_RO_USERNAME -h \$FIGGY_DB_HOST -f /tmp/db-schema.sql --schema-only \$FIGGY_DB"
ssh [email protected] "cd /opt/figgy/current && PGPASSWORD=\$FIGGY_DB_RO_PASSWORD pg_dump -Fc -U \$FIGGY_DB_RO_USERNAME -h \$FIGGY_DB_HOST -f /tmp/db-schema.sql --schema-only \$FIGGY_DB"

scp [email protected]:/tmp/\{db-schema.sql,project-vocabulary-export.binary,project-members-export.binary,project-export.binary\} fixture-exports/
Empty file.
7 changes: 7 additions & 0 deletions figgy-fixture-container/import-container-fixtures.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash

pg_restore -d "$POSTGRES_DB" --no-owner --no-privileges --role=$POSTGRES_USER /tmp/fixture-exports/db-schema.sql

psql -d "$POSTGRES_DB" -U $POSTGRES_USER -c "\copy orm_resources FROM /tmp/fixture-exports/project-export.binary BINARY"
psql -d "$POSTGRES_DB" -U $POSTGRES_USER -c "\copy orm_resources FROM /tmp/fixture-exports/project-members-export.binary BINARY"
psql -d "$POSTGRES_DB" -U $POSTGRES_USER -c "\copy orm_resources FROM /tmp/fixture-exports/project-vocabulary-export.binary BINARY"

0 comments on commit be8ef7a

Please sign in to comment.