File size: 1,275 Bytes
e21102a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
# Compile stage: install build dependencies
FROM python:3.12-slim AS builder

# Set working directory
WORKDIR /app

# Install build dependencies
RUN apt-get update && \
    apt-get install -y --no-install-recommends \
    build-essential \
    && rm -rf /var/lib/apt/lists/*

# Install Python dependencies
COPY requirements.txt .
RUN python -m pip install --upgrade pip && \
    python -m pip install --no-cache-dir wheel && \
    pip wheel --no-cache-dir --no-deps --wheel-dir /app/wheels -r requirements.txt

# Final stage: copy only necessary files
FROM python:3.12-slim

WORKDIR /app

# Copy wheels from builder stage
COPY --from=builder /app/wheels /wheels

# Install Python packages from wheels
RUN pip install --no-cache /wheels/*

# Copy application files
COPY app.py flux.py stablediffusion.py ./
COPY pyproject.toml README.md ./

# Create directories for temporary files
RUN mkdir -p /tmp/flux /tmp/flux2 && \
    chmod 777 /tmp/flux /tmp/flux2

# Set environment variables
ENV PYTHONUNBUFFERED=1
ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONPATH=/app

# Copy and set permissions for entrypoint script
COPY entrypoint.sh .
RUN chmod +x entrypoint.sh

# Expose the port that Gradio will run on
EXPOSE 7860

# Command to run the application
ENTRYPOINT ["./entrypoint.sh"]