Update Dockerfile
Browse files- Dockerfile +21 -19
Dockerfile
CHANGED
|
@@ -2,55 +2,58 @@ FROM python:3.11-slim
|
|
| 2 |
|
| 3 |
# Install Rust and maturin
|
| 4 |
USER root
|
| 5 |
-
RUN apt-get update && apt-get install -y
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
&& curl https://sh.rustup.rs -sSf | bash -s -- -y \
|
| 7 |
&& . "$HOME/.cargo/env" \
|
| 8 |
-
&& pip install maturin
|
|
|
|
|
|
|
| 9 |
|
| 10 |
-
#
|
| 11 |
RUN useradd -m appuser && \
|
| 12 |
mkdir -p /data && \
|
| 13 |
chown -R appuser:appuser /data
|
| 14 |
|
| 15 |
-
#
|
| 16 |
USER appuser
|
| 17 |
WORKDIR /app
|
| 18 |
|
| 19 |
-
#
|
| 20 |
USER root
|
| 21 |
RUN apt-get update && apt-get install -y \
|
| 22 |
ffmpeg \
|
| 23 |
tesseract-ocr \
|
| 24 |
tesseract-ocr-tam \
|
| 25 |
fonts-liberation \
|
|
|
|
| 26 |
&& rm -rf /var/lib/apt/lists/*
|
| 27 |
|
| 28 |
-
#
|
| 29 |
USER appuser
|
| 30 |
|
| 31 |
-
#
|
| 32 |
COPY --chown=appuser:appuser requirements.txt .
|
| 33 |
RUN pip install --no-cache-dir -r requirements.txt
|
| 34 |
|
| 35 |
-
#
|
| 36 |
USER root
|
| 37 |
COPY --chown=appuser:appuser rust_highlight /app/rust_highlight
|
| 38 |
WORKDIR /app/rust_highlight
|
| 39 |
-
|
| 40 |
ENV PATH="/root/.cargo/bin:${PATH}"
|
| 41 |
RUN maturin build --release --manifest-path Cargo.toml
|
| 42 |
RUN pip install target/wheels/*.whl
|
| 43 |
|
| 44 |
-
#
|
| 45 |
-
USER appuser
|
| 46 |
-
WORKDIR /app
|
| 47 |
-
# --- RUST BUILD END ---
|
| 48 |
-
|
| 49 |
-
# --- RUST COMBINER BUILD START ---
|
| 50 |
USER root
|
| 51 |
COPY --chown=appuser:appuser rust_combiner /app/rust_combiner
|
| 52 |
WORKDIR /app/rust_combiner
|
| 53 |
-
|
| 54 |
ENV PATH="/root/.cargo/bin:${PATH}"
|
| 55 |
RUN maturin build --release --manifest-path Cargo.toml
|
| 56 |
RUN pip install target/wheels/*.whl
|
|
@@ -58,12 +61,11 @@ RUN pip install target/wheels/*.whl
|
|
| 58 |
# Go back to app setup
|
| 59 |
USER appuser
|
| 60 |
WORKDIR /app
|
| 61 |
-
# --- RUST COMBINER BUILD END ---
|
| 62 |
|
| 63 |
-
#
|
| 64 |
COPY --chown=appuser:appuser app.py image_fetcher.py video.py video2.py ./
|
| 65 |
|
| 66 |
-
#
|
| 67 |
ENV BASE_DIR="/data"
|
| 68 |
|
| 69 |
EXPOSE 7860
|
|
|
|
| 2 |
|
| 3 |
# Install Rust and maturin
|
| 4 |
USER root
|
| 5 |
+
RUN apt-get update && apt-get install -y \
|
| 6 |
+
curl \
|
| 7 |
+
build-essential \
|
| 8 |
+
pkg-config \
|
| 9 |
+
libssl-dev \
|
| 10 |
+
libopencv-dev \
|
| 11 |
+
clang \
|
| 12 |
+
libclang-dev \
|
| 13 |
&& curl https://sh.rustup.rs -sSf | bash -s -- -y \
|
| 14 |
&& . "$HOME/.cargo/env" \
|
| 15 |
+
&& pip install maturin \
|
| 16 |
+
&& apt-get clean \
|
| 17 |
+
&& rm -rf /var/lib/apt/lists/*
|
| 18 |
|
| 19 |
+
# Create user and directory structure
|
| 20 |
RUN useradd -m appuser && \
|
| 21 |
mkdir -p /data && \
|
| 22 |
chown -R appuser:appuser /data
|
| 23 |
|
| 24 |
+
# Switch to appuser
|
| 25 |
USER appuser
|
| 26 |
WORKDIR /app
|
| 27 |
|
| 28 |
+
# Install system packages
|
| 29 |
USER root
|
| 30 |
RUN apt-get update && apt-get install -y \
|
| 31 |
ffmpeg \
|
| 32 |
tesseract-ocr \
|
| 33 |
tesseract-ocr-tam \
|
| 34 |
fonts-liberation \
|
| 35 |
+
&& apt-get clean \
|
| 36 |
&& rm -rf /var/lib/apt/lists/*
|
| 37 |
|
| 38 |
+
# Switch back to appuser for Python operations
|
| 39 |
USER appuser
|
| 40 |
|
| 41 |
+
# Install Python packages
|
| 42 |
COPY --chown=appuser:appuser requirements.txt .
|
| 43 |
RUN pip install --no-cache-dir -r requirements.txt
|
| 44 |
|
| 45 |
+
# Build rust_highlight
|
| 46 |
USER root
|
| 47 |
COPY --chown=appuser:appuser rust_highlight /app/rust_highlight
|
| 48 |
WORKDIR /app/rust_highlight
|
|
|
|
| 49 |
ENV PATH="/root/.cargo/bin:${PATH}"
|
| 50 |
RUN maturin build --release --manifest-path Cargo.toml
|
| 51 |
RUN pip install target/wheels/*.whl
|
| 52 |
|
| 53 |
+
# Build rust_combiner (if still needed)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 54 |
USER root
|
| 55 |
COPY --chown=appuser:appuser rust_combiner /app/rust_combiner
|
| 56 |
WORKDIR /app/rust_combiner
|
|
|
|
| 57 |
ENV PATH="/root/.cargo/bin:${PATH}"
|
| 58 |
RUN maturin build --release --manifest-path Cargo.toml
|
| 59 |
RUN pip install target/wheels/*.whl
|
|
|
|
| 61 |
# Go back to app setup
|
| 62 |
USER appuser
|
| 63 |
WORKDIR /app
|
|
|
|
| 64 |
|
| 65 |
+
# Copy application files
|
| 66 |
COPY --chown=appuser:appuser app.py image_fetcher.py video.py video2.py ./
|
| 67 |
|
| 68 |
+
# Environment variables
|
| 69 |
ENV BASE_DIR="/data"
|
| 70 |
|
| 71 |
EXPOSE 7860
|