Skip to content

Commit

Permalink
Complete support for Docker and Github Codespace (#157)
Browse files Browse the repository at this point in the history
Include support for Docker and Github Codespace so we can run our dev environment with the support of Docker.
  • Loading branch information
zhangwei217245 authored and jeanbez committed Jan 9, 2024
1 parent 2e67268 commit 3dc730c
Show file tree
Hide file tree
Showing 31 changed files with 561 additions and 350 deletions.
95 changes: 4 additions & 91 deletions .devcontainer/devcontainer.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,95 +1,8 @@
# Note: Run `docker build -f .devcontainer/Dockerfile -t pdc:latest .` from the root directory of the repository to build the docker image.

# Use Ubuntu Jammy (latest LTS) as the base image
FROM ubuntu:jammy



# Install necessary tools, MPICH, UUID library and developer files
RUN apt-get update && apt-get install -y \
build-essential \
git \
mpich \
libmpich-dev \
uuid \
uuid-dev \
autoconf \
libtool \
cmake \
cmake-curses-gui \
wget \
axel \
curl \
vim \
nano \
gdb \
cgdb \
curl \
valgrind

# Set WORK_SPACE environment variable and create necessary directories
RUN mkdir -p /workspaces
ENV WORK_SPACE=/workspaces


# Clone the repositories
WORKDIR $WORK_SPACE/source
RUN git clone https://github.com/ofiwg/libfabric.git && \
git clone https://github.com/mercury-hpc/mercury.git --recursive

COPY ./ ${WORK_SPACE}/source/pdc

ENV LIBFABRIC_SRC_DIR=$WORK_SPACE/source/libfabric
ENV MERCURY_SRC_DIR=$WORK_SPACE/source/mercury
ENV PDC_SRC_DIR=$WORK_SPACE/source/pdc
ENV LIBFABRIC_DIR=$WORK_SPACE/install/libfabric
ENV MERCURY_DIR=$WORK_SPACE/install/mercury
ENV PDC_DIR=$WORK_SPACE/install/pdc

RUN mkdir -p $LIBFABRIC_SRC_DIR && \
mkdir -p $MERCURY_SRC_DIR && \
mkdir -p $LIBFABRIC_DIR && \
mkdir -p $MERCURY_DIR && \
mkdir -p $PDC_DIR


# Save the environment variables to a file
RUN echo "export LIBFABRIC_SRC_DIR=$WORK_SPACE/source/libfabric" > $WORK_SPACE/pdc_env.sh && \
echo "export MERCURY_SRC_DIR=$WORK_SPACE/source/mercury" >> $WORK_SPACE/pdc_env.sh && \
echo "export PDC_SRC_DIR=$WORK_SPACE/source/pdc" >> $WORK_SPACE/pdc_env.sh && \
echo "export LIBFABRIC_DIR=$WORK_SPACE/install/libfabric" >> $WORK_SPACE/pdc_env.sh && \
echo "export MERCURY_DIR=$WORK_SPACE/install/mercury" >> $WORK_SPACE/pdc_env.sh && \
echo "export PDC_DIR=$WORK_SPACE/install/pdc" >> $WORK_SPACE/pdc_env.sh


# Build and install libfabric
WORKDIR $LIBFABRIC_SRC_DIR
RUN git checkout v1.18.0 && \
./autogen.sh && \
./configure --prefix=$LIBFABRIC_DIR CC=mpicc CFLAG="-O2" && \
make clean && \
make -j && make install && \
make check

ENV LD_LIBRARY_PATH="$LIBFABRIC_DIR/lib:$LD_LIBRARY_PATH"
ENV PATH="$LIBFABRIC_DIR/include:$LIBFABRIC_DIR/lib:$PATH"
RUN echo 'export LD_LIBRARY_PATH=$LIBFABRIC_DIR/lib:$LD_LIBRARY_PATH' >> $WORK_SPACE/pdc_env.sh && \
echo 'export PATH=$LIBFABRIC_DIR/include:$LIBFABRIC_DIR/lib:$PATH' >> $WORK_SPACE/pdc_env.sh


# Build and install Mercury
WORKDIR $MERCURY_SRC_DIR
ENV MERCURY_CMAKE_FLAGS="-DCMAKE_INSTALL_PREFIX=$MERCURY_DIR -DCMAKE_C_COMPILER=mpicc -DBUILD_SHARED_LIBS=ON -DBUILD_TESTING=ON -DNA_USE_OFI=ON -DNA_USE_SM=OFF -DNA_OFI_TESTING_PROTOCOL=tcp "
RUN git checkout v2.2.0 \
mkdir -p build
WORKDIR ${MERCURY_SRC_DIR}/build
RUN cmake $MERCURY_CMAKE_FLAGS ../ && \
make -j && make install && \
ctest

# Set the environment variables
ENV LD_LIBRARY_PATH="$MERCURY_DIR/lib:$LD_LIBRARY_PATH"
ENV PATH="$MERCURY_DIR/include:$MERCURY_DIR/lib:$PATH"
RUN echo 'export LD_LIBRARY_PATH=$MERCURY_DIR/lib:$LD_LIBRARY_PATH' >> $WORK_SPACE/pdc_env.sh \
echo 'export PATH=$MERCURY_DIR/include:$MERCURY_DIR/lib:$PATH' >> $WORK_SPACE/pdc_env.sh
# FROM ubuntu:jammy
FROM hpcio/pdc-dev-base:latest

RUN rm -rf $PDC_SRC_DIR && \
rm -rf $PDC_DIR
60 changes: 59 additions & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,63 @@
3000
],
"postCreateCommand": ".devcontainer/post-create.sh",
"postStartCommand": ".devcontainer/post-start.sh"
"postStartCommand": ".devcontainer/post-start.sh",
"postAttachCommand": ".devcontainer/post-attach.sh",
"customizations": {
"vscode": {
"extensions": [
"1YiB.rust-bundle",
"batisteo.vscode-django",
"ChrisChinchilla.vscode-pandoc",
"DamianKoper.gdb-debug",
"donjayamanne.python-environment-manager",
"donjayamanne.python-extension-pack",
"dustypomerleau.rust-syntax",
"eamodio.gitlens",
"formulahendry.code-runner",
"GitHub.copilot",
"GitHub.copilot-chat",
"JScearcy.rust-doc-viewer",
"julialang.language-julia",
"KevinRose.vsc-python-indent",
"lextudio.iis",
"lextudio.restructuredtext",
"lextudio.restructuredtext-pack",
"ms-azuretools.vscode-docker",
"ms-python.python",
"ms-python.vscode-pylance",
"ms-toolsai.jupyter",
"ms-toolsai.jupyter-keymap",
"ms-toolsai.jupyter-renderers",
"ms-toolsai.vscode-jupyter-cell-tags",
"ms-toolsai.vscode-jupyter-slideshow",
"ms-vscode.cmake-tools",
"ms-vscode.cpptools",
"ms-vscode.cpptools-extension-pack",
"ms-vscode.cpptools-themes",
"njpwerner.autodocstring",
"PolyMeilex.rust-targets",
"rogalmic.bash-debug",
"rust-lang.rust-analyzer",
"serayuzgur.crates",
"shakram02.bash-beautify",
"shd101wyy.markdown-preview-enhanced",
"Swellaby.rust-pack",
"tamasfe.even-better-toml",
"trond-snekvik.simple-rst",
"twxs.cmake",
"VisualStudioExptTeam.intellicode-api-usage-examples",
"VisualStudioExptTeam.vscodeintellicode",
"wholroyd.jinja",
"xaver.clang-format",
"yzane.markdown-pdf",
"yzhang.markdown-all-in-one",
"ZhangYue.rust-mod-generator"
],
"settings": {
"C_Cpp.clang_format_path": "/home/project/software/clang-format-lint-action/clang-format/clang-format10",
"terminal.integrated.scrollback": 10000
}
}
}
}
13 changes: 13 additions & 0 deletions .devcontainer/post-attach.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash


WORK_SPACE_INITIALIZED_FILE=/workspaces/.workspace_initialized

if ! [ -f $WORK_SPACE_INITIALIZED_FILE ]; then
/bin/bash /workspaces/pdc/.devcontainer/post-start.sh
watch -t -n 5 'echo "Press Ctrl+C when there is no building processes."; echo "Number of initial PDC building processes:"; ps -ef | grep make | grep -v -c grep'
else
echo "Welcome Back!"
fi

/bin/bash
40 changes: 40 additions & 0 deletions .devcontainer/post-create.sh
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1 +1,41 @@
#!/bin/bash


WORK_SPACE_INITIALIZED_FILE=/workspaces/.workspace_initialized

if ! [ -f $WORK_SPACE_INITIALIZED_FILE ]; then
touch $WORK_SPACE_INITIALIZED_FILE
echo "First time to create workspace, start to install PDC"
else
echo "Workspace already initialized, skip the installation"
exit 0
fi

rm -rf $PDC_SRC_DIR
rm -rf $PDC_DIR


ln -s /workspaces/pdc $(dirname $PDC_SRC_DIR)

mkdir -p /workspaces/source
ln -s $PDC_SRC_DIR /workspaces/source/pdc

mkdir -p /workspaces/install/pdc
ln -s /workspaces/install/pdc $(dirname $PDC_SRC_DIR)

# Build and install PDC
export PDC_CMAKE_FLAGS="-DBUILD_MPI_TESTING=ON -DBUILD_SHARED_LIBS=ON -DBUILD_TOOLS=OFF -DBUILD_TESTING=ON -DCMAKE_INSTALL_PREFIX=$PDC_DIR -DPDC_ENABLE_MPI=ON -DMERCURY_DIR=$MERCURY_DIR -DCMAKE_C_COMPILER=mpicc -DMPI_RUN_CMD=mpiexec "

cd $PDC_SRC_DIR
rm -rf build && mkdir -p build


cd ${PDC_SRC_DIR}/build
cmake $PDC_CMAKE_FLAGS ../ 2>&1 > ./cmake_config.log || echo "ignoring cmake config error and proceed"
make -j && make install

# Set the environment variables
export LD_LIBRARY_PATH="$PDC_DIR/lib:$LD_LIBRARY_PATH"
export PATH="$PDC_DIR/include:$PDC_DIR/lib:$PATH"
echo 'export LD_LIBRARY_PATH=$PDC_DIR/lib:$LD_LIBRARY_PATH' >> $WORK_SPACE/pdc_env.sh
echo 'export PATH=$PDC_DIR/include:$PDC_DIR/lib:$PATH' >> $WORK_SPACE/pdc_env.sh
31 changes: 3 additions & 28 deletions .devcontainer/post-start.sh
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,31 +1,6 @@
#!/bin/bash

nohup /bin/bash /workspaces/pdc/.devcontainer/post-create.sh 2>&1 > /workspaces/pdc_install.out &

ln -s /workspaces/pdc /home/codespace/source/pdc
mkdir -p /workspaces/install
mkdir -p /workspaces/source
ln -s $PDC_SRC_DIR /workspaces/source/pdc
ln -s $PDC_DIR /workspaces/install/pdc

export PDC_SRC_DIR=/workspaces/source/pdc

# Build and install PDC
export PDC_CMAKE_FLAGS="-DBUILD_MPI_TESTING=ON -DBUILD_SHARED_LIBS=ON -DBUILD_TESTING=ON -DCMAKE_INSTALL_PREFIX=$PDC_DIR -DPDC_ENABLE_MPI=ON -DMERCURY_DIR=$MERCURY_DIR -DCMAKE_C_COMPILER=mpicc -DMPI_RUN_CMD=mpiexec "

cd $PDC_SRC_DIR
rm -rf build && mkdir -p build


cd ${PDC_SRC_DIR}/build
cmake $PDC_CMAKE_FLAGS ../ 2>&1 > ./cmake_config.log || echo "ignoring cmake config error and proceed"
make -j && make install

# Set the environment variables
export LD_LIBRARY_PATH="$PDC_DIR/lib:$LD_LIBRARY_PATH"
export PATH="$PDC_DIR/include:$PDC_DIR/lib:$PATH"
echo 'export LD_LIBRARY_PATH=$PDC_DIR/lib:$LD_LIBRARY_PATH' >> $WORK_SPACE/pdc_env.sh
echo 'export PATH=$PDC_DIR/include:$PDC_DIR/lib:$PATH' >> $WORK_SPACE/pdc_env.sh


cd $PDC_SRC_DIR/build
# ctest
echo "Wait for 10 seconds for the building processes to start."
sleep 10s
File renamed without changes.
File renamed without changes.
79 changes: 62 additions & 17 deletions .docker/base.Dockerfile → .docker/dev_base.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,24 @@
# Note: Run `docker build -f .devcontainer/Dockerfile -t pdc:latest .` from the root directory of the repository to build the docker image.

# Use Ubuntu Jammy (latest LTS) as the base image
FROM ubuntu:jammy
ARG ARCH
FROM ${ARCH}ubuntu:jammy

RUN echo "ARCH=${ARCH}" && sleep 3

ARG ARCH_CODE

RUN echo "ARCH_CODE=${ARCH_CODE}" && sleep 3
# Install necessary tools, MPICH, UUID library and developer files
RUN apt-get update && apt-get install -y \
build-essential \
git \
mpich \
libmpich-dev \
libhdf5-dev \
libhdf5-mpich-dev \
libtiff5 \
libtiff5-dev \
uuid \
uuid-dev \
autoconf \
Expand All @@ -21,40 +33,68 @@ RUN apt-get update && apt-get install -y \
gdb \
cgdb \
curl \
valgrind
valgrind \
python3

# Install Oh My Bash
RUN bash -c "$(curl -fsSL https://raw.githubusercontent.com/ohmybash/oh-my-bash/master/tools/install.sh)" && \
sed -i 's/OSH_THEME="font"/OSH_THEME="powerline-multiline"/g' ~/.bashrc

# Install Julia

RUN echo "https://julialang-s3.julialang.org/bin/linux/aarch64/1.6/julia-1.6.7-linux-aarch64.tar.gz" > /julia_url_arm64v8.txt && \
echo "https://julialang-s3.julialang.org/bin/linux/x64/1.6/julia-1.6.7-linux-x86_64.tar.gz" > /julia_url_amd64.txt

RUN echo $(cat /julia_url_${ARCH_CODE}.txt) && sleep 3

RUN mkdir -p /opt/julia && wget -O - $(cat /julia_url_${ARCH_CODE}.txt) | tar -xz -C /opt/julia --strip-components=1 && \
ln -s /opt/julia/bin/julia /usr/local/bin/julia

RUN rm -rf /tmp/julia_url_*.txt

ENV JULIA_HOME=/opt/julia

# Install Rust
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
RUN echo 'source $HOME/.cargo/env' >> ~/.bashrc


# Set WORK_SPACE environment variable and create necessary directories
ENV WORK_SPACE=/home/codespace
ENV WORK_SPACE=/home/project
RUN mkdir -p $WORK_SPACE

# Install clang-format repo
RUN mkdir -p $WORK_SPACE/software
RUN cd $WORK_SPACE/software && git clone https://github.com/DoozyX/clang-format-lint-action.git
ENV CLANG_FORMAT_PATH=$WORK_SPACE/software/clang-format-lint-action/clang-format/clang-format10

# Clone the repositories
WORKDIR $WORK_SPACE/source
RUN git clone https://github.com/ofiwg/libfabric.git && \
git clone https://github.com/mercury-hpc/mercury.git --recursive

COPY ./ ${WORK_SPACE}/source/pdc

ENV LIBFABRIC_SRC_DIR=$WORK_SPACE/source/libfabric
ENV MERCURY_SRC_DIR=$WORK_SPACE/source/mercury
ENV PDC_SRC_DIR=$WORK_SPACE/source/pdc
ENV LIBFABRIC_DIR=$WORK_SPACE/install/libfabric
ENV MERCURY_SRC_DIR=$WORK_SPACE/source/mercury
ENV MERCURY_DIR=$WORK_SPACE/install/mercury

ENV PDC_SRC_DIR=$WORK_SPACE/source/pdc
ENV PDC_DIR=$WORK_SPACE/install/pdc

RUN mkdir -p $LIBFABRIC_SRC_DIR \
mkdir -p $MERCURY_SRC_DIR \
mkdir -p $PDC_SRC_DIR \
mkdir -p $LIBFABRIC_DIR \
mkdir -p $MERCURY_DIR \
RUN mkdir -p $LIBFABRIC_SRC_DIR && \
mkdir -p $MERCURY_SRC_DIR && \
mkdir -p $PDC_SRC_DIR && \
mkdir -p $LIBFABRIC_DIR && \
mkdir -p $MERCURY_DIR && \
mkdir -p $PDC_DIR


# Save the environment variables to a file
RUN echo "export LIBFABRIC_SRC_DIR=$WORK_SPACE/source/libfabric" > $WORK_SPACE/pdc_env.sh && \
echo "export MERCURY_SRC_DIR=$WORK_SPACE/source/mercury" >> $WORK_SPACE/pdc_env.sh && \
echo "export PDC_SRC_DIR=$WORK_SPACE/source/pdc" >> $WORK_SPACE/pdc_env.sh && \
echo "export LIBFABRIC_DIR=$WORK_SPACE/install/libfabric" >> $WORK_SPACE/pdc_env.sh && \
echo "export MERCURY_SRC_DIR=$WORK_SPACE/source/mercury" >> $WORK_SPACE/pdc_env.sh && \
echo "export MERCURY_DIR=$WORK_SPACE/install/mercury" >> $WORK_SPACE/pdc_env.sh && \
echo "export PDC_SRC_DIR=$WORK_SPACE/source/pdc" >> $WORK_SPACE/pdc_env.sh && \
echo "export PDC_DIR=$WORK_SPACE/install/pdc" >> $WORK_SPACE/pdc_env.sh


Expand All @@ -64,7 +104,7 @@ RUN git checkout v1.18.0 && \
./autogen.sh && \
./configure --prefix=$LIBFABRIC_DIR CC=mpicc CFLAG="-O2" && \
make clean && \
make -j && make install && \
make -j 8 && make install && \
make check

ENV LD_LIBRARY_PATH="$LIBFABRIC_DIR/lib:$LD_LIBRARY_PATH"
Expand All @@ -80,11 +120,16 @@ RUN git checkout v2.2.0 \
mkdir -p build
WORKDIR ${MERCURY_SRC_DIR}/build
RUN cmake $MERCURY_CMAKE_FLAGS ../ && \
make -j && make install && \
make -j 16 && make install && \
ctest

# Set the environment variables
ENV LD_LIBRARY_PATH="$MERCURY_DIR/lib:$LD_LIBRARY_PATH"
ENV PATH="$MERCURY_DIR/include:$MERCURY_DIR/lib:$PATH"
RUN echo 'export LD_LIBRARY_PATH=$MERCURY_DIR/lib:$LD_LIBRARY_PATH' >> $WORK_SPACE/pdc_env.sh \
echo 'export PATH=$MERCURY_DIR/include:$MERCURY_DIR/lib:$PATH' >> $WORK_SPACE/pdc_env.sh
echo 'export PATH=$MERCURY_DIR/include:$MERCURY_DIR/lib:$PATH' >> $WORK_SPACE/pdc_env.sh


ENV PDC_CMAKE_FLAGS="-DBUILD_MPI_TESTING=ON -DBUILD_SHARED_LIBS=ON -DBUILD_TESTING=ON -DCMAKE_INSTALL_PREFIX=$PDC_DIR -DPDC_ENABLE_MPI=ON -DMERCURY_DIR=$MERCURY_DIR -DCMAKE_C_COMPILER=mpicc -DMPI_RUN_CMD=mpiexec "

ENTRYPOINT [ "/workspaces/pdc/.devcontainer/post-attach.sh" ]
Loading

0 comments on commit 3dc730c

Please sign in to comment.