mirror of
https://github.com/arc53/DocsGPT.git
synced 2025-11-29 08:33:20 +00:00
Optimize Dockerfile to reduce image size and improve build efficiency
- Merge apt-related RUN commands in builder and final stages - Remove redundant apt-get clean (automatically handled by base image) - Consolidate cleanup operations within the same layer for effective size reduction Reference: - https://docs.docker.com/build/building/best-practices/#apt-get
This commit is contained in:
@@ -4,14 +4,11 @@ FROM ubuntu:24.04 as builder
|
|||||||
ENV DEBIAN_FRONTEND=noninteractive
|
ENV DEBIAN_FRONTEND=noninteractive
|
||||||
|
|
||||||
RUN apt-get update && \
|
RUN apt-get update && \
|
||||||
apt-get install -y software-properties-common
|
apt-get install -y software-properties-common && \
|
||||||
|
add-apt-repository ppa:deadsnakes/ppa && \
|
||||||
RUN add-apt-repository ppa:deadsnakes/ppa
|
|
||||||
|
|
||||||
# Install necessary packages and Python
|
# Install necessary packages and Python
|
||||||
RUN apt-get update && \
|
apt-get update && \
|
||||||
apt-get install -y --no-install-recommends gcc wget unzip libc6-dev python3.11 python3.11-distutils python3.11-venv && \
|
apt-get install -y --no-install-recommends gcc wget unzip libc6-dev python3.11 python3.11-distutils python3.11-venv && \
|
||||||
apt-get clean && \
|
|
||||||
rm -rf /var/lib/apt/lists/*
|
rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
# Verify Python installation and setup symlink
|
# Verify Python installation and setup symlink
|
||||||
@@ -50,12 +47,10 @@ RUN pip install --no-cache-dir --upgrade pip && \
|
|||||||
FROM ubuntu:24.04 as final
|
FROM ubuntu:24.04 as final
|
||||||
|
|
||||||
RUN apt-get update && \
|
RUN apt-get update && \
|
||||||
apt-get install -y software-properties-common
|
apt-get install -y software-properties-common && \
|
||||||
|
add-apt-repository ppa:deadsnakes/ppa && \
|
||||||
RUN add-apt-repository ppa:deadsnakes/ppa
|
|
||||||
|
|
||||||
# Install Python
|
# Install Python
|
||||||
RUN apt-get update && apt-get install -y --no-install-recommends python3.11 && \
|
apt-get update && apt-get install -y --no-install-recommends python3.11 && \
|
||||||
ln -s /usr/bin/python3.11 /usr/bin/python && \
|
ln -s /usr/bin/python3.11 /usr/bin/python && \
|
||||||
rm -rf /var/lib/apt/lists/*
|
rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user