KTVManager_Backend/dockerfile

44 lines
1.1 KiB
Plaintext
Raw Normal View History

2025-07-14 14:30:42 +01:00
# ---- Builder Stage ----
FROM python:3.11-slim-bookworm as builder
2025-07-14 13:42:58 +01:00
2025-07-14 14:30:42 +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/*
2025-07-14 13:42:58 +01:00
2025-07-14 14:30:42 +01:00
# Create a virtual environment
RUN python -m venv /opt/venv
2025-07-14 13:42:58 +01:00
2025-07-14 14:30:42 +01:00
# Activate the virtual environment
ENV PATH="/opt/venv/bin:$PATH"
# Copy requirements and install dependencies
WORKDIR /app
2025-07-14 13:42:58 +01:00
COPY requirements.txt .
2025-07-14 14:33:01 +01:00
RUN pip install --no-cache-dir requests==2.32.3
RUN pip install --no-cache-dir stem==1.8.2
2025-07-14 13:42:58 +01:00
RUN pip install --no-cache-dir -r requirements.txt
2025-07-14 14:30:42 +01:00
# ---- Final Stage ----
FROM python:3.11-slim-bookworm
2025-07-14 13:42:58 +01:00
2025-07-14 14:30:42 +01:00
# Set working directory
WORKDIR /app
2025-07-14 13:42:58 +01:00
2025-07-14 14:30:42 +01:00
# Copy virtual environment from builder stage
COPY --from=builder /opt/venv /opt/venv
2025-07-14 13:42:58 +01:00
2025-07-14 14:30:42 +01:00
# Activate the virtual environment
ENV PATH="/opt/venv/bin:$PATH"
2025-07-14 13:50:26 +01:00
ENV FLASK_ENV=production
2025-07-14 14:30:42 +01:00
# Copy application code
COPY . .
# Handle versioning
ARG VERSION
RUN if [ -n "$VERSION" ]; then echo $VERSION > VERSION; fi
# Make run script executable and run the application
2025-07-14 14:09:53 +01:00
RUN chmod +x run_docker.sh
2025-07-14 14:30:42 +01:00
EXPOSE 3001
2025-07-14 14:09:53 +01:00
CMD ["./run_docker.sh"]