-
Notifications
You must be signed in to change notification settings - Fork 256
Expand file tree
/
Copy pathDockerfile.devito
More file actions
105 lines (78 loc) · 3.14 KB
/
Copy pathDockerfile.devito
File metadata and controls
105 lines (78 loc) · 3.14 KB
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
##############################################################
# This Dockerfile contains Devito and can be built using different base images.
##############################################################
# Base image with compilers
ARG base=devitocodes/bases:cpu-gcc
FROM $base AS builder
# User/Group Ids
ARG USER_ID=1000
ARG GROUP_ID=1000
################## Install devito ############################################
ENV PIP_USE_PEP517=1
# Install pip dependencies
RUN python3 -m venv /venv && \
/venv/bin/pip install --no-cache-dir --upgrade pip wheel setuptools && \
/venv/bin/pip install --no-cache-dir jupyter && \
ln -fs /app/nvtop/build/src/nvtop /venv/bin/nvtop
# Copy Devito
ADD . /app/devito
# Remove git files
RUN rm -rf /app/devito/.git
# Mpi4py
RUN eval "$MPI4PY_FLAGS /venv/bin/pip install --no-cache-dir --verbose -r /app/devito/requirements-mpi.txt"
# Devito
RUN /venv/bin/pip install --no-cache-dir -e /app/devito[extras,tests] && rm -rf ~/.cache/pip
FROM $base AS utilities
# tmpi
RUN curl https://raw.githubusercontent.com/Azrael3000/tmpi/master/tmpi -o /usr/local/bin/tmpi
# Update if outdated and install extras
RUN apt-get update && apt-get install -y \
libncurses5-dev libncursesw5-dev libdrm-dev libsystemd-dev \
python3-dbg gdb numactl tmux vim
# Install OpenGL library, necessary for the installation of GemPy
RUN apt-get install -y libgl1-mesa-glx
# Nvtop
RUN export LD_LIBRARY_PATH=/usr/lib/x86_64-linux-gnu/:$LD_LIBRARY_PATH && \
git clone https://github.com/Syllo/nvtop.git /app/nvtop && \
mkdir -p /app/nvtop/build && cd /app/nvtop/build && \
cmake .. -DNVIDIA_SUPPORT=ON -DAMDGPU_SUPPORT=ON -DINTEL_SUPPORT=ON && \
make && make install
# cleanup
RUN apt-get clean && apt-get autoclean && apt-get autoremove -y && \
rm -rf /var/lib/apt/lists/*
FROM utilities AS user
# COPY is much faster than RUN chown by order of magnitude so we have a final step that
# just copies the built image into the user.
# User/Group Ids
ARG USER_ID=1000
ARG GROUP_ID=1000
## Create App user
# Set the home directory to our app user's home.
ENV HOME=/app
ENV APP_HOME=/app
# Create the home directory for the new app user.
# Create an app user so our program doesn't run as root.
# Chown all the files to the app user.
RUN groupadd -g ${GROUP_ID} app && \
useradd -l -u ${USER_ID} -g app app && \
install -d -m 0755 -o app -g app /app && \
chown -R app:app $APP_HOME
COPY --from=builder --chown=app:app /app /app
COPY --from=utilities --chown=app:app /app/nvtop /app/nvtop
ADD --chown=app:app docker/run-jupyter.sh /jupyter
ADD --chown=app:app docker/run-tests.sh /tests
ADD --chown=app:app docker/run-print-defaults.sh /print-defaults
ADD --chown=app:app docker/entrypoint.sh /docker-entrypoint.sh
RUN chmod +x /print-defaults /jupyter /tests /docker-entrypoint.sh
# Venv
COPY --from=builder --chown=app:app /venv /venv
# opt
COPY --from=builder --chown=app:app /opt /opt
# Install codecov
WORKDIR /app/devito
RUN curl -Os https://uploader.codecov.io/latest/linux/codecov && chmod +x codecov && chown app:app codecov
# Change to the app user.
USER app
EXPOSE 8888
ENTRYPOINT ["/docker-entrypoint.sh"]
CMD ["/jupyter"]