Reputation: 1
I'm attempting to deploy a FastAPI app to App Runner via a deployed Docker image on ECR. It works fine when running a local Docker container (on 0.0.0.0:8080), but fails to deploy on App Runner because the health check fails.
Here's the associated Dockerfile:
FROM python:3.11-bullseye
# Turns off buffering for easier container logging
ENV PYTHONUNBUFFERED=1
# Expose port you want your app on
ENV PORT=8080
EXPOSE ${PORT}
RUN apt update && apt install ffmpeg unzip -y && apt clean
ENV APP_HOME /app
WORKDIR $APP_HOME
# Install production dependencies.
COPY requirements.txt .
RUN pip install -r requirements.txt --no-cache-dir && pip install hypercorn --no-cache-dir
RUN pip install "pydantic[email]" pydantic_settings gdown
RUN gdown --fuzzy "<redacted>"
RUN unzip tokenizer_model.zip
COPY . .
RUN adduser -u 5678 --disabled-password --gecos "" appuser && chown -R appuser /app
USER appuser
CMD exec hypercorn --bind :$PORT --workers 2 app:app
Additionally, I've added a /health
endpoint that returns a 200 OK
message. I've also adjusted the configuration settings on App Runner accordingly.
I did add some logging messages for when the app starts, but I can't see anything on the App Runner console. Here are the event logs:
06-13-2024 08:35:27 AM [AppRunner] Successfully pulled your application image from ECR.
06-13-2024 08:35:37 AM [AppRunner] Provisioning instances and deploying image for publicly accessible service.
06-13-2024 08:35:46 AM [AppRunner] Performing health check on protocol `HTTP` [Path: '/health'], [Port: '8080'].
06-13-2024 08:42:00 AM [AppRunner] Health check failed on protocol `HTTP`[Path: '/health'], [Port: '8080']. Check your configured port number. For more information, see the application logs.
06-13-2024 08:42:13 AM [AppRunner] Deployment with ID : abe5baee271644b28f07eda47f100583 failed. Failure reason : Health check failed.
Would really appreciate some assistance here.
Upvotes: 0
Views: 246