8000 Devcontainer: Optimize apt-get commands to reduce Docker image size (… · pytorch/pytorch@5fe58ab · GitHub
[go: up one dir, main page]

Skip to content

Commit 5fe58ab

Browse files
wdvrpytorchmergebot
authored andcommitted
Devcontainer: Optimize apt-get commands to reduce Docker image size (#152882)
## Summary - Added --no-install-recommends flag to all apt-get install commands to reduce unnecessary dependencies - Added apt-get clean after package installations to remove package cache and reduce image size - Combined multiple apt commands into single instructions to reduce Docker image layers ## Test plan Test by building the devcontainer and verifying functionality while ensuring reduced image size Pull Request resolved: #152882 Approved by: https://github.com/cyyever, https://github.com/atalman, https://github.com/Skylion007
1 parent ed63cb2 commit 5fe58ab

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

.devcontainer/Dockerfile

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,8 @@ RUN apt-get -y update && \
1414
libopenblas-dev
1515

1616
# Tools needed for llvm
17-
RUN apt-get install -y \
18-
lsb-release \
19-
wget \
20-
software-properties-common \
21-
gnupg
17+
RUN apt-get install --no-install-recommends -y lsb-release wget software-properties-common gnupg && \
18+
sudo apt-get clean -y
2219

2320
# Create Python virtual environment
2421
# RUN python3 -m venv /opt/venv
@@ -33,7 +30,8 @@ RUN if [ -n "$CLANG_VERSION" ]; then \
3330
./llvm.sh "${CLANG_VERSION}"; \
3431
echo 'export CC=clang' >> ~/.bashrc; \
3532
echo 'export CXX=clang++' >> ~/.bashrc; \
36-
apt install -y clang libomp-dev; \
33+
apt-get install --no-install-recommends -y clang libomp-dev && \
34+
apt-get clean -y; \
3735
fi
3836

3937

@@ -43,7 +41,8 @@ RUN if [ -n "$CUDA_VERSION" ]; then \
4341
CUDA_REPO_VERSION=$(echo ${CUDA_VERSION} | sed 's/\./\-/g'); \
4442
wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64/cuda-keyring_1.0-1_all.deb && \
4543
dpkg -i cuda-keyring_1.0-1_all.deb && \
46-
apt-get install -y cuda-toolkit-${CUDA_VERSION}; \
44+
apt-get install --no-install-recommends -y cuda-toolkit-${CUDA_VERSION} && \
45+
apt-get clean -y; \
4746
fi
4847

4948
# Set PATH for CUDA

0 commit comments

Comments
 (0)
0