File size: 1,195 Bytes
a79fd75
64e55d6
3c7fa13
 
 
 
 
64e55d6
 
 
a79fd75
3c7fa13
64e55d6
 
3c7fa13
64e55d6
 
 
 
3c7fa13
64e55d6
 
3c7fa13
 
64e55d6
3c7fa13
64e55d6
3c7fa13
64e55d6
3c7fa13
64e55d6
3c7fa13
 
 
64e55d6
 
 
 
 
 
3c7fa13
 
64e55d6
 
3c7fa13
 
64e55d6
787d79c
 
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
FROM python:3.10-slim AS builder

ENV PYTHONUNBUFFERED=1 \
    PIP_NO_CACHE_DIR=off \
    PIP_DISABLE_PIP_VERSION_CHECK=on \
    PIP_DEFAULT_TIMEOUT=100

RUN apt-get update && apt-get install -y \
    ffmpeg \
    libsndfile1 \
    git \
    build-essential \
    && rm -rf /var/lib/apt/lists/*

RUN useradd -m -s /bin/bash -u 1000 user
USER user
ENV PATH="/home/user/.local/bin:$PATH"
WORKDIR /app

COPY --chown=user requirements.txt ./
RUN python -m venv /app/venv
ENV PATH="/app/venv/bin:$PATH"
RUN pip install --upgrade pip
RUN pip install -r requirements.txt

COPY --chown=user setup_imagebind.py README.md ./
RUN python setup_imagebind.py
RUN pip install .

FROM python:3.10-slim AS runtime

ENV PYTHONUNBUFFERED=1 \
    PATH="/app/venv/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" \
    APP_USER="user"

RUN apt-get update && apt-get install -y \
    ffmpeg \
    libsndfile1 \
    && rm -rf /var/lib/apt/lists/*

RUN useradd -m -s /bin/bash -u 1000 ${APP_USER}
USER ${APP_USER}
WORKDIR /app

COPY --from=builder --chown=${APP_USER} /app/venv /app/venv
COPY --chown=${APP_USER} main.py .

EXPOSE 7860
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]