Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
43 changes: 22 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,31 @@ 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 with --wait for health checks
# Use CI-specific override for GitHub Actions cache
docker compose -f docker-compose.yml -f docker-compose.ci.yml up -d --build --wait staging

# 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 -f docker-compose.yml -f docker-compose.ci.yml stop staging

# Exit with the test result
exit $exit_code
7 changes: 7 additions & 0 deletions docker-compose.ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
services:
staging:
build:
cache_from:
- type=gha
cache_to:
- type=gha,mode=max
14 changes: 14 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -103,3 +103,17 @@ services:
command: ["http://http_serve"]
profiles:
- manual

# Staging service for on_call_staging_test workflow
staging:
build:
context: ./_site
dockerfile: ../.github/scripts/staging/Dockerfile
ports:
- 8080:80
healthcheck:
test: ["CMD", "curl", "-o", "/dev/null", "-s", "http://localhost"]
interval: 10s
timeout: 5s
retries: 5
start_period: 30s