Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

Dockerfile 2.9 KB

You have to be logged in to leave a comment. Sign In
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
85
86
87
88
89
90
91
92
93
94
95
96
97
  1. #from https://towardsdatascience.com/conda-pip-and-docker-ftw-d64fe638dc45
  2. FROM ubuntu:18.04
  3. LABEL maintainer="pughdr <david.pugh@kaust.edu.sa>"
  4. SHELL [ "/bin/bash", "--login", "-c" ]
  5. RUN apt-get update --fix-missing && \
  6. apt-get install -y wget bzip2 curl git && \
  7. apt-get clean && \
  8. rm -rf /var/lib/apt/lists/*
  9. # Create a non-root user
  10. ARG username=al-khawarizmi
  11. ARG uid=1000
  12. ARG gid=100
  13. ENV USER $username
  14. ENV UID $uid
  15. ENV GID $gid
  16. ENV HOME /home/$USER
  17. RUN adduser --disabled-password \
  18. --gecos "Non-root user" \
  19. --uid $UID \
  20. --gid $GID \
  21. --home $HOME \
  22. $USER
  23. #Newer versions of Docker support copying files as a non-root user,
  24. # however the version of Docker available on DockerHub does not yet support copying as a non-root user
  25. # so if you want to set up automated builds for your Git repositories you will need to copy everything as root.
  26. COPY environment.yml requirements.txt /tmp/
  27. RUN chown $UID:$GID /tmp/environment.yml /tmp/requirements.txt
  28. COPY postBuild /usr/local/bin/postBuild.sh
  29. RUN chown $UID:$GID /usr/local/bin/postBuild.sh && \
  30. chmod u+x /usr/local/bin/postBuild.sh
  31. COPY docker/entrypoint.sh /usr/local/bin/
  32. RUN chown $UID:$GID /usr/local/bin/entrypoint.sh && \
  33. chmod u+x /usr/local/bin/entrypoint.sh
  34. USER $USER
  35. # install miniconda
  36. ENV MINICONDA_VERSION latest
  37. ENV CONDA_DIR $HOME/miniconda3
  38. RUN wget --quiet https://repo.anaconda.com/miniconda/Miniconda3-$MINICONDA_VERSION-Linux-x86_64.sh -O ~/miniconda.sh && \
  39. chmod +x ~/miniconda.sh && \
  40. ~/miniconda.sh -b -p $CONDA_DIR && \
  41. rm ~/miniconda.sh
  42. # make non-activate conda commands available
  43. ENV PATH=$CONDA_DIR/bin:$PATH
  44. # make conda activate command available from /bin/bash --login shells
  45. RUN echo ". $CONDA_DIR/etc/profile.d/conda.sh" >> ~/.profile
  46. # make conda activate command available from /bin/bash --interative shells
  47. RUN conda init bash
  48. # create a project directory inside user home
  49. ENV PROJECT_DIR $HOME/app
  50. RUN mkdir $PROJECT_DIR
  51. WORKDIR $PROJECT_DIR
  52. # build the conda environment
  53. ENV ENV_PREFIX $PROJECT_DIR/env
  54. RUN conda update --name base --channel defaults conda && \
  55. conda install mamba -c conda-forge &&\
  56. conda env create --prefix $ENV_PREFIX --file /tmp/environment.yml --force && \
  57. conda clean --all --yes
  58. # run the postBuild script to install the JupyterLab extensions
  59. RUN conda activate $ENV_PREFIX && \
  60. /usr/local/bin/postBuild.sh && \
  61. conda deactivate
  62. # use an entrypoint script to insure conda environment is properly activated at runtime
  63. ENTRYPOINT [ "/usr/local/bin/entrypoint.sh" ]
  64. # default command will be to launch JupyterLab server for development
  65. CMD [ "jupyter", "lab", "--no-browser", "--ip", "0.0.0.0" ]
  66. # build with the following command:
  67. # docker image build \
  68. # --build-arg username=$USER \
  69. # --build-arg uid=$UID \
  70. # --build-arg gid=$GID \
  71. # --file Dockerfile \
  72. # --tag $IMAGE_NAME:$IMAGE_TAG \
  73. # ../
  74. #OR, alternatively,
  75. #docker-compose up --build
Tip!

Press p or to see the previous file or, n or to see the next file

Comments

Loading...