Poetry project not recognized

I’m trying to deploy a Python service.
The dependency is managed by poetry.
When I run LOG_LEVEL=debug flyctl launch, I see the following error.

Error app does not have a Dockerfile or buildpacks configured. See https://fly.io/docs/reference/configuration/#the-build-section

I can see several buildpack related repo for Python and Poetry, but I don’t know how to correctly configure it in fly.toml.

Maybe I should just write a Dockerfile.

Have no idea of Python but looking at the example repo and the docs page you linked to, do you have a Procfile?
And just in case, is your entry .py file in the root next to the fly.toml? This is probably not needed with a Procfile not sure tho.

Building a Dockerfile will serve you better over the longer term, as you’ll have more ability to control your build process & deviate from the (narrower) expectations and capabilities of a buildpack.

Here’s a “python and poetry dockerfile” example, we deploy this app to Fly. (Incidentally it also uses nodejs, but you should be able to strip out the parts you don’t need).

FROM nikolaik/python-nodejs:python3.10-nodejs16

RUN mkdir /app
WORKDIR /app
ENV PYTHONFAULTHANDLER=1 \
  PYTHONUNBUFFERED=1 \
  PIP_NO_CACHE_DIR=off \
  PIP_DISABLE_PIP_VERSION_CHECK=on \
  PIP_DEFAULT_TIMEOUT=100 \
  BABEL_CACHE=0

RUN export DEBIAN_FRONTEND=noninteractive && \
    apt-get update && \
    apt-get install -y gdal-bin libgdal-dev && \
    python -m pip install -U pip poetry

COPY poetry.lock pyproject.toml ./
RUN poetry config virtualenvs.create false && \
  poetry install --no-interaction --no-root --no-dev && \
  rm -rf ~/.cache/pypoetry && \
  rm -rf ~/.config/pypoetry
COPY package.json yarn.lock /app/
RUN yarn install --frozen-lockfile --no-cache --production && yarn cache clean

COPY ./ /app/
RUN yarn build-prod && rm -rf node_modules/.cache
RUN ./manage.py collectstatic --noinput --ignore='*.map'

EXPOSE 8000
ENV PORT 8000

CMD /bin/sh -c 'waitress-serve \
    --threads=8 \
    --outbuf-overflow=2097152 \
    --port=$PORT \
    --channel-timeout=15 \
    --asyncore-use-poll \
    myapp.wsgi:application'
1 Like