Skip to content

Commit

Permalink
Health endpoint exposed by nginx
Browse files Browse the repository at this point in the history
  • Loading branch information
ljones140 committed Oct 30, 2024
1 parent 65a35a0 commit e97694a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
11 changes: 9 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,14 @@ 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
9 changes: 3 additions & 6 deletions nginx.conf → default.conf.template
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,9 @@ server {
etag off;
}

location /nginx_health {
set_by_lua $app_version 'return os.getenv("APP_VERSION")';
set_by_lua $build_sha 'return os.getenv("BUILD_SHA")';

default_type application/json;
return 200 '{"status":"OK", "version": "$app_version", "sha": "$build_sha"}';
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
Expand Down

0 comments on commit e97694a

Please sign in to comment.