Spaces:
Sleeping
Sleeping
FROM debian:11-slim AS build | |
RUN apt-get update && apt-get upgrade -yy && \ | |
apt-get install --no-install-suggests --no-install-recommends --yes python3-venv gcc libpython3-dev && \ | |
python3 -m venv /venv && \ | |
/venv/bin/pip install --no-cache-dir --upgrade pip setuptools wheel | |
FROM build AS build-venv | |
COPY requirements.txt /requirements.txt | |
RUN /venv/bin/pip install --no-cache-dir --upgrade --disable-pip-version-check -r /requirements.txt | |
# Copy the virtualenv into a distroless image | |
FROM gcr.io/distroless/python3-debian11 | |
COPY --from=build-venv /venv /venv | |
#RUN useradd -m -u 1000 user | |
USER nonroot:nonroot | |
ENV HOME=/tmp \ | |
PATH=/venv/bin:$PATH | |
WORKDIR $HOME/app | |
COPY --chown=nonroot captioner.py $HOME/app/captioner.py | |
ARG MODEL="Salesforce/blip-image-captioning-base" | |
ENV MODEL=${MODEL} | |
ENTRYPOINT ["/venv/bin/python3", "/venv/bin/uvicorn", "--host", "0.0.0.0", "--port", "7860", "captioner:app"] | |
EXPOSE 7860 | |
USER nonroot:nonroot | |