Image Request: Add an image to include FastAPI #4
Replies: 1 comment 1 reply
-
The official advice from FastAPI is to not use their own container.
Believe it or not this is already an in place replacement for that container. The reason is that FastAPI is a very small, source only library, that doesn't actually need anything special compiled. Take a look at the template you pointed to. The docker file for the backend is as follows: FROM tiangolo/uvicorn-gunicorn-fastapi:python3.10
WORKDIR /app/
# Install Poetry
RUN curl -sSL https://install.python-poetry.org | POETRY_HOME=/opt/poetry python && \
cd /usr/local/bin && \
ln -s /opt/poetry/bin/poetry && \
poetry config virtualenvs.create false
# Copy poetry.lock* in case it doesn't exist in the repo
COPY ./pyproject.toml ./poetry.lock* /app/
# Allow installing dev dependencies to run tests
ARG INSTALL_DEV=false
RUN bash -c "if [ $INSTALL_DEV == 'true' ] ; then poetry install --no-root ; else poetry install --no-root --only main ; fi"
ENV PYTHONPATH=/app
COPY ./scripts/ /app/
COPY ./alembic.ini /app/
COPY ./prestart.sh /app/
COPY ./tests-start.sh /app/
COPY ./app /app/app Although it does use the upstream container, it completely discards the FastAPI that was installed with it. As part of the build process the When I started this project it was because of the lack of multi architecture support in the upstream containers. My first usage of the My python project template uses the Multi-Py containers with FastAPI too, so if you want you can generate a project and switch between the two containers to test it out. |
Beta Was this translation helpful? Give feedback.
-
Hello @tedivm - thank you for your great support and work here! Very much appreciated 👏
Would you be able to add another image which is build on your already exist and maintained python-gunicorn-uvicorn?
This will allow in-place replacement for uvicorn-gunicorn-fastapi-docker which is not active maintenance but still being used in various community projects such as full-stack-fastapi-template.
I would be happy to contribute and help if possible 🙏
Beta Was this translation helpful? Give feedback.
All reactions