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.

Bobby Iliev
Site Moderator
Site Moderator badge
October 24, 2022

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

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

card icon
Get our biweekly newsletter

Sign up for Infrastructure as a Newsletter.

Sign up
card icon
Hollie's Hub for Good

Working on improving health and education, reducing inequality, and spurring economic growth? We’d like to help.

Learn more
card icon
Become a contributor

You get paid; we donate to tech nonprofits.

Learn more
Welcome to the developer cloud

DigitalOcean makes it simple to launch in the cloud and scale up as you grow – whether you’re running one virtual machine or ten thousand.

Learn more ->
DigitalOcean Cloud Control Panel
Get started for free

Enter your email to get $200 in credit for your first 60 days with DigitalOcean.

New accounts only. By submitting your email you agree to our Privacy Policy.

© 2023 DigitalOcean, LLC.