subprocess2 / Dockerfile
sreepathi-ravikumar's picture
Update Dockerfile
aa5fa1d verified
raw
history blame
1.34 kB
FROM python:3.11-slim
# Install Rust and maturin
USER root
RUN apt-get update && apt-get install -y curl build-essential pkg-config libssl-dev \
&& curl https://sh.rustup.rs -sSf | bash -s -- -y \
&& . "$HOME/.cargo/env" \
&& pip install maturin
# 1. First create user and directory structure
RUN useradd -m appuser && \
mkdir -p /app/data && \
chown -R appuser:appuser /app
# 2. Switch to appuser early
USER appuser
WORKDIR /app
# 3. Temporary root access for system packages
USER root
RUN apt-get update && apt-get install -y \
ffmpeg \
tesseract-ocr \
tesseract-ocr-tam \
fonts-liberation \
&& rm -rf /var/lib/apt/lists/*
# 4. Switch back to appuser for Python operations
USER appuser
# 5. Install Python packages (first copy just requirements)
COPY --chown=appuser:appuser requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
# Copy and build the Rust module using maturin
COPY --chown=appuser:appuser rust_highlight /app/rust_highlight
WORKDIR /app/rust_highlight
# Compile and install Rust module into Python environment
RUN . "$HOME/.cargo/env" && maturin develop --release
# 6. Copy all application files
COPY --chown=appuser:appuser app.py image_fetcher.py video.py video2.py ./
# 7. Environment variables
ENV BASE_DIR="/app/data"
EXPOSE 7860
CMD ["python", "app.py"]