@@ -57,4 +57,120 @@ 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 must match 'dspace.ui.url' for SSR to be enabled.
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+ - name : Load test data into Backend
110+ run : |
111+ docker compose -f docker/cli.yml run --rm dspace-cli create-administrator -e test@test.edu -f admin -l user -p admin -c en
112+ docker compose -f docker/cli.yml -f docker/cli.ingest.yml run --rm dspace-cli
113+ # Verify backend started successfully.
114+ # 1. Make sure root endpoint is responding (check for dspace.name defined in docker-compose.yml)
115+ # 2. Also check /collections endpoint to ensure the test data loaded properly (check for a collection name in AIPs)
116+ - name : Verify backend is responding properly
117+ run : |
118+ result=$(wget -O- -q http://127.0.0.1:8080/server/api)
119+ echo "$result"
120+ echo "$result" | grep -oE "\"DSpace Started with Docker Compose\""
121+ result=$(wget -O- -q http://127.0.0.1:8080/server/api/core/collections)
122+ echo "$result"
123+ echo "$result" | grep -oE "\"Dog in Yard\""
124+ # Start production frontend using our compose script in the codebase.
125+ - name : Start production frontend in Docker
126+ # Specify the GHCR copy of the production frontend, so that we use the newly built image
127+ env :
128+ DOCKER_REGISTRY : ghcr.io
129+ run : |
130+ docker compose -f docker/docker-compose-dist.yml up -d
131+ sleep 10
132+ docker container ls
133+ # Verify production frontend started successfully.
134+ # 1. Make sure /home path has "DSpace software" (this is in the footer of the page)
135+ # 2. Also check /community-list page lists one of the test Communities in the loaded test data
136+ - name : Verify production frontend is responding properly
137+ run : |
138+ result=$(wget -O- -q http://127.0.0.1:4000/home)
139+ echo "$result"
140+ echo "$result" | grep -oE "\"DSpace software\""
141+ - name : Error logs of production frontend (if error in startup)
142+ if : ${{ failure() }}
143+ run : |
144+ docker compose -f docker/docker-compose-dist.yml logs
145+ # Now shutdown the production frontend image and startup the development frontend image
146+ - name : Shutdown production frontend
147+ run : |
148+ docker compose -f docker/docker-compose-dist.yml down
149+ sleep 10
150+ docker container ls
151+ - name : Startup development frontend
152+ # Specify the GHCR copy of the development frontend, so that we use the newly built image
153+ env :
154+ DOCKER_REGISTRY : ghcr.io
155+ run : |
156+ docker compose -f docker/docker-compose.yml up -d
157+ sleep 10
158+ docker container ls
159+ # Verify development frontend started successfully.
160+ # 1. First, keep requesting the frontend every 10 seconds to wait until its up. Timeout after 10 minutes.
161+ # 2. Once it's responding, check to see if the word "DSpace" appears.
162+ # We cannot check for anything more specific because development mode doesn't have SSR.
163+ - name : Verify development frontend is responding properly
164+ run : |
165+ timeout 10m wget --retry-connrefused -t 0 --waitretry=10 http://127.0.0.1:4000
166+ result=$(wget -O- -q http://127.0.0.1:4000)
167+ echo "$result"
168+ echo "$result" | grep -oE "DSpace"
169+ - name : Error logs of development frontend (if error in startup)
170+ if : ${{ failure() }}
171+ run : |
172+ docker compose -f docker/docker-compose.yml logs
173+ # Shutdown our containers
174+ - name : Shutdown running Docker containers
175+ run : |
176+ docker compose -f docker/docker-compose.yml -f docker/docker-compose-rest.yml down
0 commit comments