Как уменьшить размер образа Python Docker ⇐ Python
-
Anonymous
Как уменьшить размер образа Python Docker
My Python based Docker image is 6.35GB. I tried multi stage build and several other options found while searching( like cache cleanup) Nothing helped.
I might be missing something really important.
# Use a smaller base image FROM python:3.11.4-slim as compiler # Set the working directory in the container WORKDIR /app RUN python -m venv /opt/venv # Enable venv ENV PATH="/opt/venv/bin:$PATH" COPY ./requirements.txt /app/requirements.txt #RUN pip install -Ur requirements.txt RUN pip install pip==23.1.2 \ && pip install -r requirements.txt \ && rm -rf /root/.cache FROM python:3.11.4-slim as runner WORKDIR /app/ COPY --from=compiler /opt/venv /opt/venv # Enable venv ENV PATH="/opt/venv/bin:$PATH" COPY . /app/ # Expose the port the app runs on EXPOSE 8501 # Define environment variables ENV STREAMLIT_THEME_BASE dark ENV STREAMLIT_THEME_SECONDARY_BACKGROUND_COLOR #3A475C ENV STREAMLIT_THEME_BACKGROUND_COLOR #2d3748 # Run the Streamlit app CMD ["streamlit", "run", "welcome.py"] requirements.txt
ibm-generative-ai>=2.0.0 pydantic>=2.6.1 langchain>=0.1.0 streamlit==1.27.2 ray==2.7.1 chromadb>=0.4.14 python-dotenv==1.0.0 beautifulsoup4==4.12.2 sentence-transformers==2.2.2 ibm-watson>=6.1.0 markdown==3.5.2 ibm-generative-ai[langchain] app folder contains multiple .py which does language model processing
Источник: https://stackoverflow.com/questions/781 ... image-size
My Python based Docker image is 6.35GB. I tried multi stage build and several other options found while searching( like cache cleanup) Nothing helped.
I might be missing something really important.
# Use a smaller base image FROM python:3.11.4-slim as compiler # Set the working directory in the container WORKDIR /app RUN python -m venv /opt/venv # Enable venv ENV PATH="/opt/venv/bin:$PATH" COPY ./requirements.txt /app/requirements.txt #RUN pip install -Ur requirements.txt RUN pip install pip==23.1.2 \ && pip install -r requirements.txt \ && rm -rf /root/.cache FROM python:3.11.4-slim as runner WORKDIR /app/ COPY --from=compiler /opt/venv /opt/venv # Enable venv ENV PATH="/opt/venv/bin:$PATH" COPY . /app/ # Expose the port the app runs on EXPOSE 8501 # Define environment variables ENV STREAMLIT_THEME_BASE dark ENV STREAMLIT_THEME_SECONDARY_BACKGROUND_COLOR #3A475C ENV STREAMLIT_THEME_BACKGROUND_COLOR #2d3748 # Run the Streamlit app CMD ["streamlit", "run", "welcome.py"] requirements.txt
ibm-generative-ai>=2.0.0 pydantic>=2.6.1 langchain>=0.1.0 streamlit==1.27.2 ray==2.7.1 chromadb>=0.4.14 python-dotenv==1.0.0 beautifulsoup4==4.12.2 sentence-transformers==2.2.2 ibm-watson>=6.1.0 markdown==3.5.2 ibm-generative-ai[langchain] app folder contains multiple .py which does language model processing
Источник: https://stackoverflow.com/questions/781 ... image-size