diff --git a/Dockerfile b/Dockerfile index af8008b..1b2887e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -16,6 +16,8 @@ COPY . ./ RUN chmod +x bash/run-prod.sh CMD bash/run-prod.sh +HEALTHCHECK CMD ["pipenv", "run", "python", "healthcheck.py"] + ENV DATABASE_URL postgres://postgresql:postgresql@db:5432/manuels ENV SECRET_KEY '' ENV MAILGUN_ACCESS_KEY '' diff --git a/healthcheck.py b/healthcheck.py new file mode 100644 index 0000000..3fef69b --- /dev/null +++ b/healthcheck.py @@ -0,0 +1,15 @@ +import os +import sys + +import requests + + +def main(): + port = os.getenv('PORT', 8000) + res = requests.get(f'http://localhost:{port}/') + if res.status_code >= 400: + sys.exit(1) + + +if __name__ == '__main__': + main()