Skip to content

Commit

Permalink
Nginx Healthcheck endpoint + Dockerfile healthcheck (#23)
Browse files Browse the repository at this point in the history
Co-authored-by: modem7 <[email protected]>
  • Loading branch information
tarampampam and modem7 authored Sep 6, 2021
1 parent 501d141 commit ce98410
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,15 @@ All notable changes to this package will be documented in this file.

The format is based on [Keep a Changelog][keepachangelog] and this project adheres to [Semantic Versioning][semver].

## v1.8.0

### Added

- Nginx health-check endpoint (`/health/live`) and dockerfile `HEALTHCHECK` to utilise (thx [@modem7](https://github.com/modem7)) [#22], [#23]

[#22]:https://github.com/tarampampam/error-pages/pull/22
[#23]:https://github.com/tarampampam/error-pages/pull/23

## v1.7.2

### Changed
Expand Down
7 changes: 6 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ RUN set -x \
&& mv /src/docker/nginx-server.conf ./etc/nginx/conf.d/default.conf

# Image page: <https://hub.docker.com/_/nginx>
FROM nginx:1.21-alpine as runtime
FROM nginx:1.21.1-alpine as runtime

LABEL \
# Docs: <https://github.com/opencontainers/image-spec/blob/master/annotations.md>
Expand All @@ -44,4 +44,9 @@ LABEL \
# Import from builder
COPY --from=builder /tmp/rootfs /

# Docs: <https://docs.docker.com/engine/reference/builder/#healthcheck>
HEALTHCHECK --interval=15s --timeout=2s --retries=2 --start-period=2s CMD [ \
"wget", "--spider", "-q", "http://127.0.0.1:8080/health/live" \
]

RUN chown -R nginx:nginx /opt/html
7 changes: 7 additions & 0 deletions docker/nginx-server.conf
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,13 @@ server {
root /opt/html;
}

# Health-check (liveness probe)
location = /health/live {
access_log off;
default_type text/plain;
return 200 "healthy\n";
}

location / {
try_files $uri =404;
}
Expand Down

0 comments on commit ce98410

Please sign in to comment.