-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
39 lines (29 loc) · 912 Bytes
/
Dockerfile
File metadata and controls
39 lines (29 loc) · 912 Bytes
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
# Use multi-stage build for smaller final image
FROM python:3.10-slim as builder
# Set working directory
WORKDIR /code
# Install build dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential \
&& rm -rf /var/lib/apt/lists/*
# Copy requirements first to leverage Docker cache
COPY requirements_spaces.txt .
RUN pip install -r requirements_spaces.txt
# Final stage
FROM python:3.10-slim
# Set working directory
WORKDIR /code
# Copy only necessary files from builder
COPY --from=builder /usr/local/lib/python3.9/site-packages/ /usr/local/lib/python3.9/site-packages/
COPY . .
# Set environment variables
ENV PYTHONUNBUFFERED=1
ENV GRADIO_SERVER_NAME=0.0.0.0
ENV GRADIO_SERVER_PORT=5000
# Expose port
EXPOSE 5000
# Create a non-root user
RUN useradd -m appuser && chown -R appuser /code
USER appuser
# Command to run the application
CMD ["python", "app.py"]