46 lines
1.2 KiB
Plaintext
Raw Permalink Normal View History

2025-07-14 15:48:05 +01:00
# ---- Builder Stage ----
FROM python:3.10-slim-bookworm as builder
2025-07-14 13:42:58 +01:00
2025-07-14 15:48:05 +01:00
# Install git for fetching git-based dependencies
RUN apt-get update && apt-get install -y --no-install-recommends git && rm -rf /var/lib/apt/lists/*
# Create a virtual environment
RUN python -m venv /opt/venv
2025-07-14 13:42:58 +01:00
2025-07-14 15:48:05 +01:00
# Activate the virtual environment
ENV PATH="/opt/venv/bin:$PATH"
# Copy requirements and install dependencies
WORKDIR /app
COPY requirements.txt .
2025-07-14 15:48:05 +01:00
RUN pip install --no-cache-dir wheel requests==2.32.3 stem==1.8.2
2025-07-14 15:01:55 +01:00
RUN pip install --no-cache-dir --no-build-isolation -r requirements.txt
2025-07-14 14:30:42 +01:00
2025-07-14 15:48:05 +01:00
# ---- Final Stage ----
FROM python:3.10-slim-bookworm
# Set working directory
WORKDIR /app
2025-07-14 14:30:42 +01:00
2025-07-14 15:48:05 +01:00
# Copy virtual environment from builder stage
COPY --from=builder /opt/venv /opt/venv
2025-07-14 15:48:05 +01:00
# Activate the virtual environment
ENV PATH="/opt/venv/bin:$PATH"
ENV FLASK_ENV=production
ENV FLASK_APP=ktvmanager.main:create_app
# Copy application code
COPY . .
# Handle versioning
2025-07-14 14:30:42 +01:00
ARG VERSION
2025-07-14 15:48:05 +01:00
RUN if [ -n "$VERSION" ]; then echo $VERSION > VERSION; fi
2025-07-14 14:30:42 +01:00
2025-07-14 15:48:05 +01:00
# Debugging step
RUN ls -l /opt/venv/lib/python3.10/site-packages/
2025-07-14 15:48:05 +01:00
# Make run script executable and run the application
EXPOSE 3001
CMD ["/opt/venv/bin/python", "-m", "flask", "run", "--host=0.0.0.0", "--port=3001"]