-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathDockerfile
More file actions
44 lines (31 loc) · 864 Bytes
/
Copy pathDockerfile
File metadata and controls
44 lines (31 loc) · 864 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
40
41
42
43
44
# Stage 1: Builder
FROM python:3.12-slim AS builder
# Set working directory
WORKDIR /app
# Copy requirements file
COPY requirements-l.txt .
# Create and activate virtual environment
RUN python -m venv /opt/venv && \
. /opt/venv/bin/activate && \
pip install --no-cache-dir -r requirements-l.txt
# Stage 2: Runtime
FROM python:3.12-slim
# Copy virtual environment from builder
COPY --from=builder /opt/venv /opt/venv
# Set working directory
WORKDIR /app
# Copy application code
COPY . .
# Create data directory
RUN mkdir -p user_data
# Make start script executable
RUN chmod +x start.sh
# Add virtual environment to path
ENV PATH="/opt/venv/bin:$PATH"
# Set Python environment variables
ENV PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1
# Create volume for persistent data
VOLUME /app/user_data
# Run the startup script
CMD ["./start.sh"]