Deploy DSpace #1852
This file contains hidden or 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
| # DSpace Docker deploy on dataquest servers | |
| name: Deploy DSpace | |
| on: | |
| workflow_call: | |
| inputs: | |
| DEV_MACHINE: | |
| required: false | |
| type: string | |
| default: 'dev-6' | |
| INSTANCE: | |
| required: false | |
| type: string | |
| default: '8563' | |
| IMPORT: | |
| required: false | |
| default: true | |
| type: boolean | |
| ERASE_DB: | |
| required: false | |
| default: false | |
| type: boolean | |
| workflow_dispatch: | |
| inputs: | |
| INSTANCE: | |
| required: true | |
| default: '8563' | |
| type: choice | |
| options: | |
| - '8563' | |
| IMPORT: | |
| required: true | |
| default: true | |
| type: boolean | |
| ERASE_DB: | |
| required: false | |
| default: false | |
| type: boolean | |
| DEV_MACHINE: | |
| required: false | |
| type: string | |
| default: 'dev-6' | |
| jobs: | |
| deploy-3: | |
| if: inputs.INSTANCE == '*' || inputs.INSTANCE == '8563' | |
| runs-on: dspace-${{inputs.DEV_MACHINE}}-dep-1 | |
| timeout-minutes: 10 | |
| env: | |
| INSTANCE: '8563' | |
| CONFIG_PATH: /opt/dspace-envs/${{inputs.INSTANCE}} | |
| ENVFILE: /opt/dspace-envs/${{inputs.INSTANCE}}/.env | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: ./.github/actions/erase-db | |
| if: inputs.ERASE_DB | |
| with: | |
| INSTANCE: ${{ env.INSTANCE }} | |
| NAME: dspace-${{ env.INSTANCE }} | |
| - name: deploy to ${{inputs.DEV_MACHINE}} | |
| working-directory: build-scripts/run/ | |
| run: | | |
| ./start.sh dspace-$INSTANCE | |
| cd ../.. | |
| # use customized docker-compose file for the `85` port because the server is exposed with the namespace `repository` | |
| # `/repository/server` | |
| docker compose --env-file $ENVFILE -p dspace-$INSTANCE -f docker/docker-compose.yml -f docker/docker-compose-rest.yml -f $CONFIG_PATH/docker-compose-rest.yml -f $CONFIG_PATH/docker-compose.yml up -d --no-build | |
| import-3: | |
| runs-on: dspace-${{inputs.DEV_MACHINE}}-dep-1 | |
| if: inputs.IMPORT | |
| timeout-minutes: 120 | |
| needs: deploy-3 | |
| env: | |
| INSTANCE: ${{inputs.INSTANCE}} | |
| CONFIG_PATH: /opt/dspace-envs/ | |
| steps: | |
| - name: vanilla import | |
| env: | |
| FNAME: old_dump.sql | |
| run: | | |
| export DATADIR=$CONFIG_PATH/${{inputs.INSTANCE}}/dump/$FNAME | |
| export DNAME=dspace${{inputs.INSTANCE}} | |
| export DDBNAME=dspacedb${{inputs.INSTANCE}} | |
| docker stop $DNAME || true | |
| echo "=====" | |
| # echo Starting vanilla import DB | |
| docker cp $DATADIR $DDBNAME:/tmp/ | |
| # Terminate connections, drop, create, import, add required extensions, cleanup | |
| docker exec $DDBNAME /bin/bash -c " | |
| psql -p 10563 -U dspace -d postgres -c \"SELECT pg_terminate_backend(pg_stat_activity.pid) FROM pg_stat_activity WHERE pg_stat_activity.datname = 'dspace' AND pid <> pg_backend_pid();\" && | |
| dropdb -U dspace -p 10563 dspace && | |
| createdb -U dspace -p 10563 --owner=dspace --encoding=UNICODE dspace && | |
| (psql -p 10563 -U dspace -d postgres -c \"CREATE ROLE postgres SUPERUSER;\" || true) && | |
| (psql -p 10563 -U dspace -d postgres -c \"CREATE ROLE dspace5 IN ROLE dspace;\" || true) && | |
| psql -p 10563 -U dspace -d dspace -f /tmp/$FNAME && | |
| psql -p 10563 -U dspace -d dspace -c 'CREATE EXTENSION IF NOT EXISTS pgcrypto;' && | |
| psql -p 10563 -U dspace -d dspace -c \" | |
| WITH ranked AS ( | |
| SELECT ctid, row_number() OVER (PARTITION BY eperson_group_id, eperson_id ORDER BY ctid) AS rn | |
| FROM epersongroup2eperson | |
| ) | |
| DELETE FROM epersongroup2eperson | |
| WHERE ctid IN (SELECT ctid FROM ranked WHERE rn > 1); | |
| \" && | |
| rm /tmp/$FNAME | |
| " | |
| echo "=====" | |
| docker start $DNAME | |
| sleep 60 | |
| docker exec $DNAME /bin/bash -c "cd /dspace/bin && ./dspace database migrate ignored && ./dspace create-administrator -e test@test.edu -f admin -l user -p admin -c en -o dataquest" | |
| echo "=====" | |
| # new user will not be accepted unless restarted | |
| docker restart $DNAME | |
| sleep 60 | |
| echo "=====" | |
| - name: dspace healthcheck | |
| run: | | |
| export DNAME=dspace${{inputs.INSTANCE}} | |
| echo "dspace healthcheck:" | |
| docker exec $DNAME /bin/bash -c "cd /dspace/bin && ./dspace healthcheck -v" |