Skip to content

Commit

Permalink
Introduce Nginx and Github Actions (#2)
Browse files Browse the repository at this point in the history
  • Loading branch information
pricem14pc authored Mar 3, 2022
1 parent 765189d commit 9de5158
Show file tree
Hide file tree
Showing 6 changed files with 84 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
### What is the context of this PR?
Describe what you have changed and why, link to other PRs or Issues as appropriate.

### How to review
Describe the steps required to test the changes (include screenshots if appropriate).
29 changes: 29 additions & 0 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: PR

on:
pull_request:
branches:
- master

jobs:

docker-push:
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@v2
- name: Set Tag and SHA
run: |
CLEAN_TAG=$(echo "${{ github.event.pull_request.head.ref }}" | tr / -)
echo "TAG=$CLEAN_TAG" >> $GITHUB_ENV
echo "SHA=${{ github.event.pull_request.head.sha }}" >> $GITHUB_ENV
- name: Build
run: >
docker build -t ${{ secrets.GAR_LOCATION }}/${{ secrets.GAR_PROJECT_ID }}/docker-images/eq-runner-maintenance-page:$TAG .
- name: Push to GAR
env:
GAR_SERVICE_KEY: ${{ secrets.GAR_SERVICE_KEY }}
run: |
echo $GAR_SERVICE_KEY | docker login -u _json_key --password-stdin https://${{ secrets.GAR_LOCATION }}
gcloud auth configure-docker ${{ secrets.GAR_LOCATION }}
echo "Pushing to GAR with tag $TAG"
docker push ${{ secrets.GAR_LOCATION }}/${{ secrets.GAR_PROJECT_ID }}/docker-images/eq-runner-maintenance-page:$TAG
3 changes: 3 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
FROM nginx
COPY static-html /usr/share/nginx/html
COPY nginx/conf.d/default.conf /etc/nginx/conf.d/
27 changes: 26 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,27 @@
# eq-runner-maintenance-page
Repo for EQ Questionnaire runner maintenance page
This repo provides a static maintenance page for the EQ Questionnaire Runner application.

The page at `static-html/service.html` is intended to be served to users when the Runner application is unavailable.

This repo is not responsible for the provisioning or deployment of the page.

## Web server
While the `service.html` maintenance page can be deployed directly to a backend location (to be served from there by a CDN for example) this repo also provides an [Nginx](https://nginx.org/) web server Docker container, with a basic configuration to return the maintenance page for all requests it serves. The container can be deployed to a run time replacing the EQ Runner application.

## Build image locally
```
docker build -t runner-maintenance-page .
```

## Run container locally
```
docker run -it --rm -d -p 5000:5000 --name runner-maintenance-page runner-maintenance-page
```

Requested routes at `http://localhost:5000/` will be served with the maintenance page.

The route at `http://localhost:5000/status` will return an appropriate status response intending to serve as an indication that the Runner application is unavailable on that URL.

```
docker stop runner-maintenance-page
```
21 changes: 21 additions & 0 deletions nginx/conf.d/default.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
server {
listen 5000 default;
server_name _;
server_tokens off;

if ($http_x_forwarded_proto = "http") {
return 301 https://$host$request_uri;
}

location /status {
default_type application/json;
return 200 '{"status": "Unavailable"}';
}

location / {
root /usr/share/nginx/html;
index service.html;
}

error_page 404 500 502 503 504 /service.html;
}
File renamed without changes.

0 comments on commit 9de5158

Please sign in to comment.