File size: 885 Bytes
45968f8
eee346e
 
 
 
 
 
 
 
 
45968f8
eee346e
 
 
 
 
 
45968f8
 
eee346e
 
45968f8
 
eee346e
 
 
 
45968f8
 
eee346e
 
45968f8
eee346e
 
45968f8
 
eee346e
 
 
 
 
45968f8
eee346e
 
45968f8
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
FROM python:3.11-slim AS base

# Set Python environment variables
ENV PYTHONDONTWRITEBYTECODE=1 \
    PYTHONUNBUFFERED=1 \
    PYTHONFAULTHANDLER=1 \
    LANG=C.UTF-8 \
    LC_ALL=C.UTF-8

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

# Upgrade pip
RUN pip install --no-cache-dir --upgrade pip

FROM base AS builder

# Create and activate virtual environment
RUN python -m venv /.venv
ENV PATH="/.venv/bin:$PATH"

# Install dependencies
COPY pyproject.toml .
RUN pip install --no-cache-dir .

FROM base as runtime

# Set working directory
WORKDIR /app

# Copy virtual environment from builder
COPY --from=builder /.venv /.venv
ENV PATH="/.venv/bin:$PATH"

# Copy application code
COPY . .

# Expose port (adjust if needed)
EXPOSE 8000

# Run the application
CMD ["python", "main.py"]