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

Nginx Healthcheck endpoint + Dockerfile healthcheck #23

Merged
merged 4 commits into from
Sep 6, 2021
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
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