Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add health endpoint via nginx #1068

Merged
merged 4 commits into from
Oct 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading