-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
72 lines (60 loc) · 2.51 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
ARG CUDA_VERSION=11.8.0
FROM mambaorg/micromamba:focal-cuda-${CUDA_VERSION}
ARG CAUSTICS_VERSION=0.7.0
ARG CAUSTICS_REPO="https://github.com/Ciela-Institute/caustics.git"
# Tell apt-get to not block installs by asking for interactive human input
ENV DEBIAN_FRONTEND=noninteractive \
# Setup locale to be UTF-8, avoiding gnarly hard to debug encoding errors
LANG=C.UTF-8 \
LC_ALL=C.UTF-8 \
# Set caustics directory home
# this will be empty if not in dev mode
CAUSTICS_HOME=/opt/caustics \
CAUSTICS_TEST_SCRIPT=/usr/local/bin/run-tests
# Switch over to root user to install apt-get packages
USER root
# Make everything in opt rootless
RUN chown -R ${MAMBA_USER}:${MAMBA_USER} /opt
# Copy over run test script for the case we are working with dev repo
COPY --chown=$MAMBA_USER:$MAMBA_USER run-tests.sh ${CAUSTICS_TEST_SCRIPT}
RUN chmod +x ${CAUSTICS_TEST_SCRIPT} \
&& ln -s ${CAUSTICS_TEST_SCRIPT} /bin/run-tests
# Install basic apt packages
RUN echo "Installing Apt-get packages..." \
&& apt-get update --fix-missing > /dev/null \
&& apt-get install -y apt-utils \
&& apt-get install -y \
git \
wget \
zip \
tzdata \
vim \
tmux \
python3-venv \
graphviz > /dev/null \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
# Switch back to mamba user after all apt-get packages are installed
USER $MAMBA_USER
# Setup caustics directory in case we are working with
# dev repo
RUN echo "Setup caustics directory..." \
&& mkdir ${CAUSTICS_HOME} \
&& chown -R $MAMBA_USER:$MAMBA_USER ${CAUSTICS_HOME}
# Copy over the conda lock file from host machine to docker build engine
COPY --chown=$MAMBA_USER:$MAMBA_USER conda-linux-64.lock /tmp/conda-linux-64.lock
# Install the packages listed in the conda lock file
RUN micromamba install --name base --yes --file /tmp/conda-linux-64.lock \
&& micromamba clean --all --yes
# Set to activate mamba environment, otherwise python will not be found
ARG MAMBA_DOCKERFILE_ACTIVATE=1
# Install caustics from a branch or distribution
RUN echo "Installing caustics ..." \
; if [[ "${CAUSTICS_VERSION}" = *"dev"* ]]; then \
echo "Cloning caustics to ${CAUSTICS_HOME}..." ; \
git clone -b ${CAUSTICS_VERSION} --single-branch ${CAUSTICS_REPO} ${CAUSTICS_HOME} ; \
echo "Installing from github branch: ${CAUSTICS_VERSION}..." ; \
pip install -e "${CAUSTICS_HOME}[dev]" \
; else echo "Installing from production distribution version: ${CAUSTICS_VERSION}" ; \
pip install caustics==${CAUSTICS_VERSION} \
; fi