Skip to content

Commit

Permalink
Updates dockerfile
Browse files Browse the repository at this point in the history
  • Loading branch information
davidmerfield committed Jan 25, 2025
1 parent 9149c55 commit 9cc03ef
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 14 deletions.
18 changes: 7 additions & 11 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ COPY --from=builder /usr/local/bin/pandoc /usr/local/bin/pandoc
# Install git for good since the git client requires it
RUN apk add --no-cache git

# Install curl for good since the health check requires it
RUN apk add --no-cache curl

# configure git
RUN git config --global user.email "[email protected]"
RUN git config --global user.name "Your Name"
Expand All @@ -74,7 +77,6 @@ RUN git config --global user.name "Your Name"
# todo: work out how to fix this
RUN git config --global --add safe.directory '*'


# Install necessary packages for Puppeteer
RUN apk add --no-cache \
chromium \
Expand Down Expand Up @@ -136,13 +138,7 @@ FROM source AS prod
RUN node ./app/documentation/build/index.js --no-watch

HEALTHCHECK --interval=30s --timeout=5s --start-period=5s --retries=3 \
CMD node -e "\
const http = require('http'); \
const options = { hostname: 'localhost', port: 8080, path: '/health', timeout: 5000 }; \
const req = http.request(options, (res) => { \
if (res.statusCode === 200) process.exit(0); else process.exit(1); \
}); \
req.on('error', () => process.exit(1)); \
req.end();"

CMD ["node", "./app/index.js"]
CMD curl --fail http://localhost:8080/health || exit 1

# Redirect logs to a file
CMD ["sh", "-c", "node ./app/index.js >> ./data/logs/app.log 2>&1"]
13 changes: 12 additions & 1 deletion config/openresty/conf/blot-site.conf
Original file line number Diff line number Diff line change
@@ -1,8 +1,19 @@
# This is where we send server-sent events
# which need a long timeout
location = /status {
proxy_pass http://blot_node;
proxy_read_timeout 24h;
{{> reverse-proxy.conf}}
proxy_send_timeout 24h;
proxy_connect_timeout 24h;

# SSE-specific configurations
proxy_http_version 1.1; # SSE requires HTTP/1.1
proxy_set_header Connection ''; # Disable keep-alive
proxy_buffering off; # Disable response buffering
proxy_cache off; # Ensure no caching

# Failover behavior
proxy_next_upstream off; # Do not failover during SSE
}

location = /health {
Expand Down
3 changes: 2 additions & 1 deletion config/openresty/conf/reverse-proxy.conf
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,6 @@ gzip_comp_level 9;
gzip_proxied any;

proxy_redirect off;
proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504;
# this seems to cause openresty to mark upstream as down
# proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504;
proxy_connect_timeout 5s;
14 changes: 13 additions & 1 deletion config/openresty/conf/server.conf
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,19 @@ http {
{{> auto-ssl.conf}}

location / {
{{> reverse-proxy.conf}}
proxy_pass http://blot_node;
proxy_read_timeout 24h;
proxy_send_timeout 24h;
proxy_connect_timeout 24h;

# SSE-specific configurations
proxy_http_version 1.1; # SSE requires HTTP/1.1
proxy_set_header Connection ''; # Disable keep-alive
proxy_buffering off; # Disable response buffering
proxy_cache off; # Ensure no caching

# Failover behavior
proxy_next_upstream off; # Do not failover during SSE
}
}

Expand Down

0 comments on commit 9cc03ef

Please sign in to comment.