Skip to content

Commit

Permalink
Merge pull request #1068 from clearlydefined/ljones140/nginx-health
Browse files Browse the repository at this point in the history
Add health endpoint via nginx
  • Loading branch information
ljones140 authored Oct 31, 2024
2 parents 654d7fc + 813365f commit bb31409
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build-and-deploy-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
build-and-deploy:
name: Build and Deploy
needs: [upload-package-lock-json, make-react-secret-available]
uses: clearlydefined/operations/.github/workflows/app-build-and-deploy.yml@v2.0.0
uses: clearlydefined/operations/.github/workflows/app-build-and-deploy.yml@v3.1.2
secrets:
AZURE_CREDENTIALS: ${{ secrets.AZURE_CREDENTIALS }}
AZURE_WEBAPP_PUBLISH_PROFILE: ${{ secrets.AZURE_WEBAPP_PUBLISH_PROFILE_DEV }}
Expand Down
18 changes: 16 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,28 @@
FROM node:14-alpine as builder
COPY . /opt/website
WORKDIR /opt/website

# Set environment variables from build arguments
ARG APP_VERSION="UNKNOWN"
ENV APP_VERSION=$APP_VERSION
ARG BUILD_SHA="UNKNOWN"
ENV BUILD_SHA=$BUILD_SHA

ARG REACT_APP_SERVER=http://localhost:4000
ARG REACT_APP_GA_TRACKINGID
RUN apk add --no-cache git
RUN npm install -g npm@9
RUN npm install
RUN npm run build

FROM nginx:alpine
ADD nginx.conf /etc/nginx/conf.d/default.conf
FROM nginx:1.19.6-alpine

ARG APP_VERSION="UNKNOWN"
ENV APP_VERSION=$APP_VERSION
ARG BUILD_SHA="UNKNOWN"
ENV BUILD_SHA=$BUILD_SHA

RUN mkdir /etc/nginx/templates
COPY default.conf.template /etc/nginx/templates
COPY --from=builder /opt/website/build /usr/share/nginx/html
EXPOSE 80
5 changes: 5 additions & 0 deletions nginx.conf → default.conf.template
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ server {
etag off;
}

location /health {
add_header 'Content-Type' 'application/json';
return 200 '{"status":"OK", "version": "${APP_VERSION}", "sha": "${BUILD_SHA}"}';
}

# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
Expand Down

0 comments on commit bb31409

Please sign in to comment.