LudwigO commited on
Commit
d365eb1
·
1 Parent(s): 161b7fe

dockerfile first try

Browse files
Files changed (1) hide show
  1. Dockerfile +177 -0
Dockerfile ADDED
@@ -0,0 +1,177 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM nvidia/cuda:11.3.1-base-ubuntu20.04
2
+
3
+ ENV DEBIAN_FRONTEND=noninteractive \
4
+ TZ=Europe/Paris
5
+
6
+ # Remove any third-party apt sources to avoid issues with expiring keys.
7
+ # Install some basic utilities
8
+ RUN rm -f /etc/apt/sources.list.d/*.list && \
9
+ apt-get update && apt-get install -y --no-install-recommends \
10
+ curl \
11
+ ca-certificates \
12
+ sudo \
13
+ git \
14
+ wget \
15
+ procps \
16
+ git-lfs \
17
+ zip \
18
+ unzip \
19
+ htop \
20
+ vim \
21
+ nano \
22
+ bzip2 \
23
+ libx11-6 \
24
+ build-essential \
25
+ libsndfile-dev \
26
+ software-properties-common \
27
+ libxrender1 \
28
+ && rm -rf /var/lib/apt/lists/*
29
+
30
+ RUN add-apt-repository ppa:flexiondotorg/nvtop && \
31
+ apt-get upgrade -y && \
32
+ apt-get install -y --no-install-recommends nvtop
33
+
34
+ RUN curl -sL https://deb.nodesource.com/setup_14.x | bash - && \
35
+ apt-get install -y nodejs && \
36
+ npm install -g configurable-http-proxy
37
+
38
+ # Create a working directory
39
+ WORKDIR /app
40
+
41
+ # Create a non-root user and switch to it
42
+ RUN adduser --disabled-password --gecos '' --shell /bin/bash user \
43
+ && chown -R user:user /app
44
+ RUN echo "user ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/90-user
45
+ USER user
46
+
47
+ # All users can use /home/user as their home directory
48
+ ENV HOME=/home/user
49
+ RUN mkdir $HOME/.cache $HOME/.config \
50
+ && chmod -R 777 $HOME
51
+
52
+ # Set up the Conda environment
53
+ ENV CONDA_AUTO_UPDATE_CONDA=false \
54
+ PATH=$HOME/miniconda/bin:$PATH
55
+ RUN curl -sLo ~/miniconda.sh https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh \
56
+ && chmod +x ~/miniconda.sh \
57
+ && ~/miniconda.sh -b -p ~/miniconda \
58
+ && rm ~/miniconda.sh \
59
+ && conda clean -ya
60
+
61
+ WORKDIR $HOME/app
62
+
63
+ #######################################
64
+ # Start root user section
65
+ #######################################
66
+
67
+ USER root
68
+
69
+ # User Debian packages
70
+ ## Security warning : Potential user code executed as root (build time)
71
+ RUN --mount=target=/root/packages.txt,source=packages.txt \
72
+ apt-get update && \
73
+ xargs -r -a /root/packages.txt apt-get install -y --no-install-recommends \
74
+ && rm -rf /var/lib/apt/lists/*
75
+
76
+ RUN --mount=target=/root/on_startup.sh,source=on_startup.sh,readwrite \
77
+ bash /root/on_startup.sh
78
+
79
+ RUN mkdir /data && chown user:user /data
80
+ RUN mkdir /data/chemprop && chown user:user /data/chemprop
81
+ #######################################
82
+ # End root user section
83
+ #######################################
84
+
85
+ USER user
86
+
87
+ # Pull chemprop from github
88
+ RUN git clone https://github.com/chemprop/chemprop.git
89
+
90
+ # build an empty conda environment with appropriate Python version
91
+ RUN conda create --name chemprop_env python=3.11*
92
+
93
+ SHELL ["conda", "run", "--no-capture-output", "-n", "chemprop_env", "/bin/bash", "-c"]
94
+
95
+ # Follow the installation instructions then clear the cache
96
+ ADD chemprop /data/chemprop
97
+ ADD LICENSE.txt pyproject.toml README.md ./
98
+ RUN conda install pytorch cpuonly -c pytorch && \
99
+ conda clean --all --yes && \
100
+ python -m pip install ./chemprop && \
101
+ python -m pip cache purge
102
+
103
+
104
+
105
+ # Python packages - should be all installed with pip install ./chemprop
106
+ #RUN --mount=target=requirements.txt,source=requirements.txt \
107
+ # pip install --no-cache-dir --upgrade -r requirements.txt
108
+
109
+
110
+
111
+ # Copy the current directory contents into the container at $HOME/app setting the owner to the user
112
+ COPY --chown=user . $HOME/app
113
+
114
+ RUN chmod +x start_server.sh
115
+
116
+ COPY --chown=user login.html /home/user/miniconda/lib/python3.9/site-packages/jupyter_server/templates/login.html
117
+
118
+ ENV PYTHONUNBUFFERED=1 \
119
+ GRADIO_ALLOW_FLAGGING=never \
120
+ GRADIO_NUM_PORTS=1 \
121
+ GRADIO_SERVER_NAME=0.0.0.0 \
122
+ GRADIO_THEME=huggingface \
123
+ SYSTEM=spaces \
124
+ SHELL=/bin/bash
125
+
126
+ CMD ["./start_server.sh"]
127
+ ####################################################### FROM CHEMPROP DOCKERFILE ##########################################################
128
+ # Dockerfile
129
+ #
130
+ # Builds a Docker image containing Chemprop and its required dependencies.
131
+ #
132
+ # Build this image with:
133
+ # git clone https://github.com/chemprop/chemprop.git
134
+ # cd chemprop
135
+ # docker build --tag=chemprop:latest .
136
+ #
137
+ # Run the built image with:
138
+ # docker run --name chemprop_container -it chemprop:latest
139
+ #
140
+ # Note:
141
+ # This image only runs on CPU - we do not provide a Dockerfile
142
+ # for GPU use (see installation documentation).
143
+
144
+ # Parent Image
145
+ #FROM continuumio/miniconda3:latest
146
+
147
+ # Install libxrender1 (required by RDKit) and then clean up
148
+ #RUN apt-get update && \
149
+ # apt-get install -y \
150
+ # libxrender1 && \
151
+ # apt-get autoremove -y && \
152
+ # apt-get clean -y
153
+
154
+ #WORKDIR /opt/chemprop
155
+
156
+ # build an empty conda environment with appropriate Python version
157
+ #RUN conda create --name chemprop_env python=3.11*
158
+
159
+ # This runs all subsequent commands inside the chemprop_env conda environment
160
+ #
161
+ # Analogous to just activating the environment, which we can't actually do here
162
+ # since that requires running conda init and restarting the shell (not possible
163
+ # in a Dockerfile build script)
164
+ #SHELL ["conda", "run", "--no-capture-output", "-n", "chemprop_env", "/bin/bash", "-c"]
165
+
166
+ # Follow the installation instructions then clear the cache
167
+ #ADD chemprop chemprop
168
+ #ENV PYTHONPATH /opt/chemprop
169
+ #ADD LICENSE.txt pyproject.toml README.md ./
170
+ #RUN conda install pytorch cpuonly -c pytorch && \
171
+ # conda clean --all --yes && \
172
+ # python -m pip install . && \
173
+ # python -m pip cache purge
174
+
175
+ # when running this image, open an interactive bash terminal inside the conda environment
176
+ #RUN echo "conda activate chemprop_env" > ~/.bashrc
177
+ #ENTRYPOINT ["/bin/bash", "--login"]