Question

Docker FastAPI Deploy Error: Health Checks, but I have /health route

I try to set up CD for my fastapi app using digital ocean app and digital ocean private container registry

My desired pipeline:

  1. Build docker with github actions when github receives a push to main branch
  2. Push docker to digital ocean private container registry
  3. Digital ocean app run deployment with new docker

I stuck at step 3, because I always get Deploy Error: Health Checks.
My Health check settings at digital ocean.
When I run my app locally

How I run my fastapi app:

poetry run uvicorn supa_dupa_api.main:app --port 8080 --host '::' --workers 1

Digital Ocean build logs:

Skipping virtualenv creation, as specified in config file.
INFO:     Started server process [3]
INFO:     Waiting for application startup.
INFO:     Application startup complete.
INFO:     Uvicorn running on http://[::]:8080 (Press CTRL+C to quit)

Please help me. How I can avoid this error? the service is working, but crashes after a few minutes due to this error

Additional information:

  • I tried default settings for health checks
  • I tried a different port

Dockerfile

FROM <MY_PRIVATE_IMAGE_WITH_PY_10_AND_POETRY>

ENV LANG=C.UTF-8 \
  LC_ALL=C.UTF-8 \
  PATH="${PATH}:/usr/local/bin:/root/.poetry/bin"

COPY . /workspace

RUN poetry install -n --without dev

EXPOSE 8080

CMD poetry run uvicorn coruscant.main:app --port 8080 --host '::' --workers 1


Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Hi there,

As far as I can see you are starting your service on port 8080 and also exposing that in your Dockerfile.

Have you tried to set that port in the App Platform heath check definition as well?

Best,

Bobby