Skip to content
Snippets Groups Projects
Dockerfile.backend 862 B
Newer Older
# Stage 1: Build Python dependencies
FROM python:3.10-slim AS builder
WORKDIR /src/app
COPY requirements.txt .
RUN pip install --no-cache-dir --user -r requirements.txt
# Stage 2: Final Image
FROM ubuntu:22.04
# Install Python in the second stage
# Install Python 3.11 in the final stage
RUN apt-get update && apt-get install -y \
    python3.10 \
    python3-pip \
    libgl1-mesa-glx \
    libsm6 \
    libxext6 \
    ffmpeg \
    curl \
    wget \
    git \
    && apt-get clean && rm -rf /var/lib/apt/lists/*
Joohyun Park's avatar
Joohyun Park committed

WORKDIR /src/app
Joohyun Park's avatar
Joohyun Park committed

# Copy Python dependencies from the builder stage
COPY --from=builder /root/.local /root/.local
ENV PATH=/root/.local/bin:$PATH
ENV PYTHONPATH=/root/.local/lib/python3.11/site-packages
# Copy the application files
COPY src/app /src/app
# Expose the application port
# Run the Flask app
CMD ["python3", "app.py"]