From 15d741522023d7ea1440c4092e480698c23e2b7d Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 1 Aug 2025 16:17:05 +0000 Subject: [PATCH 1/3] Initial plan From c295d1aff39c8a3e1732f883550ae36e7a9b0c78 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 1 Aug 2025 16:35:26 +0000 Subject: [PATCH 2/3] Implement Docker Compose staging test workflow Co-authored-by: dannystaple <426859+dannystaple@users.noreply.github.com> --- .github/scripts/staging/Dockerfile | 12 ++++-- .github/workflows/on_call_staging_test.yaml | 46 +++++++++++---------- docker-compose.yml | 18 ++++++++ 3 files changed, 52 insertions(+), 24 deletions(-) diff --git a/.github/scripts/staging/Dockerfile b/.github/scripts/staging/Dockerfile index 292ada9a..be9e47c5 100644 --- a/.github/scripts/staging/Dockerfile +++ b/.github/scripts/staging/Dockerfile @@ -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 diff --git a/.github/workflows/on_call_staging_test.yaml b/.github/workflows/on_call_staging_test.yaml index c6f14995..43a202e2 100644 --- a/.github/workflows/on_call_staging_test.yaml +++ b/.github/workflows/on_call_staging_test.yaml @@ -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 diff --git a/docker-compose.yml b/docker-compose.yml index 1c5e4eed..68d80354 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -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 + ports: + - 8080:80 + healthcheck: + test: ["CMD", "curl", "-o", "/dev/null", "-s", "http://localhost"] + interval: 10s + timeout: 5s + retries: 5 + start_period: 30s From 44deee4422932ad838a0338da4aaf8835b61f613 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 1 Aug 2025 17:39:38 +0000 Subject: [PATCH 3/3] Replace manual wait loop with docker compose --wait and move cache config to CI override Co-authored-by: dannystaple <426859+dannystaple@users.noreply.github.com> --- .github/workflows/on_call_staging_test.yaml | 11 ++++------- docker-compose.ci.yml | 7 +++++++ docker-compose.yml | 4 ---- 3 files changed, 11 insertions(+), 11 deletions(-) create mode 100644 docker-compose.ci.yml diff --git a/.github/workflows/on_call_staging_test.yaml b/.github/workflows/on_call_staging_test.yaml index 43a202e2..d7d5fd79 100644 --- a/.github/workflows/on_call_staging_test.yaml +++ b/.github/workflows/on_call_staging_test.yaml @@ -25,12 +25,9 @@ jobs: - name: Run as service and test run: | - # 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' + # 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 @@ -41,7 +38,7 @@ jobs: curl -I -f http://localhost:8080/wiki/lego || exit_code=1 # Stop the service regardless of test outcome - docker compose stop staging + docker compose -f docker-compose.yml -f docker-compose.ci.yml stop staging # Exit with the test result exit $exit_code diff --git a/docker-compose.ci.yml b/docker-compose.ci.yml new file mode 100644 index 00000000..0e550648 --- /dev/null +++ b/docker-compose.ci.yml @@ -0,0 +1,7 @@ +services: + staging: + build: + cache_from: + - type=gha + cache_to: + - type=gha,mode=max \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index 68d80354..fe3f9a67 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -109,10 +109,6 @@ services: build: context: ./_site dockerfile: ../.github/scripts/staging/Dockerfile - cache_from: - - type=gha - cache_to: - - type=gha,mode=max ports: - 8080:80 healthcheck: