@@ -57,4 +57,123 @@ 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+ # Override default ui.baseUrl to also use 127.0.0.1. This should match 'dspace.ui.url'.
78+ DSPACE_UI_BASEURL : http://127.0.0.1:4000
79+ steps :
80+ # Checkout our codebase (to get access to Docker Compose scripts)
81+ - name : Checkout codebase
82+ uses : actions/checkout@v6
83+ # Download Docker image artifacts (which were just built by reusable-docker-build.yml)
84+ - name : Download Docker image artifacts
85+ uses : actions/download-artifact@v8
86+ with :
87+ # Download all amd64 Docker images (TAR files) into the /tmp/docker directory
88+ pattern : docker-image-*-linux-amd64
89+ path : /tmp/docker
90+ merge-multiple : true
91+ # Load each of the images into Docker by calling "docker image load" for each.
92+ # This ensures we are using the images just built & not any prior versions on DockerHub
93+ - name : Load all downloaded Docker images
94+ run : |
95+ find /tmp/docker -type f -name "*.tar" -exec docker image load --input "{}" \;
96+ docker image ls -a
97+ # Start backend using our compose script in the codebase.
98+ - name : Start backend in Docker
99+ # MUST use docker.io as we don't have a copy of this backend image in our GitHub Action,
100+ # and docker.io is the only public image. If we ever hit aggressive rate limits at DockerHub,
101+ # we may need to consider making the 'ghcr.io' images public & switch this to 'ghcr.io'
102+ env :
103+ DOCKER_REGISTRY : docker.io
104+ run : |
105+ docker compose -f docker/docker-compose-rest.yml up -d
106+ sleep 10
107+ docker container ls
108+ # Create a test admin account. Load test data from a simple set of AIPs as defined in cli.ingest.yml
109+ # NOTE: Before creating test data, we wait for the backend to become responsive by requesting it every 10 sec.
110+ # Timeout after 5 minutes. This is done to ensure the backend is fully initialized before we create test data.
111+ - name : Load test data into Backend
112+ run : |
113+ timeout 5m wget --retry-connrefused -t 0 --waitretry=10 http://127.0.0.1:8080/server/api
114+ docker compose -f docker/cli.yml run --rm dspace-cli create-administrator -e test@test.edu -f admin -l user -p admin -c en
115+ docker compose -f docker/cli.yml -f docker/cli.ingest.yml run --rm dspace-cli
116+ # Verify backend started successfully.
117+ # 1. Make sure root endpoint is responding (check for dspace.name defined in docker-compose.yml)
118+ # 2. Also check /collections endpoint to ensure the test data loaded properly (check for a collection name in AIPs)
119+ - name : Verify backend is responding properly
120+ run : |
121+ result=$(wget -O- -q http://127.0.0.1:8080/server/api)
122+ echo "$result"
123+ echo "$result" | grep -oE "\"DSpace Started with Docker Compose\""
124+ result=$(wget -O- -q http://127.0.0.1:8080/server/api/core/collections)
125+ echo "$result"
126+ echo "$result" | grep -oE "\"Dog in Yard\""
127+ # Start production frontend using our compose script in the codebase.
128+ - name : Start production frontend in Docker
129+ # Specify the GHCR copy of the production frontend, so that we use the newly built image
130+ env :
131+ DOCKER_REGISTRY : ghcr.io
132+ run : |
133+ docker compose -f docker/docker-compose-dist.yml up -d
134+ sleep 10
135+ docker container ls
136+ # Verify production frontend started successfully.
137+ # 1. Make sure /home path has "DSpace software" (this is in the footer of the page)
138+ # 2. Also check /community-list page lists one of the test Communities in the loaded test data
139+ - name : Verify production frontend is responding properly
140+ run : |
141+ result=$(wget -O- -q http://127.0.0.1:4000/home)
142+ echo "$result"
143+ echo "$result" | grep -oE "\"DSpace software\""
144+ - name : Error logs of production frontend (if error in startup)
145+ if : ${{ failure() }}
146+ run : |
147+ docker compose -f docker/docker-compose-dist.yml logs
148+ # Now shutdown the production frontend image and startup the development frontend image
149+ - name : Shutdown production frontend
150+ run : |
151+ docker compose -f docker/docker-compose-dist.yml down
152+ sleep 10
153+ docker container ls
154+ - name : Startup development frontend
155+ # Specify the GHCR copy of the development frontend, so that we use the newly built image
156+ env :
157+ DOCKER_REGISTRY : ghcr.io
158+ run : |
159+ docker compose -f docker/docker-compose.yml up -d
160+ sleep 10
161+ docker container ls
162+ # Verify development frontend started successfully.
163+ # 1. First, keep requesting the frontend every 10 seconds to wait until its up. Timeout after 10 minutes.
164+ # 2. Once it's responding, check to see if the word "DSpace" appears.
165+ # We cannot check for anything more specific because development mode doesn't have SSR.
166+ - name : Verify development frontend is responding properly
167+ run : |
168+ timeout 10m wget --retry-connrefused -t 0 --waitretry=10 http://127.0.0.1:4000
169+ result=$(wget -O- -q http://127.0.0.1:4000)
170+ echo "$result"
171+ echo "$result" | grep -oE "DSpace"
172+ - name : Error logs of development frontend (if error in startup)
173+ if : ${{ failure() }}
174+ run : |
175+ docker compose -f docker/docker-compose.yml logs
176+ # Shutdown our containers
177+ - name : Shutdown running Docker containers
178+ run : |
179+ docker compose -f docker/docker-compose.yml -f docker/docker-compose-rest.yml down
0 commit comments