ml-model-restapi / Dockerfile
fahmiaziz98
fix version
b90bbfd
raw
history blame contribute delete
917 Bytes
FROM python:3.9-slim AS build
ENV PIP_DEFAULT_TIMEOUT=100 \
PYTHONUNBUFFERED=1 \
PIP_DISABLE_PIP_VERSION_CHECK=1 \
PIP_NO_CACHE_DIR=1 \
PATH="/home/user/.local/bin:$PATH"
RUN apt-get update && apt-get install -y \
build-essential \
libjpeg-dev \
zlib1g-dev \
&& rm -rf /var/lib/apt/lists/*
RUN useradd -m -u 1000 user
USER user
WORKDIR /app
COPY --chown=user requirements.txt .
RUN pip install --no-cache-dir --user -r requirements.txt
FROM python:3.9-slim
RUN apt-get update && apt-get install -y \
libjpeg-dev \
zlib1g-dev \
&& apt-get autoremove -y \
&& apt-get clean -y \
&& rm -rf /var/lib/apt/lists/*
RUN useradd -m -u 1000 user
USER user
ENV PATH="/home/user/.local/bin:$PATH"
WORKDIR /app
COPY --from=build /home/user/.local /home/user/.local
COPY --chown=user . .
EXPOSE 7860
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]