File size: 1,452 Bytes
623d18f
f6f2109
d29b1dc
623d18f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
baea2d7
 
 
 
623d18f
 
 
 
3123217
623d18f
a16fa97
 
623d18f
 
a16fa97
623d18f
f6f2109
a16fa97
623d18f
 
 
3123217
623d18f
 
 
 
d29b1dc
623d18f
3874c33
623d18f
 
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
# Use an official Python runtime as a base image
FROM python:3.11-slim

# Set build-time arguments for environment variables (if needed)
ARG MODEL_REPO_NAME

# Configure environment variables for Python and Poetry
ENV PYTHONUNBUFFERED=1 \
    PIP_NO_CACHE_DIR=on \
    PIP_DISABLE_PIP_VERSION_CHECK=on \
    POETRY_NO_INTERACTION=1 \
    POETRY_VIRTUALENVS_IN_PROJECT=true \
    POETRY_VIRTUALENVS_CREATE=true \
    PATH="/app/.venv/bin:$PATH"

# Install system dependencies and create a non-root user
RUN set -ex \
    && apt-get update \
    && apt-get install -y --no-install-recommends \
        git \
        postgresql-client \
        libpq-dev \
        build-essential \
    && apt-get clean \
    && rm -rf /var/lib/apt/lists/* \
    && addgroup --system --gid 1001 appgroup \
    && adduser --system --uid 1001 --gid 1001 --no-create-home appuser

# Set the working directory
WORKDIR /app

# Clone your repository (consider using COPY for better caching)
RUN git clone https://github.com/simstudioai/sim ./

# Install Poetry
RUN pip install --no-cache-dir poetry

# Install Python dependencies using Poetry
# Navigate to the correct directory that contains pyproject.toml
RUN cd /app/packages/python && poetry install --no-dev --no-root

# Switch to the non-root user for security
USER appuser

# Expose the port Hugging Face Spaces expects (default is 7860)
ENV PORT=7860
EXPOSE 7860

# Run your application
CMD ["python", "-m", "sim.main"]