Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions .github/scripts/staging/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
FROM centos/httpd:latest
COPY . /var/www/html/
COPY http2.conf /etc/httpd/conf/httpd.conf
FROM httpd:2.4.64

# Install curl for healthcheck
RUN apt-get update && apt-get install -y curl && rm -rf /var/lib/apt/lists/*

# Copy the built site content (context is _site directory)
COPY . /usr/local/apache2/htdocs/
# Copy the Apache configuration (copied to _site in workflow as httpd.conf)
COPY httpd.conf /usr/local/apache2/conf/httpd.conf
46 changes: 25 additions & 21 deletions .github/workflows/on_call_staging_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,30 +14,34 @@ jobs:
- name: extract site artifact
run: |
tar -xzf _site.tar.gz
- name: Prepare for docker build
run: |
cp .github/scripts/staging/Dockerfile _site/
cp .github/scripts/staging/http2.conf _site/

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Build the container
uses: docker/build-push-action@v6
with:
context: "_site"
tags: orionrobots:latest
cache-from: type=gha
cache-to: type=gha,mode=max
push: false
load: true

- name: Prepare staging context
run: |
# Copy staging files into the _site directory for the docker build
cp .github/scripts/staging/default.conf _site/httpd.conf

- name: Run as service and test
run: |
docker run --rm -d -p8080:80 --name orionrobots orionrobots:latest
# Wait for the service to start
sleep 10
curl -I -L -f http://localhost:8080/
curl -I -L -f http://localhost:8080/construction_guide.html
curl -I -L -f http://localhost:8080/wiki/lego
docker stop orionrobots
# Start the staging service using docker compose (context will be _site now)
docker compose up -d --build staging

# Wait for the health check to pass (healthcheck should handle readiness)
echo "Waiting for service to be ready..."
timeout 60 bash -c 'until curl -f http://localhost:8080/ >/dev/null 2>&1; do sleep 2; done'

# Perform the tests
set +e # Don't exit on error so we can clean up
exit_code=0

curl -I -f http://localhost:8080/ || exit_code=1
curl -I -f http://localhost:8080/construction_guide.html || exit_code=1
curl -I -f http://localhost:8080/wiki/lego || exit_code=1

# Stop the service regardless of test outcome
docker compose stop staging

# Exit with the test result
exit $exit_code
18 changes: 18 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -103,3 +103,21 @@ services:
command: ["http://http_serve"]
profiles:
- manual

# Staging service for on_call_staging_test workflow
staging:
build:
context: ./_site
dockerfile: ../.github/scripts/staging/Dockerfile
cache_from:
- type=gha
cache_to:
- type=gha,mode=max
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How will this behave at the desk? It might only want to do this in the workflow run context - could it be specified there instead as a parameter/env var for the docker compose up command?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved the GitHub Actions cache configuration to a separate docker-compose.ci.yml override file. This isolates the CI-specific cache settings from the main compose file, preventing any issues during local development. The workflow now uses both files with -f docker-compose.yml -f docker-compose.ci.yml. Commit: 44deee4

ports:
- 8080:80
healthcheck:
test: ["CMD", "curl", "-o", "/dev/null", "-s", "http://localhost"]
interval: 10s
timeout: 5s
retries: 5
start_period: 30s