FastAPI/Poetry Docker Deployment on Digital Ocean

I have a FastAPI Project that I am trying to deploy on Digital Ocean’s App Platform. I am using a base CPU instance, which is not the issue because I have tested on larger images with more RAM and CPUs.

I have a Dockerfile for my FastAPI app, that builds and runs successfully on my local machine (MacBook Pro M3 Pro), but when I attmept to deploy via Github/Dockerfile on the App Platform I keep getting two errors:

Deploy Error: Container Terminated & Deploy Error: Health Checks

There seems to be an issue when the Docker container spins up in that my project is not installed properly or referenced correctly, becuase when I want to use any modules that import components form the package itself (i.e humblapi.core.config import Config) the container seems to hang. It seems the conaitner will deploy successfully if I just have one file as my FastAPI app, but not when importing modules form the package. I have seen an error message that the humblapi package was not installed (when I wasn’t using --no-root) and also /app/src/humblapi does not contain any element.

How do I get poetry to install properly or get my container to run?

Attempts

I have tried using poetry install --no-root to avoid installing the package itself, which hasn’t worked.
I have tried changing the [tool.poetry] to include packages = [{ include = "humblapi", from = "src" },], this did not work.

I have tried doing the suggested pip install from FastAPI docs, that didn’t work.

The deployment is only successful when I do not include any humblapi imports.

Do you know if I can only use relative imports for Digital Ocean? I am confused because my local Dockerfile container runs perfectly.

The lastest attempt of trying to deploy the pip-install` branch has this error. It starts up, but then collapses and quits.

Resources

I am using docker build -t humblapi . & docker run --rm -p 8080:8080 humblapi

poetry install –no-root (runs locally)

FROM python:3.11-slim

WORKDIR /app

# Install system dependencies
RUN apt-get update && apt-get install -y 
    gcc 
    g++ 
    curl 
    pkg-config 
    libssl-dev 
    libgtk-3-dev 
    libsoup2.4-dev 
    libjavascriptcoregtk-4.0-dev 
    libwebkit2gtk-4.0-dev 
    && rm -rf /var/lib/apt/lists/*

# Install Rust
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
ENV PATH="/root/.cargo/bin:${PATH}"

# Copy project files
COPY pyproject.toml poetry.lock* README.md /app/

# Install dependencies without pywry
RUN pip install poetry && 
    poetry config virtualenvs.create false && 
    poetry install --no-dev --no-interaction --no-ansi --no-root -v

# Install pywry separately
RUN pip install pywry==0.6.2

# Copy the rest of the application
COPY . /app

EXPOSE 8080
CMD ["fastapi", "run", "src/humblapi/main.py", "--host", "0.0.0.0", "--port", "8080"]

pip install multi-stage Dockerfile (runs locally)

# Stage 1: Generate requirements.txt
FROM python:3.11-slim as requirements-stage

WORKDIR /tmp

RUN pip install poetry

COPY pyproject.toml poetry.lock* /tmp/

RUN poetry export -f requirements.txt --output requirements.txt --without-hashes

# Stage 2: Final image
FROM python:3.11-slim

WORKDIR /app

# Install system dependencies
RUN apt-get update && apt-get install -y 
    gcc 
    g++ 
    curl 
    pkg-config 
    libssl-dev 
    libgtk-3-dev 
    libsoup2.4-dev 
    libjavascriptcoregtk-4.0-dev 
    libwebkit2gtk-4.0-dev 
    && rm -rf /var/lib/apt/lists/*

# Install Rust
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
ENV PATH="/root/.cargo/bin:${PATH}"

# Copy requirements.txt from the previous stage
COPY --from=requirements-stage /tmp/requirements.txt /app/requirements.txt

# Install dependencies
RUN pip install --no-cache-dir -r /app/requirements.txt

# Copy the rest of the application
COPY . /app

EXPOSE 8080
CMD ["fastapi", "run", "src/humblapi/main.py", "--host", "0.0.0.0", "--port", "8080"]

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật