MilesCranmer commited on
Commit
faf444e
1 Parent(s): 31ffc0e

Make docker build multi-stage

Browse files
Files changed (1) hide show
  1. Dockerfile +10 -33
Dockerfile CHANGED
@@ -1,43 +1,15 @@
1
  # This builds a dockerfile containing a working copy of PySR
2
  # with all pre-requisites installed.
3
 
 
4
  ARG PYVERSION=3.10.8
5
 
 
6
  FROM python:$PYVERSION
7
 
8
- # metainformation
9
- LABEL org.opencontainers.image.authors = "Miles Cranmer"
10
- LABEL org.opencontainers.image.source = "https://github.com/MilesCranmer/PySR"
11
- LABEL org.opencontainers.image.licenses = "Apache License 2.0"
12
-
13
- # Need to use ARG after FROM, otherwise it won't get passed through.
14
- ARG JLVERSION=1.8.2
15
-
16
- ENV PYVERSION $PYVERSION
17
- ENV JLVERSION $JLVERSION
18
-
19
- # arm64:
20
- # https://julialang-s3.julialang.org/bin/linux/aarch64/1.8/julia-1.8.2-linux-aarch64.tar.gz
21
- # amd64:
22
- # https://julialang-s3.julialang.org/bin/linux/x64/1.8/julia-1.8.2-linux-x86_64.tar.gz
23
-
24
- RUN export JULIA_VER=$(echo $JLVERSION | cut -d '.' -f -2) && \
25
- export ARCH=$(arch | sed 's/x86_64/amd64/' | sed 's/aarch64/arm64/') && \
26
- if [ "$ARCH" = "amd64" ]; then \
27
- export BASE_URL="https://julialang-s3.julialang.org/bin/linux/x64/$JULIA_VER" && \
28
- export FULL_URL=$BASE_URL/julia-$JLVERSION-linux-x86_64.tar.gz; \
29
- elif [ "$ARCH" = "arm64" ]; then \
30
- export BASE_URL="https://julialang-s3.julialang.org/bin/linux/aarch64/$JULIA_VER"; \
31
- export FULL_URL=$BASE_URL/julia-$JLVERSION-linux-aarch64.tar.gz; \
32
- else \
33
- echo "Download link for architecture ${ARCH} not found. Please add the corresponding Julia download URL to this Dockerfile." && \
34
- exit 1; \
35
- fi && \
36
- wget -nv $FULL_URL -O julia.tar.gz && \
37
- tar -xzf julia.tar.gz && \
38
- rm julia.tar.gz && \
39
- mv julia-$JLVERSION /opt/julia && \
40
- ln -s /opt/julia/bin/julia /usr/local/bin/julia
41
 
42
  # Install IPython and other useful libraries:
43
  RUN pip install ipython matplotlib
@@ -57,4 +29,9 @@ RUN pip3 install .
57
  # Install Julia pre-requisites:
58
  RUN python3 -c 'import pysr; pysr.install()'
59
 
 
 
 
 
 
60
  CMD ["ipython"]
 
1
  # This builds a dockerfile containing a working copy of PySR
2
  # with all pre-requisites installed.
3
 
4
+ ARG JLVERSION=1.8.2
5
  ARG PYVERSION=3.10.8
6
 
7
+ FROM julia:$JLVERSION AS jl
8
  FROM python:$PYVERSION
9
 
10
+ # Merge Julia image:
11
+ COPY --from=jl /usr/local/julia /usr/local/julia
12
+ ENV PATH="/usr/local/julia/bin:${PATH}"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
13
 
14
  # Install IPython and other useful libraries:
15
  RUN pip install ipython matplotlib
 
29
  # Install Julia pre-requisites:
30
  RUN python3 -c 'import pysr; pysr.install()'
31
 
32
+ # metainformation
33
+ LABEL org.opencontainers.image.authors = "Miles Cranmer"
34
+ LABEL org.opencontainers.image.source = "https://github.com/MilesCranmer/PySR"
35
+ LABEL org.opencontainers.image.licenses = "Apache License 2.0"
36
+
37
  CMD ["ipython"]