Skip to content

Commit bb31409

Browse files
authored
Merge pull request #1068 from clearlydefined/ljones140/nginx-health
Add health endpoint via nginx
2 parents 654d7fc + 813365f commit bb31409

File tree

3 files changed

+22
-3
lines changed

3 files changed

+22
-3
lines changed

.github/workflows/build-and-deploy-dev.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ jobs:
3333
build-and-deploy:
3434
name: Build and Deploy
3535
needs: [upload-package-lock-json, make-react-secret-available]
36-
uses: clearlydefined/operations/.github/workflows/app-build-and-deploy.yml@v2.0.0
36+
uses: clearlydefined/operations/.github/workflows/app-build-and-deploy.yml@v3.1.2
3737
secrets:
3838
AZURE_CREDENTIALS: ${{ secrets.AZURE_CREDENTIALS }}
3939
AZURE_WEBAPP_PUBLISH_PROFILE: ${{ secrets.AZURE_WEBAPP_PUBLISH_PROFILE_DEV }}

Dockerfile

+16-2
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,28 @@
33
FROM node:14-alpine as builder
44
COPY . /opt/website
55
WORKDIR /opt/website
6+
7+
# Set environment variables from build arguments
8+
ARG APP_VERSION="UNKNOWN"
9+
ENV APP_VERSION=$APP_VERSION
10+
ARG BUILD_SHA="UNKNOWN"
11+
ENV BUILD_SHA=$BUILD_SHA
12+
613
ARG REACT_APP_SERVER=http://localhost:4000
714
ARG REACT_APP_GA_TRACKINGID
815
RUN apk add --no-cache git
916
RUN npm install -g npm@9
1017
RUN npm install
1118
RUN npm run build
1219

13-
FROM nginx:alpine
14-
ADD nginx.conf /etc/nginx/conf.d/default.conf
20+
FROM nginx:1.19.6-alpine
21+
22+
ARG APP_VERSION="UNKNOWN"
23+
ENV APP_VERSION=$APP_VERSION
24+
ARG BUILD_SHA="UNKNOWN"
25+
ENV BUILD_SHA=$BUILD_SHA
26+
27+
RUN mkdir /etc/nginx/templates
28+
COPY default.conf.template /etc/nginx/templates
1529
COPY --from=builder /opt/website/build /usr/share/nginx/html
1630
EXPOSE 80

nginx.conf default.conf.template

+5
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@ server {
1212
etag off;
1313
}
1414

15+
location /health {
16+
add_header 'Content-Type' 'application/json';
17+
return 200 '{"status":"OK", "version": "${APP_VERSION}", "sha": "${BUILD_SHA}"}';
18+
}
19+
1520
# redirect server error pages to the static page /50x.html
1621
#
1722
error_page 500 502 503 504 /50x.html;

0 commit comments

Comments
 (0)