Skip to content

Commit 1e03014

Browse files
Complete support for Docker and Github Codespace (#157)
Include support for Docker and Github Codespace so we can run our dev environment with the support of Docker.
1 parent bd46c46 commit 1e03014

31 files changed

+561
-350
lines changed

.devcontainer/devcontainer.Dockerfile

Lines changed: 4 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -1,95 +1,8 @@
11
# Note: Run `docker build -f .devcontainer/Dockerfile -t pdc:latest .` from the root directory of the repository to build the docker image.
22

33
# Use Ubuntu Jammy (latest LTS) as the base image
4-
FROM ubuntu:jammy
5-
6-
7-
8-
# Install necessary tools, MPICH, UUID library and developer files
9-
RUN apt-get update && apt-get install -y \
10-
build-essential \
11-
git \
12-
mpich \
13-
libmpich-dev \
14-
uuid \
15-
uuid-dev \
16-
autoconf \
17-
libtool \
18-
cmake \
19-
cmake-curses-gui \
20-
wget \
21-
axel \
22-
curl \
23-
vim \
24-
nano \
25-
gdb \
26-
cgdb \
27-
curl \
28-
valgrind
29-
30-
# Set WORK_SPACE environment variable and create necessary directories
31-
RUN mkdir -p /workspaces
32-
ENV WORK_SPACE=/workspaces
33-
34-
35-
# Clone the repositories
36-
WORKDIR $WORK_SPACE/source
37-
RUN git clone https://github.com/ofiwg/libfabric.git && \
38-
git clone https://github.com/mercury-hpc/mercury.git --recursive
39-
40-
COPY ./ ${WORK_SPACE}/source/pdc
41-
42-
ENV LIBFABRIC_SRC_DIR=$WORK_SPACE/source/libfabric
43-
ENV MERCURY_SRC_DIR=$WORK_SPACE/source/mercury
44-
ENV PDC_SRC_DIR=$WORK_SPACE/source/pdc
45-
ENV LIBFABRIC_DIR=$WORK_SPACE/install/libfabric
46-
ENV MERCURY_DIR=$WORK_SPACE/install/mercury
47-
ENV PDC_DIR=$WORK_SPACE/install/pdc
48-
49-
RUN mkdir -p $LIBFABRIC_SRC_DIR && \
50-
mkdir -p $MERCURY_SRC_DIR && \
51-
mkdir -p $LIBFABRIC_DIR && \
52-
mkdir -p $MERCURY_DIR && \
53-
mkdir -p $PDC_DIR
54-
55-
56-
# Save the environment variables to a file
57-
RUN echo "export LIBFABRIC_SRC_DIR=$WORK_SPACE/source/libfabric" > $WORK_SPACE/pdc_env.sh && \
58-
echo "export MERCURY_SRC_DIR=$WORK_SPACE/source/mercury" >> $WORK_SPACE/pdc_env.sh && \
59-
echo "export PDC_SRC_DIR=$WORK_SPACE/source/pdc" >> $WORK_SPACE/pdc_env.sh && \
60-
echo "export LIBFABRIC_DIR=$WORK_SPACE/install/libfabric" >> $WORK_SPACE/pdc_env.sh && \
61-
echo "export MERCURY_DIR=$WORK_SPACE/install/mercury" >> $WORK_SPACE/pdc_env.sh && \
62-
echo "export PDC_DIR=$WORK_SPACE/install/pdc" >> $WORK_SPACE/pdc_env.sh
63-
64-
65-
# Build and install libfabric
66-
WORKDIR $LIBFABRIC_SRC_DIR
67-
RUN git checkout v1.18.0 && \
68-
./autogen.sh && \
69-
./configure --prefix=$LIBFABRIC_DIR CC=mpicc CFLAG="-O2" && \
70-
make clean && \
71-
make -j && make install && \
72-
make check
73-
74-
ENV LD_LIBRARY_PATH="$LIBFABRIC_DIR/lib:$LD_LIBRARY_PATH"
75-
ENV PATH="$LIBFABRIC_DIR/include:$LIBFABRIC_DIR/lib:$PATH"
76-
RUN echo 'export LD_LIBRARY_PATH=$LIBFABRIC_DIR/lib:$LD_LIBRARY_PATH' >> $WORK_SPACE/pdc_env.sh && \
77-
echo 'export PATH=$LIBFABRIC_DIR/include:$LIBFABRIC_DIR/lib:$PATH' >> $WORK_SPACE/pdc_env.sh
78-
79-
80-
# Build and install Mercury
81-
WORKDIR $MERCURY_SRC_DIR
82-
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 "
83-
RUN git checkout v2.2.0 \
84-
mkdir -p build
85-
WORKDIR ${MERCURY_SRC_DIR}/build
86-
RUN cmake $MERCURY_CMAKE_FLAGS ../ && \
87-
make -j && make install && \
88-
ctest
89-
90-
# Set the environment variables
91-
ENV LD_LIBRARY_PATH="$MERCURY_DIR/lib:$LD_LIBRARY_PATH"
92-
ENV PATH="$MERCURY_DIR/include:$MERCURY_DIR/lib:$PATH"
93-
RUN echo 'export LD_LIBRARY_PATH=$MERCURY_DIR/lib:$LD_LIBRARY_PATH' >> $WORK_SPACE/pdc_env.sh \
94-
echo 'export PATH=$MERCURY_DIR/include:$MERCURY_DIR/lib:$PATH' >> $WORK_SPACE/pdc_env.sh
4+
# FROM ubuntu:jammy
5+
FROM hpcio/pdc-dev-base:latest
956

7+
RUN rm -rf $PDC_SRC_DIR && \
8+
rm -rf $PDC_DIR

.devcontainer/devcontainer.json

Lines changed: 59 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,63 @@
55
3000
66
],
77
"postCreateCommand": ".devcontainer/post-create.sh",
8-
"postStartCommand": ".devcontainer/post-start.sh"
8+
"postStartCommand": ".devcontainer/post-start.sh",
9+
"postAttachCommand": ".devcontainer/post-attach.sh",
10+
"customizations": {
11+
"vscode": {
12+
"extensions": [
13+
"1YiB.rust-bundle",
14+
"batisteo.vscode-django",
15+
"ChrisChinchilla.vscode-pandoc",
16+
"DamianKoper.gdb-debug",
17+
"donjayamanne.python-environment-manager",
18+
"donjayamanne.python-extension-pack",
19+
"dustypomerleau.rust-syntax",
20+
"eamodio.gitlens",
21+
"formulahendry.code-runner",
22+
"GitHub.copilot",
23+
"GitHub.copilot-chat",
24+
"JScearcy.rust-doc-viewer",
25+
"julialang.language-julia",
26+
"KevinRose.vsc-python-indent",
27+
"lextudio.iis",
28+
"lextudio.restructuredtext",
29+
"lextudio.restructuredtext-pack",
30+
"ms-azuretools.vscode-docker",
31+
"ms-python.python",
32+
"ms-python.vscode-pylance",
33+
"ms-toolsai.jupyter",
34+
"ms-toolsai.jupyter-keymap",
35+
"ms-toolsai.jupyter-renderers",
36+
"ms-toolsai.vscode-jupyter-cell-tags",
37+
"ms-toolsai.vscode-jupyter-slideshow",
38+
"ms-vscode.cmake-tools",
39+
"ms-vscode.cpptools",
40+
"ms-vscode.cpptools-extension-pack",
41+
"ms-vscode.cpptools-themes",
42+
"njpwerner.autodocstring",
43+
"PolyMeilex.rust-targets",
44+
"rogalmic.bash-debug",
45+
"rust-lang.rust-analyzer",
46+
"serayuzgur.crates",
47+
"shakram02.bash-beautify",
48+
"shd101wyy.markdown-preview-enhanced",
49+
"Swellaby.rust-pack",
50+
"tamasfe.even-better-toml",
51+
"trond-snekvik.simple-rst",
52+
"twxs.cmake",
53+
"VisualStudioExptTeam.intellicode-api-usage-examples",
54+
"VisualStudioExptTeam.vscodeintellicode",
55+
"wholroyd.jinja",
56+
"xaver.clang-format",
57+
"yzane.markdown-pdf",
58+
"yzhang.markdown-all-in-one",
59+
"ZhangYue.rust-mod-generator"
60+
],
61+
"settings": {
62+
"C_Cpp.clang_format_path": "/home/project/software/clang-format-lint-action/clang-format/clang-format10",
63+
"terminal.integrated.scrollback": 10000
64+
}
65+
}
66+
}
967
}

.devcontainer/post-attach.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/bin/bash
2+
3+
4+
WORK_SPACE_INITIALIZED_FILE=/workspaces/.workspace_initialized
5+
6+
if ! [ -f $WORK_SPACE_INITIALIZED_FILE ]; then
7+
/bin/bash /workspaces/pdc/.devcontainer/post-start.sh
8+
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'
9+
else
10+
echo "Welcome Back!"
11+
fi
12+
13+
/bin/bash

.devcontainer/post-create.sh

100644100755
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,41 @@
11
#!/bin/bash
2+
3+
4+
WORK_SPACE_INITIALIZED_FILE=/workspaces/.workspace_initialized
5+
6+
if ! [ -f $WORK_SPACE_INITIALIZED_FILE ]; then
7+
touch $WORK_SPACE_INITIALIZED_FILE
8+
echo "First time to create workspace, start to install PDC"
9+
else
10+
echo "Workspace already initialized, skip the installation"
11+
exit 0
12+
fi
13+
14+
rm -rf $PDC_SRC_DIR
15+
rm -rf $PDC_DIR
16+
17+
18+
ln -s /workspaces/pdc $(dirname $PDC_SRC_DIR)
19+
20+
mkdir -p /workspaces/source
21+
ln -s $PDC_SRC_DIR /workspaces/source/pdc
22+
23+
mkdir -p /workspaces/install/pdc
24+
ln -s /workspaces/install/pdc $(dirname $PDC_SRC_DIR)
25+
26+
# Build and install PDC
27+
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 "
28+
29+
cd $PDC_SRC_DIR
30+
rm -rf build && mkdir -p build
31+
32+
33+
cd ${PDC_SRC_DIR}/build
34+
cmake $PDC_CMAKE_FLAGS ../ 2>&1 > ./cmake_config.log || echo "ignoring cmake config error and proceed"
35+
make -j && make install
36+
37+
# Set the environment variables
38+
export LD_LIBRARY_PATH="$PDC_DIR/lib:$LD_LIBRARY_PATH"
39+
export PATH="$PDC_DIR/include:$PDC_DIR/lib:$PATH"
40+
echo 'export LD_LIBRARY_PATH=$PDC_DIR/lib:$LD_LIBRARY_PATH' >> $WORK_SPACE/pdc_env.sh
41+
echo 'export PATH=$PDC_DIR/include:$PDC_DIR/lib:$PATH' >> $WORK_SPACE/pdc_env.sh

.devcontainer/post-start.sh

100644100755
Lines changed: 3 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,6 @@
11
#!/bin/bash
22

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

4-
ln -s /workspaces/pdc /home/codespace/source/pdc
5-
mkdir -p /workspaces/install
6-
mkdir -p /workspaces/source
7-
ln -s $PDC_SRC_DIR /workspaces/source/pdc
8-
ln -s $PDC_DIR /workspaces/install/pdc
9-
10-
export PDC_SRC_DIR=/workspaces/source/pdc
11-
12-
# Build and install PDC
13-
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 "
14-
15-
cd $PDC_SRC_DIR
16-
rm -rf build && mkdir -p build
17-
18-
19-
cd ${PDC_SRC_DIR}/build
20-
cmake $PDC_CMAKE_FLAGS ../ 2>&1 > ./cmake_config.log || echo "ignoring cmake config error and proceed"
21-
make -j && make install
22-
23-
# Set the environment variables
24-
export LD_LIBRARY_PATH="$PDC_DIR/lib:$LD_LIBRARY_PATH"
25-
export PATH="$PDC_DIR/include:$PDC_DIR/lib:$PATH"
26-
echo 'export LD_LIBRARY_PATH=$PDC_DIR/lib:$LD_LIBRARY_PATH' >> $WORK_SPACE/pdc_env.sh
27-
echo 'export PATH=$PDC_DIR/include:$PDC_DIR/lib:$PATH' >> $WORK_SPACE/pdc_env.sh
28-
29-
30-
cd $PDC_SRC_DIR/build
31-
# ctest
5+
echo "Wait for 10 seconds for the building processes to start."
6+
sleep 10s
File renamed without changes.
Lines changed: 62 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,24 @@
1+
# Note: Run `docker build -f .devcontainer/Dockerfile -t pdc:latest .` from the root directory of the repository to build the docker image.
2+
13
# Use Ubuntu Jammy (latest LTS) as the base image
2-
FROM ubuntu:jammy
4+
ARG ARCH
5+
FROM ${ARCH}ubuntu:jammy
6+
7+
RUN echo "ARCH=${ARCH}" && sleep 3
38

9+
ARG ARCH_CODE
10+
11+
RUN echo "ARCH_CODE=${ARCH_CODE}" && sleep 3
412
# Install necessary tools, MPICH, UUID library and developer files
513
RUN apt-get update && apt-get install -y \
614
build-essential \
715
git \
816
mpich \
917
libmpich-dev \
18+
libhdf5-dev \
19+
libhdf5-mpich-dev \
20+
libtiff5 \
21+
libtiff5-dev \
1022
uuid \
1123
uuid-dev \
1224
autoconf \
@@ -21,40 +33,68 @@ RUN apt-get update && apt-get install -y \
2133
gdb \
2234
cgdb \
2335
curl \
24-
valgrind
36+
valgrind \
37+
python3
38+
39+
# Install Oh My Bash
40+
RUN bash -c "$(curl -fsSL https://raw.githubusercontent.com/ohmybash/oh-my-bash/master/tools/install.sh)" && \
41+
sed -i 's/OSH_THEME="font"/OSH_THEME="powerline-multiline"/g' ~/.bashrc
42+
43+
# Install Julia
44+
45+
RUN echo "https://julialang-s3.julialang.org/bin/linux/aarch64/1.6/julia-1.6.7-linux-aarch64.tar.gz" > /julia_url_arm64v8.txt && \
46+
echo "https://julialang-s3.julialang.org/bin/linux/x64/1.6/julia-1.6.7-linux-x86_64.tar.gz" > /julia_url_amd64.txt
47+
48+
RUN echo $(cat /julia_url_${ARCH_CODE}.txt) && sleep 3
49+
50+
RUN mkdir -p /opt/julia && wget -O - $(cat /julia_url_${ARCH_CODE}.txt) | tar -xz -C /opt/julia --strip-components=1 && \
51+
ln -s /opt/julia/bin/julia /usr/local/bin/julia
52+
53+
RUN rm -rf /tmp/julia_url_*.txt
54+
55+
ENV JULIA_HOME=/opt/julia
56+
57+
# Install Rust
58+
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
59+
RUN echo 'source $HOME/.cargo/env' >> ~/.bashrc
60+
2561

2662
# Set WORK_SPACE environment variable and create necessary directories
27-
ENV WORK_SPACE=/home/codespace
63+
ENV WORK_SPACE=/home/project
2864
RUN mkdir -p $WORK_SPACE
2965

66+
# Install clang-format repo
67+
RUN mkdir -p $WORK_SPACE/software
68+
RUN cd $WORK_SPACE/software && git clone https://github.com/DoozyX/clang-format-lint-action.git
69+
ENV CLANG_FORMAT_PATH=$WORK_SPACE/software/clang-format-lint-action/clang-format/clang-format10
70+
3071
# Clone the repositories
3172
WORKDIR $WORK_SPACE/source
3273
RUN git clone https://github.com/ofiwg/libfabric.git && \
3374
git clone https://github.com/mercury-hpc/mercury.git --recursive
3475

35-
COPY ./ ${WORK_SPACE}/source/pdc
36-
3776
ENV LIBFABRIC_SRC_DIR=$WORK_SPACE/source/libfabric
38-
ENV MERCURY_SRC_DIR=$WORK_SPACE/source/mercury
39-
ENV PDC_SRC_DIR=$WORK_SPACE/source/pdc
4077
ENV LIBFABRIC_DIR=$WORK_SPACE/install/libfabric
78+
ENV MERCURY_SRC_DIR=$WORK_SPACE/source/mercury
4179
ENV MERCURY_DIR=$WORK_SPACE/install/mercury
80+
81+
ENV PDC_SRC_DIR=$WORK_SPACE/source/pdc
4282
ENV PDC_DIR=$WORK_SPACE/install/pdc
4383

44-
RUN mkdir -p $LIBFABRIC_SRC_DIR \
45-
mkdir -p $MERCURY_SRC_DIR \
46-
mkdir -p $PDC_SRC_DIR \
47-
mkdir -p $LIBFABRIC_DIR \
48-
mkdir -p $MERCURY_DIR \
84+
RUN mkdir -p $LIBFABRIC_SRC_DIR && \
85+
mkdir -p $MERCURY_SRC_DIR && \
86+
mkdir -p $PDC_SRC_DIR && \
87+
mkdir -p $LIBFABRIC_DIR && \
88+
mkdir -p $MERCURY_DIR && \
4989
mkdir -p $PDC_DIR
5090

5191

5292
# Save the environment variables to a file
5393
RUN echo "export LIBFABRIC_SRC_DIR=$WORK_SPACE/source/libfabric" > $WORK_SPACE/pdc_env.sh && \
54-
echo "export MERCURY_SRC_DIR=$WORK_SPACE/source/mercury" >> $WORK_SPACE/pdc_env.sh && \
55-
echo "export PDC_SRC_DIR=$WORK_SPACE/source/pdc" >> $WORK_SPACE/pdc_env.sh && \
5694
echo "export LIBFABRIC_DIR=$WORK_SPACE/install/libfabric" >> $WORK_SPACE/pdc_env.sh && \
95+
echo "export MERCURY_SRC_DIR=$WORK_SPACE/source/mercury" >> $WORK_SPACE/pdc_env.sh && \
5796
echo "export MERCURY_DIR=$WORK_SPACE/install/mercury" >> $WORK_SPACE/pdc_env.sh && \
97+
echo "export PDC_SRC_DIR=$WORK_SPACE/source/pdc" >> $WORK_SPACE/pdc_env.sh && \
5898
echo "export PDC_DIR=$WORK_SPACE/install/pdc" >> $WORK_SPACE/pdc_env.sh
5999

60100

@@ -64,7 +104,7 @@ RUN git checkout v1.18.0 && \
64104
./autogen.sh && \
65105
./configure --prefix=$LIBFABRIC_DIR CC=mpicc CFLAG="-O2" && \
66106
make clean && \
67-
make -j && make install && \
107+
make -j 8 && make install && \
68108
make check
69109

70110
ENV LD_LIBRARY_PATH="$LIBFABRIC_DIR/lib:$LD_LIBRARY_PATH"
@@ -80,11 +120,16 @@ RUN git checkout v2.2.0 \
80120
mkdir -p build
81121
WORKDIR ${MERCURY_SRC_DIR}/build
82122
RUN cmake $MERCURY_CMAKE_FLAGS ../ && \
83-
make -j && make install && \
123+
make -j 16 && make install && \
84124
ctest
85125

86126
# Set the environment variables
87127
ENV LD_LIBRARY_PATH="$MERCURY_DIR/lib:$LD_LIBRARY_PATH"
88128
ENV PATH="$MERCURY_DIR/include:$MERCURY_DIR/lib:$PATH"
89129
RUN echo 'export LD_LIBRARY_PATH=$MERCURY_DIR/lib:$LD_LIBRARY_PATH' >> $WORK_SPACE/pdc_env.sh \
90-
echo 'export PATH=$MERCURY_DIR/include:$MERCURY_DIR/lib:$PATH' >> $WORK_SPACE/pdc_env.sh
130+
echo 'export PATH=$MERCURY_DIR/include:$MERCURY_DIR/lib:$PATH' >> $WORK_SPACE/pdc_env.sh
131+
132+
133+
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 "
134+
135+
ENTRYPOINT [ "/workspaces/pdc/.devcontainer/post-attach.sh" ]

0 commit comments

Comments
 (0)