Skip to content

refactor(container): reduce layers and image size. Add .devcontainer.json sample. #192

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 8, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
refactor(container): reduce layers and image size
- Combines the RUN commands to reduce image layers where possible.
- Clean apt/dnf package cache and remove downloaded package files.
  • Loading branch information
jorge-ortega committed Apr 7, 2025
commit 0dba2b2d3b31ed4bfd50bd942b0f1b5b5bafdc68
28 changes: 15 additions & 13 deletions container/rockylinux9-cuda12/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ RUN dnf -y install \
redhat-rpm-config \
which \
xz \
zlib-devel
zlib-devel && \
dnf clean all

# Needed to build `path_tracer`, `optix/ex03_window` example
RUN dnf -y install \
Expand All @@ -16,30 +17,31 @@ RUN dnf -y install \
libX11-devel \
libXcursor-devel \
libXi-devel \
libXrandr-devel
libXrandr-devel && \
dnf clean all

# Get LLVM 7 & libffi.so.6
WORKDIR /data/llvm7
RUN curl -sSf -L -O https://dl.fedoraproject.org/pub/epel/9/Everything/x86_64/Packages/l/libffi3.1-3.1-36.el9.x86_64.rpm
RUN curl -sSf -L -O https://dl.fedoraproject.org/pub/epel/8/Everything/x86_64/Packages/l/llvm7.0-7.0.1-7.el8.x86_64.rpm
RUN curl -sSf -L -O https://dl.fedoraproject.org/pub/epel/8/Everything/x86_64/Packages/l/llvm7.0-devel-7.0.1-7.el8.x86_64.rpm
RUN curl -sSf -L -O https://dl.fedoraproject.org/pub/epel/8/Everything/x86_64/Packages/l/llvm7.0-libs-7.0.1-7.el8.x86_64.rpm
RUN curl -sSf -L -O https://dl.fedoraproject.org/pub/epel/8/Everything/x86_64/Packages/l/llvm7.0-static-7.0.1-7.el8.x86_64.rpm
RUN dnf -y install ./*.rpm
RUN ln -s /usr/bin/llvm-config-7-64 /usr/bin/llvm-config
RUN curl -sSf -L -O https://dl.fedoraproject.org/pub/epel/9/Everything/x86_64/Packages/l/libffi3.1-3.1-36.el9.x86_64.rpm && \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Merging curl RUNs are fine since I think no many people would like to modify it.

curl -sSf -L -O https://dl.fedoraproject.org/pub/epel/8/Everything/x86_64/Packages/l/llvm7.0-7.0.1-7.el8.x86_64.rpm && \
curl -sSf -L -O https://dl.fedoraproject.org/pub/epel/8/Everything/x86_64/Packages/l/llvm7.0-devel-7.0.1-7.el8.x86_64.rpm && \
curl -sSf -L -O https://dl.fedoraproject.org/pub/epel/8/Everything/x86_64/Packages/l/llvm7.0-libs-7.0.1-7.el8.x86_64.rpm && \
curl -sSf -L -O https://dl.fedoraproject.org/pub/epel/8/Everything/x86_64/Packages/l/llvm7.0-static-7.0.1-7.el8.x86_64.rpm && \
dnf -y install ./*.rpm && \
ln -s /usr/bin/llvm-config-7-64 /usr/bin/llvm-config && \
rm -rf ./*.rpm && \
dnf clean all

# Get Rust
RUN curl -sSf -L https://sh.rustup.rs | bash -s -- -y
ENV PATH="/root/.cargo/bin:${PATH}"

# Setup the workspace
ADD ./rust-toolchain.toml /data/Rust-CUDA/
WORKDIR /data/Rust-CUDA
RUN rustup show
RUN rm -f "rust-toolchain.toml"
RUN --mount=type=bind,source=rust-toolchain.toml,target=/data/Rust-CUDA/rust-toolchain.toml \
rustup show

# Add nvvm to LD_LIBRARY_PATH.
ENV LD_LIBRARY_PATH="/usr/local/cuda/nvvm/lib64:${LD_LIBRARY_PATH}"

ENV LLVM_LINK_STATIC=1
ENV RUST_LOG=info
31 changes: 16 additions & 15 deletions container/ubuntu22-cuda11/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,47 +1,48 @@
FROM nvidia/cuda:11.8.0-cudnn8-devel-ubuntu22.04

RUN apt-get update
RUN DEBIAN_FRONTEND=noninteractive apt-get -qq -y install \
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get -qq -y install \
build-essential \
curl \
clang \
libssl-dev \
libtinfo-dev \
pkg-config \
xz-utils \
zlib1g-dev
zlib1g-dev && \
rm -rf /var/lib/apt/lists/*

# Needed to build `path_tracer`, `optix/ex03_window` example
RUN DEBIAN_FRONTEND=noninteractive apt-get -qq -y install \
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get -qq -y install \
cmake \
libfontconfig-dev \
libx11-xcb-dev \
libxcursor-dev \
libxi-dev \
libxinerama-dev \
libxrandr-dev
libxrandr-dev && \
rm -rf /var/lib/apt/lists/*

# Get LLVM 7
WORKDIR /data/llvm7
RUN curl -sSf -L -O http://mirrors.kernel.org/ubuntu/pool/universe/l/llvm-toolchain-7/llvm-7_7.0.1-12_amd64.deb
RUN curl -sSf -L -O http://mirrors.kernel.org/ubuntu/pool/universe/l/llvm-toolchain-7/llvm-7-dev_7.0.1-12_amd64.deb
RUN curl -sSf -L -O http://mirrors.kernel.org/ubuntu/pool/universe/l/llvm-toolchain-7/libllvm7_7.0.1-12_amd64.deb
RUN curl -sSf -L -O http://mirrors.kernel.org/ubuntu/pool/universe/l/llvm-toolchain-7/llvm-7-runtime_7.0.1-12_amd64.deb
RUN apt-get install -y ./*.deb
RUN ln -s /usr/bin/llvm-config-7 /usr/bin/llvm-config
RUN curl -sSf -L -O http://mirrors.kernel.org/ubuntu/pool/universe/l/llvm-toolchain-7/llvm-7_7.0.1-12_amd64.deb && \
curl -sSf -L -O http://mirrors.kernel.org/ubuntu/pool/universe/l/llvm-toolchain-7/llvm-7-dev_7.0.1-12_amd64.deb && \
curl -sSf -L -O http://mirrors.kernel.org/ubuntu/pool/universe/l/llvm-toolchain-7/libllvm7_7.0.1-12_amd64.deb && \
curl -sSf -L -O http://mirrors.kernel.org/ubuntu/pool/universe/l/llvm-toolchain-7/llvm-7-runtime_7.0.1-12_amd64.deb && \
apt-get update && apt-get install -y ./*.deb && \
ln -s /usr/bin/llvm-config-7 /usr/bin/llvm-config && \
rm -rf ./*.deb && \
rm -rf /var/lib/apt/lists/*

# Get Rust
RUN curl -sSf -L https://sh.rustup.rs | bash -s -- -y
ENV PATH="/root/.cargo/bin:${PATH}"

# Setup the workspace
ADD ./rust-toolchain.toml /data/Rust-CUDA/
WORKDIR /data/Rust-CUDA
RUN rustup show
RUN rm -f "rust-toolchain.toml"
RUN --mount=type=bind,source=rust-toolchain.toml,target=/data/Rust-CUDA/rust-toolchain.toml \
rustup show

# Add nvvm to LD_LIBRARY_PATH.
ENV LD_LIBRARY_PATH="/usr/local/cuda/nvvm/lib64:${LD_LIBRARY_PATH}"

ENV LLVM_LINK_STATIC=1
ENV RUST_LOG=info
31 changes: 16 additions & 15 deletions container/ubuntu22-cuda12/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,47 +1,48 @@
FROM nvidia/cuda:12.8.1-cudnn-devel-ubuntu22.04

RUN apt-get update
RUN DEBIAN_FRONTEND=noninteractive apt-get -qq -y install \
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get -qq -y install \
build-essential \
curl \
clang \
libssl-dev \
libtinfo-dev \
pkg-config \
xz-utils \
zlib1g-dev
zlib1g-dev && \
rm -rf /var/lib/apt/lists/*

# Needed to build `path_tracer`, `optix/ex03_window` example
RUN DEBIAN_FRONTEND=noninteractive apt-get -qq -y install \
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get -qq -y install \
cmake \
libfontconfig-dev \
libx11-xcb-dev \
libxcursor-dev \
libxi-dev \
libxinerama-dev \
libxrandr-dev
libxrandr-dev && \
rm -rf /var/lib/apt/lists/*

# Get LLVM 7
WORKDIR /data/llvm7
RUN curl -sSf -L -O http://mirrors.kernel.org/ubuntu/pool/universe/l/llvm-toolchain-7/llvm-7_7.0.1-12_amd64.deb
RUN curl -sSf -L -O http://mirrors.kernel.org/ubuntu/pool/universe/l/llvm-toolchain-7/llvm-7-dev_7.0.1-12_amd64.deb
RUN curl -sSf -L -O http://mirrors.kernel.org/ubuntu/pool/universe/l/llvm-toolchain-7/libllvm7_7.0.1-12_amd64.deb
RUN curl -sSf -L -O http://mirrors.kernel.org/ubuntu/pool/universe/l/llvm-toolchain-7/llvm-7-runtime_7.0.1-12_amd64.deb
RUN apt-get install -y ./*.deb
RUN ln -s /usr/bin/llvm-config-7 /usr/bin/llvm-config
RUN curl -sSf -L -O http://mirrors.kernel.org/ubuntu/pool/universe/l/llvm-toolchain-7/llvm-7_7.0.1-12_amd64.deb && \
curl -sSf -L -O http://mirrors.kernel.org/ubuntu/pool/universe/l/llvm-toolchain-7/llvm-7-dev_7.0.1-12_amd64.deb && \
curl -sSf -L -O http://mirrors.kernel.org/ubuntu/pool/universe/l/llvm-toolchain-7/libllvm7_7.0.1-12_amd64.deb && \
curl -sSf -L -O http://mirrors.kernel.org/ubuntu/pool/universe/l/llvm-toolchain-7/llvm-7-runtime_7.0.1-12_amd64.deb && \
apt-get update && apt-get install -y ./*.deb && \
ln -s /usr/bin/llvm-config-7 /usr/bin/llvm-config && \
rm -rf ./*.deb && \
rm -rf /var/lib/apt/lists/*

# Get Rust
RUN curl -sSf -L https://sh.rustup.rs | bash -s -- -y
ENV PATH="/root/.cargo/bin:${PATH}"

# Setup the workspace
ADD ./rust-toolchain.toml /data/Rust-CUDA/
WORKDIR /data/Rust-CUDA
RUN rustup show
RUN rm -f "rust-toolchain.toml"
RUN --mount=type=bind,source=rust-toolchain.toml,target=/data/Rust-CUDA/rust-toolchain.toml \
rustup show

# Add nvvm to LD_LIBRARY_PATH.
ENV LD_LIBRARY_PATH="/usr/local/cuda/nvvm/lib64:${LD_LIBRARY_PATH}"

ENV LLVM_LINK_STATIC=1
ENV RUST_LOG=info
33 changes: 17 additions & 16 deletions container/ubuntu24-cuda12/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,48 +1,49 @@
FROM nvidia/cuda:12.8.1-cudnn-devel-ubuntu24.04

RUN apt-get update
RUN DEBIAN_FRONTEND=noninteractive apt-get -qq -y install \
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get -qq -y install \
build-essential \
clang \
curl \
libssl-dev \
libtinfo-dev \
pkg-config \
xz-utils \
zlib1g-dev
zlib1g-dev && \
rm -rf /var/lib/apt/lists/*

# Needed to build `path_tracer`, `optix/ex03_window` example
RUN DEBIAN_FRONTEND=noninteractive apt-get -qq -y install \
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get -qq -y install \
cmake \
libfontconfig-dev \
libx11-xcb-dev \
libxcursor-dev \
libxi-dev \
libxinerama-dev \
libxrandr-dev
libxrandr-dev && \
rm -rf /var/lib/apt/lists/*

# Get LLVM 7 & libffi7
WORKDIR /data/llvm7
RUN curl -sSf -L -O http://security.ubuntu.com/ubuntu/pool/universe/libf/libffi7/libffi7_3.3-5ubuntu1_amd64.deb
RUN curl -sSf -L -O http://mirrors.kernel.org/ubuntu/pool/universe/l/llvm-toolchain-7/llvm-7_7.0.1-12_amd64.deb
RUN curl -sSf -L -O http://mirrors.kernel.org/ubuntu/pool/universe/l/llvm-toolchain-7/llvm-7-dev_7.0.1-12_amd64.deb
RUN curl -sSf -L -O http://mirrors.kernel.org/ubuntu/pool/universe/l/llvm-toolchain-7/libllvm7_7.0.1-12_amd64.deb
RUN curl -sSf -L -O http://mirrors.kernel.org/ubuntu/pool/universe/l/llvm-toolchain-7/llvm-7-runtime_7.0.1-12_amd64.deb
RUN apt-get install -y ./*.deb
RUN ln -s /usr/bin/llvm-config-7 /usr/bin/llvm-config
RUN curl -sSf -L -O http://security.ubuntu.com/ubuntu/pool/universe/libf/libffi7/libffi7_3.3-5ubuntu1_amd64.deb && \
curl -sSf -L -O http://mirrors.kernel.org/ubuntu/pool/universe/l/llvm-toolchain-7/llvm-7_7.0.1-12_amd64.deb && \
curl -sSf -L -O http://mirrors.kernel.org/ubuntu/pool/universe/l/llvm-toolchain-7/llvm-7-dev_7.0.1-12_amd64.deb && \
curl -sSf -L -O http://mirrors.kernel.org/ubuntu/pool/universe/l/llvm-toolchain-7/libllvm7_7.0.1-12_amd64.deb && \
curl -sSf -L -O http://mirrors.kernel.org/ubuntu/pool/universe/l/llvm-toolchain-7/llvm-7-runtime_7.0.1-12_amd64.deb && \
apt-get install -y ./*.deb && \
ln -s /usr/bin/llvm-config-7 /usr/bin/llvm-config && \
rm -rf ./*.deb && \
rm -rf /var/lib/apt/lists/*

# Get Rust
RUN curl -sSf -L https://sh.rustup.rs | bash -s -- -y
ENV PATH="/root/.cargo/bin:${PATH}"

# Setup the workspace
ADD ./rust-toolchain.toml /data/Rust-CUDA/
WORKDIR /data/Rust-CUDA
RUN rustup show
RUN rm -f "rust-toolchain.toml"
RUN --mount=type=bind,source=rust-toolchain.toml,target=/data/Rust-CUDA/rust-toolchain.toml \
rustup show

# Add nvvm to LD_LIBRARY_PATH.
ENV LD_LIBRARY_PATH="/usr/local/cuda/nvvm/lib64:${LD_LIBRARY_PATH}"

ENV LLVM_LINK_STATIC=1
ENV RUST_LOG=info