@@ -57,4 +57,117 @@ jobs:
5757 # Enable redeploy of sandbox & demo if the branch for this image matches the deployment branch of
5858 # these sites as specified in reusable-docker-build.xml
5959 REDEPLOY_SANDBOX_URL : ${{ secrets.REDEPLOY_SANDBOX_URL }}
60- REDEPLOY_DEMO_URL : ${{ secrets.REDEPLOY_DEMO_URL }}
60+ REDEPLOY_DEMO_URL : ${{ secrets.REDEPLOY_DEMO_URL }}
61+
62+ # ################################################################################
63+ # Test Deployment via Docker to ensure newly built images are working properly
64+ # ################################################################################
65+ docker-deploy :
66+ # Ensure this job never runs on forked repos. It's only executed for 'dspace/dspace-angular'
67+ if : github.repository == 'dspace/dspace-angular'
68+ runs-on : ubuntu-latest
69+ # Must run after all major images are built
70+ needs : [dspace-angular, dspace-angular-dist]
71+ env :
72+ # Override default dspace.server.url & REST 'host' because backend starts at http://127.0.0.1:8080
73+ dspace__P__server__P__url : http://127.0.0.1:8080/server
74+ DSPACE_REST_HOST : 127.0.0.1
75+ # Override default dspace.ui.url to also use 127.0.0.1.
76+ dspace__P__ui__P__url : http://127.0.0.1:4000
77+ # Docker Registry to use for Docker compose scripts below.
78+ # If this is a PR, then we need to use docker.io (as the registry must be public),
79+ # Otherwise we default to ghcr.io to avoid aggressive rate limits at DockerHub.
80+ DOCKER_REGISTRY : ${{ github.event_name == 'pull_request' && 'docker.io' || 'ghcr.io' }}
81+ steps :
82+ # Checkout our codebase (to get access to Docker Compose scripts)
83+ - name : Checkout codebase
84+ uses : actions/checkout@v4
85+ # Download Docker image artifacts (which were just built by reusable-docker-build.yml)
86+ - name : Download Docker image artifacts
87+ uses : actions/download-artifact@v4
88+ with :
89+ # Download all amd64 Docker images (TAR files) into the /tmp/docker directory
90+ pattern : docker-image-*-linux-amd64
91+ path : /tmp/docker
92+ merge-multiple : true
93+ # Load each of the images into Docker by calling "docker image load" for each.
94+ # This ensures we are using the images just built & not any prior versions on DockerHub
95+ - name : Load all downloaded Docker images
96+ run : |
97+ find /tmp/docker -type f -name "*.tar" -exec docker image load --input "{}" \;
98+ docker image ls -a
99+ # Start backend using our compose script in the codebase.
100+ - name : Start backend in Docker
101+ run : |
102+ docker compose -f docker/docker-compose-rest.yml up -d
103+ sleep 10
104+ docker container ls
105+ # Create a test admin account. Load test data from a simple set of AIPs as defined in cli.ingest.yml
106+ - name : Load test data into Backend
107+ run : |
108+ docker compose -f docker/cli.yml run --rm dspace-cli create-administrator -e test@test.edu -f admin -l user -p admin -c en
109+ docker compose -f docker/cli.yml -f docker/cli.ingest.yml run --rm dspace-cli
110+ # Verify backend started successfully.
111+ # 1. Make sure root endpoint is responding (check for dspace.name defined in docker-compose.yml)
112+ # 2. Also check /collections endpoint to ensure the test data loaded properly (check for a collection name in AIPs)
113+ - name : Verify backend is responding properly
114+ run : |
115+ result=$(wget -O- -q http://127.0.0.1:8080/server/api)
116+ echo "$result"
117+ echo "$result" | grep -oE "\"DSpace Started with Docker Compose\""
118+ result=$(wget -O- -q http://127.0.0.1:8080/server/api/core/collections)
119+ echo "$result"
120+ echo "$result" | grep -oE "\"Dog in Yard\""
121+ # Start production frontend using our compose script in the codebase.
122+ - name : Start production frontend in Docker
123+ # Specify the GHCR copy of the production frontend, so that we use the newly built image
124+ env :
125+ DOCKER_REGISTRY : ghcr.io
126+ run : |
127+ docker compose -f docker/docker-compose-dist.yml up -d
128+ sleep 10
129+ docker container ls
130+ # Verify production frontend started successfully.
131+ # 1. Make sure /home path has "DSpace software" (this is in the footer of the page)
132+ # 2. Also check /community-list page lists one of the test Communities in the loaded test data
133+ - name : Verify production frontend is responding properly
134+ run : |
135+ result=$(wget -O- -q http://127.0.0.1:4000/home)
136+ echo "$result"
137+ echo "$result" | grep -oE "DSpace software"
138+ - name : Error logs of production frontend (if error in startup)
139+ if : ${{ failure() }}
140+ run : |
141+ docker compose -f docker/docker-compose-dist.yml logs
142+ # Now shutdown the production frontend image and startup the development frontend image
143+ - name : Shutdown production frontend
144+ run : |
145+ docker compose -f docker/docker-compose-dist.yml down
146+ sleep 10
147+ docker container ls
148+ - name : Startup development frontend
149+ # Specify the GHCR copy of the development frontend, so that we use the newly built image
150+ env :
151+ DOCKER_REGISTRY : ghcr.io
152+ run : |
153+ docker compose -f docker/docker-compose.yml up -d
154+ sleep 10
155+ docker container ls
156+ # Verify development frontend started successfully.
157+ # 1. First, keep requesting the frontend every 10 seconds to wait until its up. Timeout after 10 minutes.
158+ # 2. Once it's responding, check to see if the word "DSpace" appears.
159+ # We cannot check for anything more specific because development mode doesn't have SSR.
160+ - name : Verify development frontend is responding properly
161+ run : |
162+ timeout 10m wget --retry-connrefused -t 0 --waitretry=10 http://127.0.0.1:4000
163+ result=$(wget -O- -q http://127.0.0.1:4000)
164+ echo "$result"
165+ echo "$result" | grep -oE "DSpace"
166+ - name : Error logs of development frontend (if error in startup)
167+ if : ${{ failure() }}
168+ run : |
169+ docker compose -f docker/docker-compose.yml logs
170+ # Shutdown our containers
171+ - name : Shutdown running Docker containers
172+ run : |
173+ docker compose -f docker/docker-compose.yml -f docker/docker-compose-rest.yml down
0 commit comments