Skip to content

Commit 1b6a944

Browse files
authored
Merge pull request #236 from orionrobots/copilot/fix-235
Consolidate Dockerfile stages: combine staging and httpd_serve
2 parents 162b2b2 + dcef766 commit 1b6a944

File tree

5 files changed

+42
-14
lines changed

5 files changed

+42
-14
lines changed

.github/scripts/staging/Dockerfile

Lines changed: 0 additions & 9 deletions
This file was deleted.

.github/workflows/on_call_staging_test.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ jobs:
2222
run: |
2323
# Copy staging files into the _site directory for the docker build
2424
cp .github/scripts/staging/default.conf _site/httpd.conf
25+
# Also copy default.conf for the consolidated Dockerfile to support fallback
26+
cp .github/scripts/staging/default.conf _site/default.conf
2527
2628
- name: Run as service and test
2729
run: |

Dockerfile

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,26 @@ FROM httpd:2.4.64 AS httpd_serve
2424
# Install curl for healthcheck
2525
RUN apt-get update && apt-get install -y curl && rm -rf /var/lib/apt/lists/*
2626

27-
# COPY _site /var/www/html/
28-
COPY .github/scripts/staging/default.conf /usr/local/apache2/conf/httpd.conf
27+
# Copy Apache configuration - flexible approach for both contexts
28+
# For staging: httpd.conf will be in the build context
29+
# For development: default.conf will be sourced from .github/scripts/staging/
30+
COPY . /tmp/build_context/
31+
RUN if [ -f /tmp/build_context/httpd.conf ]; then \
32+
echo "Using httpd.conf for staging configuration"; \
33+
cp /tmp/build_context/httpd.conf /usr/local/apache2/conf/httpd.conf; \
34+
elif [ -f /tmp/build_context/default.conf ]; then \
35+
echo "Using default.conf from build context"; \
36+
cp /tmp/build_context/default.conf /usr/local/apache2/conf/httpd.conf; \
37+
elif [ -f /tmp/build_context/.github/scripts/staging/default.conf ]; then \
38+
echo "Using default.conf from .github/scripts/staging/"; \
39+
cp /tmp/build_context/.github/scripts/staging/default.conf /usr/local/apache2/conf/httpd.conf; \
40+
else \
41+
echo "ERROR: No configuration file found"; \
42+
exit 1; \
43+
fi
44+
45+
# Copy site content to web directory
46+
COPY . /usr/local/apache2/htdocs/
2947

3048
FROM base AS tests
3149

README.md

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,11 +103,27 @@ orionrobotsgithubio-web-1 | ruby 3.1.1p18 (2022-02-18 revision 53f5fc4236) [x86
103103

104104
## Staging Test Environment
105105

106-
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:
106+
The staging test environment uses Docker Compose to run the built site with Apache configuration that mirrors the hosting environment. This environment:
107107

108108
- Tests the site with Apache configuration that mirrors the hosting environment
109-
- Validates that htaccess rules work correctly
109+
- Validates that htaccess rules work correctly
110110
- Ensures the site serves properly before deployment
111111

112+
### Running the Staging Environment
113+
114+
To run the staging environment locally using Docker Compose:
115+
116+
```bash
117+
# Build the site first (if not already built)
118+
docker compose up --build dist
119+
120+
# Start the staging service
121+
docker compose up --build staging
122+
```
123+
124+
The staging service will be available at http://localhost:8080
125+
126+
The staging environment automatically uses the consolidated `httpd_serve` Docker stage from the main Dockerfile, ensuring consistency between development and CI/CD environments.
127+
112128
The staging tests run automatically in CI/CD workflows when changes are pushed to the master branch or in pull requests.
113129

docker-compose.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,8 @@ services:
108108
staging:
109109
build:
110110
context: ./_site
111-
dockerfile: ../.github/scripts/staging/Dockerfile
111+
dockerfile: ../Dockerfile
112+
target: httpd_serve
112113
ports:
113114
- 8080:80
114115
healthcheck:

0 commit comments

Comments
 (0)