File size: 1,341 Bytes
dd8494c
 
 
 
 
 
 
 
 
 
 
 
cf9fd07
8caf0a0
0fbe9df
5ea22fe
b4e6edc
dd8494c
 
 
 
 
 
 
 
 
 
 
cf9fd07
 
 
 
dd8494c
 
 
 
cf9fd07
 
 
 
 
 
 
 
 
 
dd8494c
 
 
 
 
 
 
 
 
 
 
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
51
52
53
54
55
56
57
58
FROM python:3.10-slim

# Set environment variables
ENV PYTHONDONTWRITEBYTECODE=1 \
    PYTHONUNBUFFERED=1 \
    PIP_NO_CACHE_DIR=off \
    PIP_DISABLE_PIP_VERSION_CHECK=on \
    PIP_DEFAULT_TIMEOUT=100

# Install system dependencies
RUN apt-get update && apt-get install -y \
    git \
    dos2unix \
    nginx \
    procps \
    curl \
    prometheus \
    && rm -rf /var/lib/apt/lists/*

# Create a non-root user
RUN useradd -m -u 1000 user

# Set working directory
WORKDIR /app

# Copy requirements first for caching
COPY requirements.txt .

# Remove -e . from requirements.txt to avoid installing the project before copying it
# and install dependencies
RUN sed -i '/-e \./d' requirements.txt && \
    pip install --no-cache-dir -r requirements.txt

# Copy the rest of the application
COPY --chown=user:user . .

# Ensure the user has permissions on the app directory (needed for dvc init if .dvc is missing)
RUN chown -R user:user /app

# Fix line endings and permissions for the start script
RUN dos2unix scripts/start_space.sh && \
    chmod +x scripts/start_space.sh

# Install the project itself
RUN pip install --no-cache-dir .

# Make start script executable
RUN chmod +x scripts/start_space.sh

# Switch to non-root user
USER user

# Expose the port
EXPOSE 7860

# Command to run the application
CMD ["./scripts/start_space.sh"]