Commit 3df46523 authored by Artem Baranovskyi's avatar Artem Baranovskyi
Browse files

Image build is optimized.

parent 00098604
Pipeline #10714 failed with stages
in 8 minutes and 54 seconds
# Build stage FROM pytorch/pytorch:2.0.1-cuda11.7-cudnn8-runtime
FROM pytorch/pytorch:2.0.1-cuda11.7-cudnn8-runtime AS builder
# Install necessary packages
RUN apt-get update && apt-get install -y --no-install-recommends \ RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential python3-venv && \ build-essential python3-venv && \
apt-get clean && \ apt-get clean && \
rm -rf /var/lib/apt/lists/* rm -rf /var/lib/apt/lists/*
# Create virtual environment and install dependencies
RUN python3 -m venv /opt/myenv && \
/opt/myenv/bin/pip install --no-cache-dir Flask matplotlib scikit-learn transformers pandas sentence_transformers && \
/opt/myenv/bin/pip install --no-cache-dir --upgrade setuptools wheel
RUN python3 -m venv /opt/myenv
ENV PATH="/opt/myenv/bin:$PATH" ENV PATH="/opt/myenv/bin:$PATH"
WORKDIR /app WORKDIR /app
COPY . /app COPY . /app
# Install dependencies in smaller steps # Setting permissions and cleaning
RUN pip install --no-cache-dir Flask matplotlib scikit-learn transformers pandas sentence_transformers
RUN pip install --no-cache-dir --upgrade setuptools wheel
# Final image
FROM python:3.10-slim
COPY --from=builder /opt/myenv /opt/myenv
COPY --from=builder /app /app
ENV PATH="/opt/myenv/bin:$PATH"
RUN chown -R www-data:www-data /app && chmod -R 755 /app RUN chown -R www-data:www-data /app && chmod -R 755 /app
EXPOSE 5000 EXPOSE 5000
CMD ["/opt/myenv/bin/python", "/app/api.py"] CMD ["/opt/myenv/bin/python", "/app/api.py"]
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment