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:38:05 +01:00
|
|
|
RUN pip install --no-cache-dir requests stem
|
|
|
|
RUN pip install --no-cache-dir git+https://github.com/karl0ss/requests_tor.git@ae1e85abb3bb2c25f431bd031c6d881986c626f6
|
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"]
|