Skip to content

Commit

Permalink
feat: shared dockerfile
Browse files Browse the repository at this point in the history
  • Loading branch information
ccrutchf committed Nov 4, 2024
1 parent c651676 commit 98acf7a
Show file tree
Hide file tree
Showing 7 changed files with 117 additions and 215 deletions.
47 changes: 4 additions & 43 deletions .cpu_devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,46 +1,7 @@
FROM ubuntu:24.04
FROM ghcr.io/ucsd-e4e/fishsense-lite:cpu

SHELL ["/bin/bash", "-c"]
SHELL ["/bin/bash", "-c"]

RUN apt-get update && apt-get upgrade -y

RUN apt-get install -y sudo \
build-essential \
git \
libssl-dev \
zlib1g-dev \
libbz2-dev \
libreadline-dev \
libsqlite3-dev \
wget \
curl \
llvm \
libncurses5-dev \
libncursesw5-dev \
xz-utils \
tk-dev \
libffi-dev \
liblzma-dev \
python3-openssl \
libopencv-dev \
clang \
libclang-dev \
llvm

RUN echo 'ubuntu ALL=(ALL) NOPASSWD: ALL' >> /etc/sudoers

USER ubuntu
ENV HOME="/home/ubuntu"
RUN mkdir -p ${HOME}
WORKDIR ${HOME}

RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y

RUN git clone --depth=1 https://github.com/pyenv/pyenv.git .pyenv
ENV PYENV_ROOT="${HOME}/.pyenv"
ENV PATH="${PYENV_ROOT}/shims:${PYENV_ROOT}/bin:${PATH}"

RUN pyenv install 3.11
RUN pyenv global 3.11
RUN pip install --upgrade pip
RUN pip install poetry

CMD ["/bin/bash"]
82 changes: 3 additions & 79 deletions .cuda_devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,83 +1,7 @@
FROM nvidia/cuda:12.6.1-devel-ubuntu24.04
FROM ghcr.io/ucsd-e4e/fishsense-lite:cuda

SHELL ["/bin/bash", "-c"]
SHELL ["/bin/bash", "-c"]

RUN apt-get update && apt-get upgrade -y

RUN apt-get install -y sudo \
build-essential \
git \
libssl-dev \
zlib1g-dev \
libbz2-dev \
libreadline-dev \
libsqlite3-dev \
wget \
curl \
llvm \
libncurses5-dev \
libncursesw5-dev \
xz-utils \
tk-dev \
libffi-dev \
liblzma-dev \
python3-openssl \
libopencv-dev \
clang \
libclang-dev \
llvm \
python3-dev \
libpython3-dev \
ocl-icd-libopencl1 \
cmake \
pkg-config \
make \
ninja-build \
ocl-icd-libopencl1 \
ocl-icd-dev \
ocl-icd-opencl-dev \
libhwloc-dev \
clinfo \
dialog \
apt-utils \
libxml2-dev \
libclang-cpp-dev \
llvm-dev

# NVIDIA does not provide OpenCL passthru.
# POCL supports a CUDA-based OpenCL driver
RUN git clone https://github.com/pocl/pocl.git /pocl
WORKDIR /pocl
RUN git checkout v6.0
RUN mkdir build
WORKDIR /pocl/build
RUN cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/ -DENABLE_CUDA=ON .. && \
make -j && \
make install

RUN echo 'ubuntu ALL=(ALL) NOPASSWD: ALL' >> /etc/sudoers

USER ubuntu
ENV HOME="/home/ubuntu"
RUN mkdir -p ${HOME}
WORKDIR ${HOME}

RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y

RUN git clone --depth=1 https://github.com/pyenv/pyenv.git .pyenv
ENV PYENV_ROOT="${HOME}/.pyenv"
ENV PATH="${PYENV_ROOT}/shims:${PYENV_ROOT}/bin:${PATH}"

RUN pyenv install 3.11
RUN pyenv global 3.11
RUN pip install --upgrade pip
RUN pip install poetry

# We want access to all of the GPUs but do not want to expose any CPU devices
RUN echo "unset POCL_DEVICES" >> ${HOME}/.bashrc && \
echo "gpu_count=\`nvidia-smi --query-gpu=name --format=csv,noheader | wc -l\`" >> ${HOME}/.bashrc && \
echo "cuda=cuda" >> ${HOME}/.bashrc && \
echo "for i in \$(seq \$gpu_count); do" >> ${HOME}/.bashrc && \
echo " export POCL_DEVICES=\$cuda\$POCL_DEVICES" >> ${HOME}/.bashrc && \
echo " cuda=',cuda'" >> ${HOME}/.bashrc && \
echo "done" >> ${HOME}/.bashrc
CMD ["/bin/bash"]
46 changes: 43 additions & 3 deletions .github/workflows/docker-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,32 @@ jobs:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
-
name: Build and push
name: Build Base
uses: docker/build-push-action@v6
with:
context: .
file: docker/Dockerfile.base
build-args:
-IMAGE=nvidia/cuda:12.6.1-devel-ubuntu24.04
tags: ghcr.io/ucsd-e4e/fishsense-lite:base-cuda
push: false
-
name: Build Middle
uses: docker/build-push-action@v6
with:
context: .
file: docker/Dockerfile.cuda
tags: ghcr.io/ucsd-e4e/fishsense-lite:mid-cuda
push: false
-
name: Build and push
uses: docker/build-push-action@v6
with:
context: .
file: docker/Dockerfile
tags: ghcr.io/ucsd-e4e/fishsense-lite:cuda
build-args:
-IMAGE=ghcr.io/ucsd-e4e/fishsense-lite:mid-cuda
push: true

build-cpu:
Expand All @@ -52,10 +72,30 @@ jobs:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
-
name: Build and push
name: Build Base
uses: docker/build-push-action@v6
with:
context: .
file: docker/Dockerfile.base
build-args:
-IMAGE=ubuntu:24.04
tags: ghcr.io/ucsd-e4e/fishsense-lite:base-cpu
push: false
-
name: Build Middle
uses: docker/build-push-action@v6
with:
context: .
file: docker/Dockerfile.cpu
tags: ghcr.io/ucsd-e4e/fishsense-lite:latest
tags: ghcr.io/ucsd-e4e/fishsense-lite:mid-cpu
push: false
-
name: Build and push
uses: docker/build-push-action@v6
with:
context: .
file: docker/Dockerfile
tags: ghcr.io/ucsd-e4e/fishsense-lite:cpu
build-args:
-IMAGE=ghcr.io/ucsd-e4e/fishsense-lite:mid-cpu
push: true
26 changes: 26 additions & 0 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
ARG IMAGE=ghcr.io/ucsd-e4e/fishsense-lite:base-cpu
FROM $IMAGE

RUN echo 'ubuntu ALL=(ALL) NOPASSWD: ALL' >> /etc/sudoers

USER ubuntu
ENV HOME="/home/ubuntu"
RUN mkdir -p ${HOME}
WORKDIR ${HOME}

RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
RUN echo ". \"\$HOME/.cargo/env\"" >> ${HOME}/.bashrc

RUN git clone --depth=1 https://github.com/pyenv/pyenv.git .pyenv
ENV PYENV_ROOT="${HOME}/.pyenv"
ENV PATH="${PYENV_ROOT}/shims:${PYENV_ROOT}/bin:${PATH}"
RUN echo "export PYENV_ROOT=\"\$HOME/.pyenv\"" >> ${HOME}/.bashrc && \
echo "[[ -d \$PYENV_ROOT/bin ]] && export PATH="\$PYENV_ROOT/bin:\$PATH"" >> ${HOME}/.bashrc && \
echo "eval \"\$(pyenv init -)\"" >> ${HOME}/.bashrc && \
echo "\"$(pyenv virtualenv-init -)\"" >> ${HOME}/.bashrc

RUN pyenv install 3.11
RUN pyenv global 3.11
RUN pip install --upgrade pip && pip cache purge

CMD ["/bin/bash"]
33 changes: 33 additions & 0 deletions docker/Dockerfile.base
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
ARG IMAGE=ghcr.io/ucsd-e4e/fishsense-lite:mid-cpu
FROM $IMAGE

SHELL ["/bin/bash", "-c"]

RUN apt-get update && apt-get upgrade -y && \
apt-get clean && rm -rf /var/lib/apt/lists/*

RUN apt-get update && apt-get install -y sudo \
build-essential \
git \
libssl-dev \
zlib1g-dev \
libbz2-dev \
libreadline-dev \
libsqlite3-dev \
wget \
curl \
llvm \
libncurses5-dev \
libncursesw5-dev \
xz-utils \
tk-dev \
libffi-dev \
liblzma-dev \
python3-openssl \
libopencv-dev \
clang \
libclang-dev \
llvm \
&& apt-get clean && rm -rf /var/lib/apt/lists/*

CMD ["/bin/bash"]
49 changes: 3 additions & 46 deletions docker/Dockerfile.cpu
Original file line number Diff line number Diff line change
@@ -1,49 +1,6 @@
FROM ubuntu:24.04
FROM ghcr.io/ucsd-e4e/fishsense-lite:base-cpu

SHELL ["/bin/bash", "-c"]

RUN apt-get update && apt-get upgrade -y && \
apt-get clean && rm -rf /var/lib/apt/lists/*

RUN apt-get update && apt-get install -y sudo \
build-essential \
git \
libssl-dev \
zlib1g-dev \
libbz2-dev \
libreadline-dev \
libsqlite3-dev \
wget \
curl \
llvm \
libncurses5-dev \
libncursesw5-dev \
xz-utils \
tk-dev \
libffi-dev \
liblzma-dev \
python3-openssl \
libopencv-dev \
clang \
libclang-dev \
llvm \
&& apt-get clean && rm -rf /var/lib/apt/lists/*

RUN echo 'ubuntu ALL=(ALL) NOPASSWD: ALL' >> /etc/sudoers

USER ubuntu
ENV HOME="/home/ubuntu"
RUN mkdir -p ${HOME}
WORKDIR ${HOME}

RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y

RUN git clone --depth=1 https://github.com/pyenv/pyenv.git .pyenv
ENV PYENV_ROOT="${HOME}/.pyenv"
ENV PATH="${PYENV_ROOT}/shims:${PYENV_ROOT}/bin:${PATH}"

RUN pyenv install 3.11
RUN pyenv global 3.11
RUN pip install --upgrade pip && pip cache purge
# Do work that is specific to the CPU dockerfile here.
# This should end as root.

CMD ["/bin/bash"]
49 changes: 5 additions & 44 deletions docker/Dockerfile.cuda
Original file line number Diff line number Diff line change
@@ -1,32 +1,9 @@
FROM nvidia/cuda:12.6.1-devel-ubuntu24.04
FROM ghcr.io/ucsd-e4e/fishsense-lite:base-cuda

SHELL ["/bin/bash", "-c"]
# Do work that is specific to the CPU dockerfile here.
# This should end as root.

RUN apt-get update && apt-get upgrade -y && \
apt-get clean && rm -rf /var/lib/apt/lists/*

RUN apt-get update && apt-get install -y sudo \
build-essential \
git \
libssl-dev \
zlib1g-dev \
libbz2-dev \
libreadline-dev \
libsqlite3-dev \
wget \
curl \
llvm \
libncurses5-dev \
libncursesw5-dev \
xz-utils \
tk-dev \
libffi-dev \
liblzma-dev \
python3-openssl \
libopencv-dev \
clang \
libclang-dev \
llvm \
RUN apt-get update && apt-get install -y \
python3-dev \
libpython3-dev \
ocl-icd-libopencl1 \
Expand Down Expand Up @@ -58,29 +35,13 @@ RUN cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/ -DENABLE_CUDA=ON .
make install && \
rm -rf /pocl

RUN echo 'ubuntu ALL=(ALL) NOPASSWD: ALL' >> /etc/sudoers

USER ubuntu
ENV HOME="/home/ubuntu"
RUN mkdir -p ${HOME}
WORKDIR ${HOME}

# We want access to all of the GPUs but do not want to expose any CPU devices
RUN echo "export POCL_DEVICES=cuda" >> ${HOME}/.bashrc

RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
RUN echo ". \"\$HOME/.cargo/env\"" >> ${HOME}/.bashrc

RUN git clone --depth=1 https://github.com/pyenv/pyenv.git .pyenv
ENV PYENV_ROOT="${HOME}/.pyenv"
ENV PATH="${PYENV_ROOT}/shims:${PYENV_ROOT}/bin:${PATH}"
RUN echo "export PYENV_ROOT=\"\$HOME/.pyenv\"" >> ${HOME}/.bashrc && \
echo "[[ -d \$PYENV_ROOT/bin ]] && export PATH="\$PYENV_ROOT/bin:\$PATH"" >> ${HOME}/.bashrc && \
echo "eval \"\$(pyenv init -)\"" >> ${HOME}/.bashrc && \
echo "\"$(pyenv virtualenv-init -)\"" >> ${HOME}/.bashrc

RUN pyenv install 3.11
RUN pyenv global 3.11
RUN pip install --upgrade pip && pip cache purge
USER root

CMD ["/bin/bash"]

0 comments on commit 98acf7a

Please sign in to comment.