Skip to content
This repository was archived by the owner on Jan 11, 2025. It is now read-only.

Commit b4ca313

Browse files
added healthchecks in dockerfile
1 parent fde8c89 commit b4ca313

File tree

58 files changed

+155
-1
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+155
-1
lines changed

README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,11 @@ configure arguments: --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --modules-p
107107
## Run Container
108108

109109
```sh
110-
docker run -it --rm -p 80:80 fabiocicerchia/nginx-lua
110+
docker run -it --rm -p 80:80 \
111+
--health-cmd='curl --fail http://example.com || exit 1' \
112+
--health-interval=30s \
113+
--health-timeout=3s \
114+
fabiocicerchia/nginx-lua:latest
111115
```
112116

113117
## Example

nginx/1.17.10/alpine/3.10.5/Dockerfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,8 @@ RUN set -x \
187187
&& rm -rf /ngx_devel_kit-${VER_NGX_DEVEL_KIT} \
188188
&& apk del .build-deps .nginx-build-deps
189189

190+
HEALTHCHECK --interval=30s --timeout=3s CMD curl --fail http://localhost/ || exit 1
191+
190192
EXPOSE 80
191193
EXPOSE 443
192194

nginx/1.17.10/alpine/3.11.6/Dockerfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,8 @@ RUN set -x \
187187
&& rm -rf /ngx_devel_kit-${VER_NGX_DEVEL_KIT} \
188188
&& apk del .build-deps .nginx-build-deps
189189

190+
HEALTHCHECK --interval=30s --timeout=3s CMD curl --fail http://localhost/ || exit 1
191+
190192
EXPOSE 80
191193
EXPOSE 443
192194

nginx/1.17.10/alpine/3.12.0/Dockerfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,8 @@ RUN set -x \
187187
&& rm -rf /ngx_devel_kit-${VER_NGX_DEVEL_KIT} \
188188
&& apk del .build-deps .nginx-build-deps
189189

190+
HEALTHCHECK --interval=30s --timeout=3s CMD curl --fail http://localhost/ || exit 1
191+
190192
EXPOSE 80
191193
EXPOSE 443
192194

nginx/1.17.10/amazonlinux/2.0.20200406.0/Dockerfile

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ RUN set -x \
5252
openssl-devel \
5353
pcre-devel \
5454
zlib-devel \
55+
shadow-utils \
5556
&& yum install -y \
5657
gcc-c++ \
5758
gzip \
@@ -92,6 +93,10 @@ RUN set -x \
9293
&& tar xvzf /lua-nginx.tar.gz && rm /lua-nginx.tar.gz \
9394
# NGINX
9495
# ##############################################################################
96+
# create nginx user/group first, to be consistent throughout docker variants
97+
&& addgroup -g 1001 -S nginx \
98+
&& adduser -S -D -H -u 1001 -h /var/cache/nginx -s /sbin/nologin -G nginx -g nginx nginx \
99+
&& yum makecache \
95100
# we're on an architecture upstream doesn't officially build for
96101
# let's build binaries from the published packaging sources
97102
&& wget https://nginx.org/download/nginx-${VER_NGINX}.tar.gz -O /nginx.tar.gz \
@@ -166,6 +171,7 @@ RUN set -x \
166171
&& rm -rf /luajit2-${VER_LUAJIT} \
167172
&& rm -rf /nginx-${VER_NGINX} \
168173
&& rm -rf /ngx_devel_kit-${VER_NGX_DEVEL_KIT} \
174+
&& yum clean all \
169175
&& yum remove -y \
170176
gcc-c++ \
171177
gzip \
@@ -179,6 +185,8 @@ RUN set -x \
179185
tar \
180186
wget
181187

188+
HEALTHCHECK --interval=30s --timeout=3s CMD curl --fail http://localhost/ || exit 1
189+
182190
EXPOSE 80
183191
EXPOSE 443
184192

nginx/1.17.10/amazonlinux/2018.03.0.20200318.1/Dockerfile

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ RUN set -x \
5252
openssl-devel \
5353
pcre-devel \
5454
zlib-devel \
55+
shadow-utils \
5556
&& yum install -y \
5657
gcc-c++ \
5758
gzip \
@@ -92,6 +93,10 @@ RUN set -x \
9293
&& tar xvzf /lua-nginx.tar.gz && rm /lua-nginx.tar.gz \
9394
# NGINX
9495
# ##############################################################################
96+
# create nginx user/group first, to be consistent throughout docker variants
97+
&& addgroup -g 1001 -S nginx \
98+
&& adduser -S -D -H -u 1001 -h /var/cache/nginx -s /sbin/nologin -G nginx -g nginx nginx \
99+
&& yum makecache \
95100
# we're on an architecture upstream doesn't officially build for
96101
# let's build binaries from the published packaging sources
97102
&& wget https://nginx.org/download/nginx-${VER_NGINX}.tar.gz -O /nginx.tar.gz \
@@ -166,6 +171,7 @@ RUN set -x \
166171
&& rm -rf /luajit2-${VER_LUAJIT} \
167172
&& rm -rf /nginx-${VER_NGINX} \
168173
&& rm -rf /ngx_devel_kit-${VER_NGX_DEVEL_KIT} \
174+
&& yum clean all \
169175
&& yum remove -y \
170176
gcc-c++ \
171177
gzip \
@@ -179,6 +185,8 @@ RUN set -x \
179185
tar \
180186
wget
181187

188+
HEALTHCHECK --interval=30s --timeout=3s CMD curl --fail http://localhost/ || exit 1
189+
182190
EXPOSE 80
183191
EXPOSE 443
184192

nginx/1.17.10/centos/6.10/Dockerfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,8 @@ RUN set -x \
181181
make \
182182
wget
183183

184+
HEALTHCHECK --interval=30s --timeout=3s CMD curl --fail http://localhost/ || exit 1
185+
184186
EXPOSE 80
185187
EXPOSE 443
186188

nginx/1.17.10/centos/7.8.2003/Dockerfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,8 @@ RUN set -x \
181181
make \
182182
wget
183183

184+
HEALTHCHECK --interval=30s --timeout=3s CMD curl --fail http://localhost/ || exit 1
185+
184186
EXPOSE 80
185187
EXPOSE 443
186188

nginx/1.17.10/centos/8.2.2004/Dockerfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,8 @@ RUN set -x \
181181
make \
182182
wget
183183

184+
HEALTHCHECK --interval=30s --timeout=3s CMD curl --fail http://localhost/ || exit 1
185+
184186
EXPOSE 80
185187
EXPOSE 443
186188

nginx/1.17.10/debian/10.4-slim/Dockerfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,8 @@ RUN set -x \
176176
wget \
177177
&& rm -rf /var/lib/apt/lists/*
178178

179+
HEALTHCHECK --interval=30s --timeout=3s CMD curl --fail http://localhost/ || exit 1
180+
179181
EXPOSE 80
180182
EXPOSE 443
181183

0 commit comments

Comments
 (0)