I’m trying to deploy a simple websocket server using the fly CLI. It’s a python poetry project which seems to be nothing out of the ordinary. When running the fly launch command from the project’s root directory I get the following output:
Scanning source code
INFO Detected Poetry project
WARN No supported Python frameworks found
INFO Detected pyproject.toml
Error: No dependencies found in pyproject.toml
I’m not sure what I’m doing wrong and was not able to find anything when trying to google. Anyone got a clue?
Python project auto-detection is fairly new and given the myriad ways in which a Python application can implement web services, it’s not really feasible to detect all of them to generate a reasonable fly.toml and Dockerfile. As seen here, auto-detection will only work for Flask, FastAPI, Streamlit and Django. So you could do one of two things:
Use a framework to implement your application so it’s auto-detected. Forcing you to use a specific framework to allow fly launch to auto-detect seems a bit ham-fisted though - so the best option would probably be:
Provide your own Dockerfile that creates a Docker image for your app. As long as the image builds and starts properly via e.g. docker run -p x:y, running fly launch will give you a fly.toml that should work, you only need to ensure that the internal_port in fly.toml matches the port your app is serving on. If you did docker run -p x:y, the y port is the one you should configure here.
You can use the starter Dockerfile that fly launch creates for an application with Flask:
FROM python:3.10-bookworm AS builder
ENV PYTHONUNBUFFERED=1 \
PYTHONDONTWRITEBYTECODE=1
WORKDIR /app
RUN pip install poetry
RUN poetry config virtualenvs.in-project true
COPY pyproject.toml poetry.lock ./
RUN poetry install
FROM python:3.10-slim-bookworm
WORKDIR /app
COPY --from=builder /app/.venv .venv/
COPY . .
CMD ["/app/.venv/bin/flask", "run", "--host=0.0.0.0", "--port=8080"]
Replace the last line (CMD) with the actual command to run your app or service.