Spaces:
Paused
Paused
icebear icebear0828 commited on
fix: Docker HEALTHCHECK reads port from config (#118) (#119)
Browse files* fix: Docker HEALTHCHECK reads port from config instead of hardcoded 8080 (#118)
HEALTHCHECK was hardcoded to localhost:8080. Users who changed
server.port in default.yaml (e.g. 8090) got an infinite restart loop
because the health check always failed.
Add docker-healthcheck.sh that parses port from config/default.yaml,
falling back to 8080 if unreadable.
* fix: remove unreachable exec in docker healthcheck script
---------
Co-authored-by: icebear0828 <icebear0828@users.noreply.github.com>
- Dockerfile +3 -2
- docker-healthcheck.sh +4 -0
Dockerfile
CHANGED
|
@@ -37,10 +37,11 @@ EXPOSE 8080
|
|
| 37 |
RUN mkdir -p /app/data
|
| 38 |
|
| 39 |
COPY docker-entrypoint.sh /
|
| 40 |
-
|
|
|
|
| 41 |
|
| 42 |
HEALTHCHECK --interval=30s --timeout=5s --start-period=10s --retries=3 \
|
| 43 |
-
CMD
|
| 44 |
|
| 45 |
ENTRYPOINT ["/docker-entrypoint.sh"]
|
| 46 |
CMD ["node", "dist/index.js"]
|
|
|
|
| 37 |
RUN mkdir -p /app/data
|
| 38 |
|
| 39 |
COPY docker-entrypoint.sh /
|
| 40 |
+
COPY docker-healthcheck.sh /
|
| 41 |
+
RUN chmod +x /docker-entrypoint.sh /docker-healthcheck.sh
|
| 42 |
|
| 43 |
HEALTHCHECK --interval=30s --timeout=5s --start-period=10s --retries=3 \
|
| 44 |
+
CMD /docker-healthcheck.sh
|
| 45 |
|
| 46 |
ENTRYPOINT ["/docker-entrypoint.sh"]
|
| 47 |
CMD ["node", "dist/index.js"]
|
docker-healthcheck.sh
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/sh
|
| 2 |
+
# Read server port from config, fallback to 8080
|
| 3 |
+
PORT=$(grep -A5 '^server:' /app/config/default.yaml 2>/dev/null | grep 'port:' | head -1 | awk '{print $2}')
|
| 4 |
+
curl -fs "http://localhost:${PORT:-8080}/health" || exit 1
|