/
Dockerfile.devito
63 lines (48 loc) · 2.07 KB
/
Dockerfile.devito
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
##############################################################
# This Dockerfile contains the Devito codes and can be built using different base images.
##############################################################
# Base image with compilers
ARG base=devitocodes/bases:cpu-gcc
FROM $base as builder
################## Install devito ############################################
# Copy Devito
ADD . /app/devito
# Remove git files
RUN rm -rf /app/devito/.git
# Install pip dependencies and devito as a pip package
RUN python3 -m venv /venv && \
/venv/bin/pip install --no-cache-dir --upgrade pip && \
/venv/bin/pip install --no-cache-dir jupyter && \
/venv/bin/pip install --no-cache-dir wheel && \
/venv/bin/pip install --no-cache-dir -e /app/devito[extras,mpi] && \
rm -rf ~/.cache/pip
# Safety cleanup
RUN apt-get clean && apt-get autoclean && apt-get autoremove && \
rm -rf /var/lib/apt/lists/*
FROM $base 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.
## 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 mkdir -p /app && groupadd -r app && useradd -r -g app -d /app -s /sbin/nologin -c "Docker image user" app && chown -R app:app $APP_HOME
COPY --from=builder --chown=app:app /app /app
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
# 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"]