Spaces:
Sleeping
Sleeping
File size: 1,183 Bytes
c21482b 2573d67 03a51ed 2573d67 147eb42 5e5906f 274ad8e 2573d67 147eb42 2573d67 147eb42 2573d67 2438f4f 147eb42 2573d67 3c8dfb6 2573d67 |
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 50 |
ARG PYTHON_VERSION=3.10.15
FROM python:$PYTHON_VERSION-slim as builder
RUN pip install poetry==1.8.2
ENV POETRY_NO_INTERACTION=1 \
POETRY_VIRTUALENVS_IN_PROJECT=1 \
POETRY_VIRTUALENVS_CREATE=1 \
POETRY_CACHE_DIR=/tmp/poetry_cache
WORKDIR /app
COPY pyproject.toml poetry.lock ./
RUN poetry install --no-root && rm -rf $POETRY_CACHE_DIR
FROM python:$PYTHON_VERSION-slim as runtime
# Create user first
RUN useradd -m -u 1000 user
####### Add your own installation commands here #######
# Create necessary directories with proper permissions
RUN mkdir -p /app/cache && chmod 777 /app/cache && \
mkdir -p /app/output && chmod 777 /app/output && \
chown -R user:user /app/output /app/cache
# Copy virtual environment and set permissions
COPY --from=builder /app/.venv /app/.venv
RUN chown -R user:user /app/.venv
# Copy application code
COPY . /app
RUN chown -R user:user /app
# Switch to user
USER user
ENV VIRTUAL_ENV=/app/.venv \
PATH="/app/.venv/bin:$PATH"
# Install additional dependencies
RUN pip install python-multipart
# Install spaCy model as user
RUN python -m spacy download en_core_web_sm
EXPOSE 7860
CMD ["sh", "/app/bin/api-start.sh"]
|