From d366d5907541e5cc5a4d4dcc44bbb7fdef85c9db Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 4 Aug 2025 13:57:14 +0000 Subject: [PATCH 1/2] Initial plan From dcef766f97dcd26bac0df368417ab4555ae77e0e Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 4 Aug 2025 14:12:02 +0000 Subject: [PATCH 2/2] Consolidate Dockerfile stages: combine staging and httpd_serve Co-authored-by: dannystaple <426859+dannystaple@users.noreply.github.com> --- .github/scripts/staging/Dockerfile | 9 --------- .github/workflows/on_call_staging_test.yaml | 2 ++ Dockerfile | 22 +++++++++++++++++++-- README.md | 20 +++++++++++++++++-- docker-compose.yml | 3 ++- 5 files changed, 42 insertions(+), 14 deletions(-) delete mode 100644 .github/scripts/staging/Dockerfile diff --git a/.github/scripts/staging/Dockerfile b/.github/scripts/staging/Dockerfile deleted file mode 100644 index be9e47c5..00000000 --- a/.github/scripts/staging/Dockerfile +++ /dev/null @@ -1,9 +0,0 @@ -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 2881a017..c8dd519f 100644 --- a/.github/workflows/on_call_staging_test.yaml +++ b/.github/workflows/on_call_staging_test.yaml @@ -22,6 +22,8 @@ jobs: run: | # Copy staging files into the _site directory for the docker build cp .github/scripts/staging/default.conf _site/httpd.conf + # Also copy default.conf for the consolidated Dockerfile to support fallback + cp .github/scripts/staging/default.conf _site/default.conf - name: Run as service and test run: | diff --git a/Dockerfile b/Dockerfile index 5bf2e04f..e5693d90 100644 --- a/Dockerfile +++ b/Dockerfile @@ -24,8 +24,26 @@ FROM httpd:2.4.64 AS httpd_serve # Install curl for healthcheck RUN apt-get update && apt-get install -y curl && rm -rf /var/lib/apt/lists/* -# COPY _site /var/www/html/ -COPY .github/scripts/staging/default.conf /usr/local/apache2/conf/httpd.conf +# Copy Apache configuration - flexible approach for both contexts +# For staging: httpd.conf will be in the build context +# For development: default.conf will be sourced from .github/scripts/staging/ +COPY . /tmp/build_context/ +RUN if [ -f /tmp/build_context/httpd.conf ]; then \ + echo "Using httpd.conf for staging configuration"; \ + cp /tmp/build_context/httpd.conf /usr/local/apache2/conf/httpd.conf; \ + elif [ -f /tmp/build_context/default.conf ]; then \ + echo "Using default.conf from build context"; \ + cp /tmp/build_context/default.conf /usr/local/apache2/conf/httpd.conf; \ + elif [ -f /tmp/build_context/.github/scripts/staging/default.conf ]; then \ + echo "Using default.conf from .github/scripts/staging/"; \ + cp /tmp/build_context/.github/scripts/staging/default.conf /usr/local/apache2/conf/httpd.conf; \ + else \ + echo "ERROR: No configuration file found"; \ + exit 1; \ + fi + +# Copy site content to web directory +COPY . /usr/local/apache2/htdocs/ FROM base AS tests diff --git a/README.md b/README.md index 137956db..36704c33 100644 --- a/README.md +++ b/README.md @@ -103,11 +103,27 @@ orionrobotsgithubio-web-1 | ruby 3.1.1p18 (2022-02-18 revision 53f5fc4236) [x86 ## Staging Test Environment -The staging test environment is located in `.github/scripts/staging/` and contains Docker configuration files used for testing the built site before deployment. This environment: +The staging test environment uses Docker Compose to run the built site with Apache configuration that mirrors the hosting environment. This environment: - Tests the site with Apache configuration that mirrors the hosting environment -- Validates that htaccess rules work correctly +- Validates that htaccess rules work correctly - Ensures the site serves properly before deployment +### Running the Staging Environment + +To run the staging environment locally using Docker Compose: + +```bash +# Build the site first (if not already built) +docker compose up --build dist + +# Start the staging service +docker compose up --build staging +``` + +The staging service will be available at http://localhost:8080 + +The staging environment automatically uses the consolidated `httpd_serve` Docker stage from the main Dockerfile, ensuring consistency between development and CI/CD environments. + The staging tests run automatically in CI/CD workflows when changes are pushed to the master branch or in pull requests. diff --git a/docker-compose.yml b/docker-compose.yml index 25ad2aba..4af0caa0 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -108,7 +108,8 @@ services: staging: build: context: ./_site - dockerfile: ../.github/scripts/staging/Dockerfile + dockerfile: ../Dockerfile + target: httpd_serve ports: - 8080:80 healthcheck: