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