fastAPI-ML-quickstart
fastAPI-ML-quickstart copied to clipboard
Using slim docker base image to reduce image size
I will suggest to consider using the slim/alpine docker base image (f.e. see here: https://github.com/tiangolo/uvicorn-gunicorn-fastapi-docker) to reduce the final image size, if it is possible.
This is my docker file. Works perfectly and as expected. I am using python3.8-slim as my base image.
FROM tiangolo/uvicorn-gunicorn:python3.8-slim
LABEL maintainer="Sebastian Ramirez <[email protected]>"
COPY ./api /app/api
COPY requirements.txt /api/requirements.txt
RUN pip install --no-cache-dir -r /api/requirements.txt
ENV PYTHONPATH=/app
WORKDIR /app/api
EXPOSE 3000
ENTRYPOINT ["uvicorn"]
CMD ["api.main:app", "--host", "0.0.0.0", "--port", "3000"]