forked from DSpace/dspace-angular
-
Notifications
You must be signed in to change notification settings - Fork 2
178 lines (154 loc) · 6.16 KB
/
Copy pathdeploy.yml
File metadata and controls
178 lines (154 loc) · 6.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
# 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: '8593'
IMPORT:
required: false
default: false
type: boolean
ERASE_DB:
required: false
default: false
type: boolean
workflow_dispatch:
inputs:
INSTANCE:
required: true
default: '8593'
type: choice
options:
- '8593'
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 == '8593'
runs-on: dspace-${{inputs.DEV_MACHINE}}-dep-1
timeout-minutes: 60
env:
INSTANCE: '8593'
CONFIG_PATH: /opt/dspace-envs/${{inputs.INSTANCE}}
ENVFILE: /opt/dspace-envs/${{inputs.INSTANCE}}/.env
steps:
- uses: actions/checkout@v6
- uses: ./.github/actions/erase-db
if: inputs.ERASE_DB
with:
INSTANCE: ${{ env.INSTANCE }}
NAME: dspace-${{ env.INSTANCE }}
- name: Set start.sh as executable
run: chmod +x build-scripts/run/start.sh
- name: deploy to ${{inputs.DEV_MACHINE}}
working-directory: build-scripts/run/
env:
ADMIN_PASSWORD: ${{ secrets.DSPACE_ADMIN_PASSWORD }}
USER_PASSWORD: ${{ secrets.DSPACE_USER_PASSWORD }}
run: |
./start.sh dspace-$INSTANCE
cd ../..
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 --remove-orphans
playwright-after-deploy3:
needs: deploy-3
if: '!inputs.IMPORT'
uses: ./.github/workflows/playwright-tests.yml
secrets: inherit
playwright-after-import3:
needs: import-3
if: inputs.IMPORT
uses: ./.github/workflows/playwright-tests.yml
secrets: inherit
import-3:
runs-on: dspace-${{inputs.DEV_MACHINE}}-dep-1
if: inputs.IMPORT
timeout-minutes: 900
needs: deploy-3
env:
INSTANCE: ${{inputs.INSTANCE}}
CONFIG_PATH: /opt/dspace-envs/
FNAME: old_dump.sql
ADMIN_PASSWORD: ${{ secrets.DSPACE_ADMIN_PASSWORD }}
steps:
- uses: actions/checkout@v6
- name: vanilla import
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/$FNAME
echo "Copying script for setup db roles to container..."
# Create database, import dumpand extensions, then cleanup
docker exec $DDBNAME /bin/bash -c "
dropdb -U dspace dspace || true &&
createdb -U dspace --owner=dspace --encoding=UNICODE dspace &&
psql -U dspace -d dspace -f /tmp/$FNAME
"
echo "====="
docker start $DNAME
- name: run database migration
run: |
export DNAME=dspace${{inputs.INSTANCE}}
export ENVFILE=$CONFIG_PATH/${{inputs.INSTANCE}}/.env
export OVERLAY=$CONFIG_PATH/${{inputs.INSTANCE}}
# ---------------------------------------------------------------
# Why a one-off `docker compose run` instead of `docker exec $DNAME migrate`:
# The dspace entrypoint auto-runs `dspace database migrate` (WITHOUT `ignored`)
# and then starts the REST webapp. On a freshly imported DSpace-6 dump the
# "Ignored" XMLWorkflow migrations are NOT applied, so the webapp boots against
# an un-migrated DB, crashes, and (with the restart policy) the container
# restarts. That restart SIGKILLs any `docker exec` running inside it -> the
# migration dies with exit 137. So we stop the app and run the migration as a
# one-off compose container (overridden entrypoint = migrate only, no webapp,
# no restart policy), using the same compose files/env as the deploy step.
# ---------------------------------------------------------------
echo "Stopping app container so its restart loop can't kill the migration..."
docker stop $DNAME || true
echo "Running one-off DB migration via docker compose..."
docker compose --env-file $ENVFILE -p dspace-${{inputs.INSTANCE}} \
-f docker/docker-compose.yml -f docker/docker-compose-rest.yml \
-f $OVERLAY/docker-compose-rest.yml -f $OVERLAY/docker-compose.yml \
run --rm --no-deps --entrypoint /bin/bash dspace \
-c "while (!</dev/tcp/dspacedb/5432) >/dev/null 2>&1; do sleep 1; done; cd /dspace/bin && ./dspace database migrate ignored"
echo "Migration done. Starting app container (entrypoint migrate is now a no-op)..."
docker start $DNAME
echo "Waiting for DSpace to be ready..."
sleep 10
- name: restart dspace container
run: |
export DNAME=dspace${{inputs.INSTANCE}}
echo "Restarting DSpace container..."
docker restart $DNAME
sleep 60
- name: create administrator
run: |
export DNAME=dspace${{inputs.INSTANCE}}
echo "Creating DSpace administrator..."
docker exec $DNAME /bin/bash -c "cd /dspace/bin && ./dspace create-administrator -e dspace.admin.dev@dataquest.sk -f admin -l user -p \"${ADMIN_PASSWORD}\" -c en"
- name: rebuild discovery index and run oai import
run: |
export DNAME=dspace${{inputs.INSTANCE}}
echo "Rebuilding discovery index..."
docker exec $DNAME /bin/bash -c "/dspace/bin/dspace index-discovery -b"
echo "Running OAI import..."
docker exec $DNAME /bin/bash -c "/dspace/bin/dspace oai import -c"