I gave up on using a builder and switched to a Dockerfile instead – I was getting unexplained timeouts when I specified a Paketo buildpack and the docs are pretty vague, so I Dockerised the app instead:
FROM python:alpine
RUN apk update \
&& apk add libpq postgresql-dev \
&& apk add build-base
COPY ./requirements.txt /app/requirements.txt
WORKDIR /app
RUN pip install -r requirements.txt
COPY . /app
CMD ["gunicorn", "-b", "0.0.0.0:8080", "--workers", "3", "app:app"]
Be sure to edit the top-level [build]
section from your fly.toml
to remove the builder
and buildpacks
keys and use the dockerfile by using the dockerfile = "Dockerfile"
key, and ensure the PORT
key in [env]
matches the port you specify in your Dockerfile CMD
. Note also that you’ll need to tune the workers
setting in your Dockerfile to match the number of CPUs in your app – the rule of thumb is num CPUs * 2 + 1
.