Skip to content

Commit a3ab9da

Browse files
authoredJun 22, 2023
Dockerfile HEALTHCHECK (#171)
* `HEALTHCHECK` in the Dockerfile (relies on public access to the namespace document) nginx `depends_on` with `service_healthy` condition * `HEALTHCHECK` param adjustments * Increased `HEALTHCHECK` interval * Replaced the `atomgraph/nginx` Docker image with the official `nginx` Rewrote nginx's `command` using `sed` instead of `envsubst` * Reformatted placeholders in nginx.conf.template from $VAR to ${VAR}
1 parent b9376c0 commit a3ab9da

File tree

4 files changed

+26
-20
lines changed

4 files changed

+26
-20
lines changed
 

‎CHANGELOG.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@
22
### Added
33
- New Varnish proxy cache between nginx and LinkedDataHub (service `varnish-frontend`) in order to improve performance
44
- New `lapp:frontendProxy` and `lapp:backendProxy` properties in the LAPP ontology
5+
- `HEALTHCHECK` configuration in Dockerfile (relies on public access to the namespace document)
56

67
### Changed
7-
- Replaced the `atomgraph/varnish:6.0.11` Docker image with the official `varnish:7.3.0` image
88
- Fixed content drag and drop logic to only work in content mode and not affect dragging in map and graph modes
99
- When `ENABLE_LINKED_DATA_PROXY=false`, `?uri=` proxy requests will return `400 Bad Request` unless the URI is already cached or mapped to file
10+
- Replaced the `atomgraph/varnish:6.0.11` Docker image with the official `varnish:7.3.0` image
11+
- Replaced the `atomgraph/nginx:1.23.3` Docker image with the official `nginx:1.23.3` image
1012

1113
## [4.0.4] - 2023-06-07
1214
### Changed

‎Dockerfile

+3-2
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,6 @@ ENV GOOGLE_CLIENT_SECRET=
110110

111111
ENV GENERATE_SITEMAP=true
112112

113-
# HEALTHCHECK --start-period=80s CMD curl -f http://localhost:$HTTP_PORT || exit 1
114-
115113
# remove default Tomcat webapps and install xmlstarlet (used for XPath queries) and envsubst (for variable substitution)
116114

117115
RUN apt-get update --allow-releaseinfo-change && \
@@ -182,6 +180,9 @@ RUN useradd --no-log-init -U ldh && \
182180

183181
RUN ./import-letsencrypt-stg-roots.sh
184182

183+
HEALTHCHECK --start-period=80s --interval=60s --timeout=10s \
184+
CMD curl -f -I "http://localhost:${HTTP_PORT}/ns" -H "Accept: application/n-triples" || exit 1 # relies on public access to the namespace document
185+
185186
USER ldh
186187

187188
ENTRYPOINT ["/bin/bash", "entrypoint.sh"]

‎docker-compose.yml

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
version: "2.3"
22
services:
33
nginx:
4-
image: atomgraph/nginx:1.23.3
4+
image: nginx:1.23.3
55
mem_limit: 128m
6-
command: /bin/bash -c "envsubst '$$HTTPS_PORT $$UPSTREAM_SERVER $$UPSTREAM_HTTP_PORT $$SERVER_NAME $$SERVER_HTTPS_PORT $$SERVER_HTTP_PORT $$SERVER_CERT_FILE $$SERVER_KEY_FILE $$SSL_VERIFY_CLIENT $$MAX_BODY_SIZE $$SERVER_CLIENT_CERT_HTTPS_PORT' < /etc/nginx/nginx.conf.template > /etc/nginx/nginx.conf && nginx -g 'daemon off;'"
6+
command: /bin/sh -c "cp /etc/nginx/nginx.conf.template /etc/nginx/nginx.conf && sed -i 's|$${HTTPS_PORT}|'"$$HTTPS_PORT"'|g' /etc/nginx/nginx.conf && sed -i 's|$${UPSTREAM_SERVER}|'"$$UPSTREAM_SERVER"'|g' /etc/nginx/nginx.conf && sed -i 's|$${UPSTREAM_HTTP_PORT}|'"$$UPSTREAM_HTTP_PORT"'|g' /etc/nginx/nginx.conf && sed -i 's|$${SERVER_NAME}|'"$$SERVER_NAME"'|g' /etc/nginx/nginx.conf && sed -i 's|$${SERVER_HTTPS_PORT}|'"$$SERVER_HTTPS_PORT"'|g' /etc/nginx/nginx.conf && sed -i 's|$${SERVER_HTTP_PORT}|'"$$SERVER_HTTP_PORT"'|g' /etc/nginx/nginx.conf && sed -i 's|$${SERVER_CERT_FILE}|'"$$SERVER_CERT_FILE"'|g' /etc/nginx/nginx.conf && sed -i 's|$${SERVER_KEY_FILE}|'"$$SERVER_KEY_FILE"'|g' /etc/nginx/nginx.conf && sed -i 's|$${SSL_VERIFY_CLIENT}|'"$$SSL_VERIFY_CLIENT"'|g' /etc/nginx/nginx.conf && sed -i 's|$${MAX_BODY_SIZE}|'"$$MAX_BODY_SIZE"'|g' /etc/nginx/nginx.conf && sed -i 's|$${SERVER_CLIENT_CERT_HTTPS_PORT}|'"$$SERVER_CLIENT_CERT_HTTPS_PORT"'|g' /etc/nginx/nginx.conf && nginx -g 'daemon off;'"
7+
depends_on:
8+
linkeddatahub:
9+
condition: service_healthy
710
ports:
811
- ${HTTP_PORT}:8080 # allow Tomcat to do HTTP to HTTPS redirect
912
- ${HTTPS_PORT}:8443 # HTTPS

‎platform/nginx.conf.template

+15-15
Original file line numberDiff line numberDiff line change
@@ -6,24 +6,24 @@ events {
66

77
http {
88
upstream linkeddatahub {
9-
server $UPSTREAM_SERVER:$UPSTREAM_HTTP_PORT;
9+
server ${UPSTREAM_SERVER}:${UPSTREAM_HTTP_PORT};
1010
}
1111

1212
limit_req_zone $binary_remote_addr zone=linked_data:10m rate=6r/s;
1313
limit_req_zone $binary_remote_addr zone=static_files:10m rate=20r/s;
1414
limit_req_status 429;
1515

16-
client_max_body_size $MAX_BODY_SIZE;
16+
client_max_body_size ${MAX_BODY_SIZE};
1717

1818
# server with optional client cert authentication (depends on the $SSL_VERIFY_CLIENT value)
1919
server {
20-
listen $SERVER_HTTPS_PORT ssl;
21-
server_name $SERVER_NAME;
22-
ssl_certificate $SERVER_CERT_FILE;
23-
ssl_certificate_key $SERVER_KEY_FILE;
24-
ssl_session_cache shared:SSL:1m;
20+
listen ${SERVER_HTTPS_PORT} ssl;
21+
server_name ${SERVER_NAME};
22+
ssl_certificate ${SERVER_CERT_FILE};
23+
ssl_certificate_key ${SERVER_KEY_FILE};
24+
ssl_session_cache shared:SSL:1m;
2525
ssl_prefer_server_ciphers on;
26-
ssl_verify_client $SSL_VERIFY_CLIENT;
26+
ssl_verify_client ${SSL_VERIFY_CLIENT};
2727

2828
location / {
2929
proxy_pass http://linkeddatahub;
@@ -56,10 +56,10 @@ http {
5656

5757
# server with client cert authentication on
5858
server {
59-
listen $SERVER_CLIENT_CERT_HTTPS_PORT ssl;
60-
server_name $SERVER_NAME;
61-
ssl_certificate $SERVER_CERT_FILE;
62-
ssl_certificate_key $SERVER_KEY_FILE;
59+
listen ${SERVER_CLIENT_CERT_HTTPS_PORT} ssl;
60+
server_name ${SERVER_NAME};
61+
ssl_certificate ${SERVER_CERT_FILE};
62+
ssl_certificate_key ${SERVER_KEY_FILE};
6363
ssl_session_cache shared:SSL:1m;
6464
ssl_prefer_server_ciphers on;
6565
ssl_verify_client optional_no_ca;
@@ -80,11 +80,11 @@ http {
8080
}
8181

8282
server {
83-
listen $SERVER_HTTP_PORT;
84-
server_name $SERVER_NAME;
83+
listen ${SERVER_HTTP_PORT};
84+
server_name ${SERVER_NAME};
8585

8686
location / {
87-
return 301 https://$server_name:$HTTPS_PORT$request_uri;
87+
return 301 https://$server_name:${HTTPS_PORT}$request_uri;
8888
}
8989
}
9090

0 commit comments

Comments
 (0)
Please sign in to comment.