Add healthcheck

This commit is contained in:
Ryan W
2023-09-30 11:46:38 -07:00
parent 16cec22850
commit 0c592efa51
2 changed files with 5 additions and 2 deletions
+2 -2
View File
@@ -49,8 +49,8 @@ jobs:
- name: Check Health - name: Check Health
run: | run: |
HEALTH_STATUS=$(docker inspect --format='{{.State.Status}}' rails-on-docker); HEALTH_STATUS=$(docker inspect --format='{{.State.Health}}' rails-on-docker);
echo "$HEALTH_STATUS" echo "$HEALTH_STATUS"
if [ "$HEALTH_STATUS" != "running" ]; then if [ "$HEALTH_STATUS" != "healthy" ]; then
exit 1 exit 1
fi fi
+3
View File
@@ -78,6 +78,9 @@ USER rails:rails
# Entrypoint prepares the database. # Entrypoint prepares the database.
ENTRYPOINT ["/rails/bin/docker-entrypoint-production"] ENTRYPOINT ["/rails/bin/docker-entrypoint-production"]
HEALTHCHECK --interval=5m --timeout=3s --start-period=30s \
CMD curl -f http://localhost:3000/up || exit 1
# Start the server by default, this can be overwritten at runtime # Start the server by default, this can be overwritten at runtime
EXPOSE 3000 EXPOSE 3000
CMD ["./bin/rails", "server"] CMD ["./bin/rails", "server"]