Skip to content

Commit 8c6751a

Browse files
authored
Merge pull request #229 from orionrobots/copilot/fix-228
Migrate on_call_staging_test workflow to use Docker Compose with improved CI integration
2 parents bed86cf + 44deee4 commit 8c6751a

File tree

4 files changed

+52
-24
lines changed

4 files changed

+52
-24
lines changed

.github/scripts/staging/Dockerfile

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1-
FROM centos/httpd:latest
2-
COPY . /var/www/html/
3-
COPY http2.conf /etc/httpd/conf/httpd.conf
1+
FROM httpd:2.4.64
2+
3+
# Install curl for healthcheck
4+
RUN apt-get update && apt-get install -y curl && rm -rf /var/lib/apt/lists/*
5+
6+
# Copy the built site content (context is _site directory)
7+
COPY . /usr/local/apache2/htdocs/
8+
# Copy the Apache configuration (copied to _site in workflow as httpd.conf)
9+
COPY httpd.conf /usr/local/apache2/conf/httpd.conf

.github/workflows/on_call_staging_test.yaml

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -14,30 +14,31 @@ jobs:
1414
- name: extract site artifact
1515
run: |
1616
tar -xzf _site.tar.gz
17-
- name: Prepare for docker build
18-
run: |
19-
cp .github/scripts/staging/Dockerfile _site/
20-
cp .github/scripts/staging/http2.conf _site/
2117
2218
- name: Set up Docker Buildx
2319
uses: docker/setup-buildx-action@v3
2420

25-
- name: Build the container
26-
uses: docker/build-push-action@v6
27-
with:
28-
context: "_site"
29-
tags: orionrobots:latest
30-
cache-from: type=gha
31-
cache-to: type=gha,mode=max
32-
push: false
33-
load: true
34-
21+
- name: Prepare staging context
22+
run: |
23+
# Copy staging files into the _site directory for the docker build
24+
cp .github/scripts/staging/default.conf _site/httpd.conf
25+
3526
- name: Run as service and test
3627
run: |
37-
docker run --rm -d -p8080:80 --name orionrobots orionrobots:latest
38-
# Wait for the service to start
39-
sleep 10
40-
curl -I -L -f http://localhost:8080/
41-
curl -I -L -f http://localhost:8080/construction_guide.html
42-
curl -I -L -f http://localhost:8080/wiki/lego
43-
docker stop orionrobots
28+
# Start the staging service using docker compose with --wait for health checks
29+
# Use CI-specific override for GitHub Actions cache
30+
docker compose -f docker-compose.yml -f docker-compose.ci.yml up -d --build --wait staging
31+
32+
# Perform the tests
33+
set +e # Don't exit on error so we can clean up
34+
exit_code=0
35+
36+
curl -I -f http://localhost:8080/ || exit_code=1
37+
curl -I -f http://localhost:8080/construction_guide.html || exit_code=1
38+
curl -I -f http://localhost:8080/wiki/lego || exit_code=1
39+
40+
# Stop the service regardless of test outcome
41+
docker compose -f docker-compose.yml -f docker-compose.ci.yml stop staging
42+
43+
# Exit with the test result
44+
exit $exit_code

docker-compose.ci.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
services:
2+
staging:
3+
build:
4+
cache_from:
5+
- type=gha
6+
cache_to:
7+
- type=gha,mode=max

docker-compose.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,3 +103,17 @@ services:
103103
command: ["http://http_serve"]
104104
profiles:
105105
- manual
106+
107+
# Staging service for on_call_staging_test workflow
108+
staging:
109+
build:
110+
context: ./_site
111+
dockerfile: ../.github/scripts/staging/Dockerfile
112+
ports:
113+
- 8080:80
114+
healthcheck:
115+
test: ["CMD", "curl", "-o", "/dev/null", "-s", "http://localhost"]
116+
interval: 10s
117+
timeout: 5s
118+
retries: 5
119+
start_period: 30s

0 commit comments

Comments
 (0)