forked from MilesCranmer/PySR
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
84 lines (70 loc) · 2.38 KB
/
Dockerfile
File metadata and controls
84 lines (70 loc) · 2.38 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
# This builds a dockerfile containing a working copy of PySR
# with all pre-requisites installed.
#
# Targets:
# - pysr-runtime: Python + Julia + PySR installed (no eager Julia package precompile).
# - pysr: dev-friendly image (installs extras and precompiles Julia deps).
# - pysr-slurm: image for running a local Slurm cluster for CI tests.
ARG JLVERSION=1.11
ARG PYVERSION=3.12
ARG BASE_IMAGE=bullseye
FROM julia:${JLVERSION}-${BASE_IMAGE} AS jl
FROM python:${PYVERSION}-${BASE_IMAGE} AS pysr-runtime
# Merge Julia image:
COPY --from=jl /usr/local/julia /usr/local/julia
ENV PATH="/usr/local/julia/bin:${PATH}"
WORKDIR /pysr
# Install PySR:
# We do a minimal copy so it doesn't need to rerun at every file change:
ADD ./pyproject.toml /pysr/pyproject.toml
ADD ./LICENSE /pysr/LICENSE
ADD ./README.md /pysr/README.md
ADD ./pysr /pysr/pysr
RUN pip3 install --no-cache-dir .
# --------------------------------------------------------------------
FROM pysr-runtime AS pysr-slurm
RUN set -eu; \
apt-get update; \
apt-get install -y --no-install-recommends \
ca-certificates \
gettext-base \
munge \
procps \
slurmctld \
slurmd \
util-linux \
; \
rm -rf /var/lib/apt/lists/*
RUN set -eu; \
chmod 0755 /etc; \
mkdir -m 0755 -p \
/var/run/slurm \
/var/spool/slurm \
/var/lib/slurm \
/var/log/slurm \
/etc/slurm \
; \
mkdir -m 0700 -p /etc/munge; \
if [ ! -f /etc/munge/munge.key ]; then \
dd if=/dev/urandom of=/etc/munge/munge.key bs=1 count=1024; \
chmod 0400 /etc/munge/munge.key; \
chown munge:munge /etc/munge/munge.key; \
fi; \
chown -R slurm:slurm \
/var/run/slurm \
/var/spool/slurm \
/var/lib/slurm \
/var/log/slurm \
/etc/slurm
COPY pysr/test/slurm_docker_cluster/config/slurm.conf /etc/slurm/slurm.conf
COPY pysr/test/slurm_docker_cluster/config/cgroup.conf /etc/slurm/cgroup.conf
COPY pysr/test/slurm_docker_cluster/docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh
RUN chmod +x /usr/local/bin/docker-entrypoint.sh
ENTRYPOINT ["docker-entrypoint.sh"]
# --------------------------------------------------------------------
FROM pysr-runtime AS pysr
# Install IPython and other useful libraries:
RUN pip install --no-cache-dir ipython matplotlib
# Install Julia pre-requisites:
RUN python3 -c 'import pysr; pysr.load_all_packages()'
CMD ["ipython"]