fastAPI-ML-quickstart icon indicating copy to clipboard operation
fastAPI-ML-quickstart copied to clipboard

Using slim docker base image to reduce image size

Open lospejos opened this issue 5 years ago • 1 comments

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.

lospejos avatar Jul 30 '20 21:07 lospejos

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"]

naveenmarthala avatar Oct 18 '20 17:10 naveenmarthala