-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathDockerfile.julia
47 lines (36 loc) · 1.56 KB
/
Dockerfile.julia
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
FROM python:3.10
RUN useradd -m jupyter
EXPOSE 8888
RUN apt update && apt install -y lsof
# Install Julia
RUN wget --no-verbose -O julia.tar.gz "https://julialang-s3.julialang.org/bin/linux/$(uname -m|sed 's/86_//')/1.10/julia-1.10.1-linux-$(uname -m).tar.gz"
RUN tar -xzf "julia.tar.gz" && mv julia-1.10.1 /opt/julia && \
ln -s /opt/julia/bin/julia /usr/local/bin/julia && rm "julia.tar.gz"
# Add Julia to Jupyter
USER 1000
RUN julia -e 'using Pkg; Pkg.add("IJulia");'
# Install Julia requirements
RUN julia -e ' \
packages = [ \
"DataSets", "XLSX", "Plots", "Downloads", "DataFrames", "ImageShow", "FileIO", "JSON3", "CSV" \
]; \
using Pkg; \
Pkg.add(packages);'
# Back to root for Python package install
USER root
# Install Python requirements
RUN pip install --upgrade --no-cache-dir hatch pip
# Install project requirements
# Hack to install requirements without requiring the rest of the files
COPY --chown=1000:1000 pyproject.toml /jupyter/
RUN bash -c "pip install --no-build-isolation --no-cache-dir -r <(echo 'import tomli; c = tomli.load(open(\"/jupyter/pyproject.toml\", \"rb\")); d = c[\"project\"][\"dependencies\"]; print(\"\n\".join(f\"{dep}\" for dep in d))' | python)"
# Copy src code over
COPY --chown=1000:1000 . /jupyter
RUN chown -R 1000:1000 /jupyter
RUN pip install --no-build-isolation --no-cache-dir /jupyter
# Switch to non-root user. It is crucial for security reasons to not run jupyter as root user!
USER jupyter
WORKDIR /jupyter
RUN julia -e 'using Pkg; Pkg.add("IJulia");'
# Service
CMD ["beaker", "notebook", "--ip", "0.0.0.0"]