diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 0000000..872d267 --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -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). \ No newline at end of file diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml new file mode 100644 index 0000000..e7ad09f --- /dev/null +++ b/.github/workflows/pull_request.yml @@ -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 diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..09dcc57 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,3 @@ +FROM nginx +COPY static-html /usr/share/nginx/html +COPY nginx/conf.d/default.conf /etc/nginx/conf.d/ diff --git a/README.md b/README.md index c23affe..158cbd1 100644 --- a/README.md +++ b/README.md @@ -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 +``` \ No newline at end of file diff --git a/nginx/conf.d/default.conf b/nginx/conf.d/default.conf new file mode 100644 index 0000000..7556471 --- /dev/null +++ b/nginx/conf.d/default.conf @@ -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; +} diff --git a/service.html b/static-html/service.html similarity index 100% rename from service.html rename to static-html/service.html