-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDockerfile
153 lines (130 loc) · 5.1 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
# Dockerfile for building a CPU-only environment for the aperi-mech project
# Base Image: Ubuntu 22.04
# This Dockerfile sets up a python and spack environment with necessary packages
# After building the image, the user can run the container and start working on the aperi-mech project.
# Building the project:
# 1. This assume the user has the aperi-mech project cloned in the same directory as the Dockerfile
# 2. Build the docker image using the following command:
# docker build -t aperi-mech:latest .
# 3. Run the docker container using the following command (uses the docker-compose.yml file in the aperi-mech project):
# docker-compose run --service-ports aperi-mech-development /bin/bash
# 4. Start working on the aperi-mech project
# - Configure the project
# ./do_configure
# - Build the project:
# cd build/Release
# make -j 4
# - Run the project unit tests:
# make run_all_unit_tests
# - Run the project regression tests:
# TODO(jake) implement: make run_all_regression_tests
# - Run the project performance tests:
# TODO(jake) implement: make run_all_performance_tests
# Base image
FROM ubuntu:22.04
# Avoid prompts from apt
ENV DEBIAN_FRONTEND=noninteractive
#################### System Packages from apt ####################
# Install necessary packages
# trunk-ignore(hadolint/DL3008)
# trunk-ignore(checkov/CKV2_DOCKER_1)
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential \
ca-certificates \
coreutils \
curl \
environment-modules \
file \
gfortran \
git \
git-lfs \
gpg \
lcov \
libcurl4-openssl-dev \
libgl1 \
libglu1-mesa \
libssl-dev \
lsb-release \
openssl \
python3 \
python3-distutils \
python3-venv \
python3-pip \
sudo \
unzip \
vim \
xorg \
zip \
&& rm -rf /var/lib/apt/lists/*
#################### User Setup ####################
# Create a non-root user
RUN useradd -m aperi-mech_docker
# Switch back to root user
USER root
# Configure passwordless sudo for the user
RUN echo "aperi-mech_docker ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers
# Change to the new user
USER aperi-mech_docker
# Make the working directory
WORKDIR /home/aperi-mech_docker
# Set the HOME environment variable
ENV HOME=/home/aperi-mech_docker
#################### Python Packages ####################
# Install python packages using pip
RUN pip3 install --no-input --no-cache-dir \
pytest==8.3.2 \
testbook==0.4.2 \
jupyter==1.0.0 \
jupyterlab==4.2.4 \
numpy==2.0.1 \
scipy==1.14.0 \
matplotlib==3.9.1 \
ipykernel==6.29.5 \
meshio==5.3.5 \
gmsh==4.13.1 \
netCDF4==1.7.1.post1 \
pandas==2.2.3 \
&& rm -rf ~/.cache/pip
# Add environment to Jupyter
RUN python3 -m ipykernel install --user --name aperi-mech --display-name "aperi-mech"
# Add .local/bin to the PATH
ENV PATH="${HOME}/.local/bin:$PATH"
#################### Spack Installation and Setup ####################
# Clone Spack repo
RUN git clone -c feature.manyFiles=true https://github.com/spack/spack.git ${HOME}/spack
# Set up Spack environment
ENV SPACK_ROOT=${HOME}/spack
ENV PATH="$SPACK_ROOT/bin:$PATH"
RUN . $SPACK_ROOT/share/spack/setup-env.sh
# Find compilers and externals for Spack
RUN spack compiler find && \
spack external find
# Create a new Spack environment, cpu build
RUN spack env create aperi-mech
# Add packages to the Spack environment, aperi-mech
# Compadre should be version 1.5.9 (need to update the spack package to get that version as of July 2024)
RUN . $SPACK_ROOT/share/spack/setup-env.sh && \
spack -e aperi-mech add compadre@master ~tests && \
spack -e aperi-mech add [email protected] ~cuda ~shared && \
spack -e aperi-mech add [email protected] ~cuda ~shared cxxstd=17 && \
spack -e aperi-mech add trilinos@master ~amesos ~amesos2 ~anasazi ~aztec ~belos ~cuda ~epetra ~epetraext ~ifpack ~ifpack2 ~ml ~muelu ~sacado ~shared +exodus +gtest +hdf5 +mpi +stk +zoltan +zoltan2 cxxstd=17 && \
spack -e aperi-mech add [email protected] && \
spack -e aperi-mech add [email protected] && \
spack -e aperi-mech add eigen@master
# eigen@master is used as [email protected] has a lot of GPU related warnings
# Install Packages, aperi-mech
RUN . $SPACK_ROOT/share/spack/setup-env.sh && \
spack -e aperi-mech install --fresh
# Create a new Spack environment, for seacas. Want seacas without mpi, which causes conflicts with trilinos
RUN spack env create seacas
# Add packages to the Spack environment, seacas
RUN . $SPACK_ROOT/share/spack/setup-env.sh && \
spack -e seacas add openmpi && \
spack -e seacas add seacas ~mpi ~tests ~x11
# Install Packages, seacas
RUN . $SPACK_ROOT/share/spack/setup-env.sh && \
spack -e seacas install --fresh
# Add the spack source command to the bashrc
RUN echo "source ${SPACK_ROOT}/share/spack/setup-env.sh" >> ${HOME}/.bashrc
# HEALTHCHECK to verify Spack and Python availability
HEALTHCHECK --interval=1m --timeout=10s --start-period=5s --retries=3 CMD /bin/bash -c "source ${SPACK_ROOT}/share/spack/setup-env.sh && python3 --version || exit 1"