File size: 963 Bytes
2056905
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9d49c48
 
2056905
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
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