Ramses II
commited on
Commit
•
e9576fd
1
Parent(s):
0d321d4
auto msg
Browse files- Dockerfile +41 -48
Dockerfile
CHANGED
@@ -1,73 +1,66 @@
|
|
1 |
FROM jupyter/scipy-notebook
|
2 |
|
3 |
-
#
|
4 |
-
|
5 |
|
6 |
-
#
|
7 |
-
|
|
|
8 |
|
9 |
-
#
|
10 |
-
|
11 |
|
12 |
-
#
|
13 |
USER root
|
14 |
-
|
15 |
-
# Install sudo and other dependencies
|
16 |
RUN apt-get update && apt-get install -y \
|
17 |
wget \
|
18 |
nginx \
|
19 |
-
sudo \
|
20 |
-
build-essential \
|
21 |
-
curl \
|
22 |
-
git \
|
23 |
-
vim \
|
24 |
&& apt-get clean && rm -rf /var/lib/apt/lists/*
|
25 |
|
26 |
-
#
|
27 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
28 |
|
29 |
-
#
|
30 |
-
|
31 |
-
echo "jovyan ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/jovyan && \
|
32 |
-
chmod 0440 /etc/sudoers.d/jovyan
|
33 |
|
34 |
-
# Copy
|
35 |
-
COPY jupyter_config.py
|
36 |
-
COPY nginx.conf /
|
37 |
-
COPY entrypoint.sh /
|
38 |
|
39 |
-
#
|
40 |
-
RUN chmod +x /
|
41 |
|
42 |
-
# Create necessary directories
|
|
|
43 |
RUN mkdir -p /var/lib/nginx/body /var/lib/nginx/fastcgi \
|
44 |
/var/lib/nginx/proxy /var/lib/nginx/scgi \
|
45 |
/var/lib/nginx/uwsgi /var/log/nginx \
|
46 |
-
&& chown -R
|
47 |
&& chmod 755 /var/lib/nginx /var/run /run
|
48 |
|
49 |
-
#
|
50 |
-
RUN touch /var/log/nginx/error.log /var/log/nginx/access.log
|
51 |
-
&& chown
|
52 |
-
|
53 |
-
# Set the permissions for the app directory to the existing user
|
54 |
-
RUN chown -R ${NB_UID}:${NB_GID} /app
|
55 |
-
|
56 |
-
# Switch back to the original user
|
57 |
-
USER ${NB_UID}
|
58 |
|
59 |
-
#
|
60 |
-
|
61 |
|
62 |
-
|
63 |
-
EXPOSE 8888
|
64 |
|
65 |
-
# Expose
|
66 |
-
EXPOSE 7860
|
67 |
|
68 |
-
# Set
|
69 |
-
ENV JUPYTERLAB_PORT=8888
|
70 |
-
|
71 |
|
72 |
-
# Run the entrypoint script
|
73 |
-
ENTRYPOINT ["/
|
|
|
1 |
FROM jupyter/scipy-notebook
|
2 |
|
3 |
+
# Create a user with ID 1000
|
4 |
+
RUN useradd -m -u 1000 user
|
5 |
|
6 |
+
# Set environment variables
|
7 |
+
ENV HOME=/home/user \
|
8 |
+
PATH=/home/user/.local/bin:$PATH
|
9 |
|
10 |
+
# Set working directory
|
11 |
+
WORKDIR $HOME/app
|
12 |
|
13 |
+
# Install system dependencies
|
14 |
USER root
|
|
|
|
|
15 |
RUN apt-get update && apt-get install -y \
|
16 |
wget \
|
17 |
nginx \
|
|
|
|
|
|
|
|
|
|
|
18 |
&& apt-get clean && rm -rf /var/lib/apt/lists/*
|
19 |
|
20 |
+
# Switch back to the user
|
21 |
+
USER user
|
22 |
+
|
23 |
+
# Upgrade pip
|
24 |
+
RUN pip install --no-cache-dir --upgrade pip
|
25 |
+
|
26 |
+
# Copy requirements and install Python dependencies
|
27 |
+
COPY --chown=user requirements.txt .
|
28 |
+
RUN pip install --user --no-cache-dir -r requirements.txt
|
29 |
|
30 |
+
# Copy static files
|
31 |
+
COPY --chown=user public $HOME/app/public
|
|
|
|
|
32 |
|
33 |
+
# Copy configuration files
|
34 |
+
COPY --chown=user jupyter_config.py $HOME/.jupyter/jupyter_config.py
|
35 |
+
COPY --chown=user nginx.conf $HOME/nginx.conf
|
36 |
+
COPY --chown=user entrypoint.sh $HOME/entrypoint.sh
|
37 |
|
38 |
+
# Make entrypoint executable
|
39 |
+
RUN chmod +x $HOME/entrypoint.sh
|
40 |
|
41 |
+
# Create necessary directories for Nginx
|
42 |
+
USER root
|
43 |
RUN mkdir -p /var/lib/nginx/body /var/lib/nginx/fastcgi \
|
44 |
/var/lib/nginx/proxy /var/lib/nginx/scgi \
|
45 |
/var/lib/nginx/uwsgi /var/log/nginx \
|
46 |
+
&& chown -R user:user /var/lib/nginx /var/log/nginx /var/run /run \
|
47 |
&& chmod 755 /var/lib/nginx /var/run /run
|
48 |
|
49 |
+
# Create Nginx log files
|
50 |
+
RUN touch /var/log/nginx/error.log /var/log/nginx/access.log \
|
51 |
+
&& chown user:user /var/log/nginx/error.log /var/log/nginx/access.log
|
|
|
|
|
|
|
|
|
|
|
|
|
52 |
|
53 |
+
# Create a directory for persistent data
|
54 |
+
RUN mkdir -p /data && chown user:user /data && chmod 777 /data
|
55 |
|
56 |
+
USER user
|
|
|
57 |
|
58 |
+
# Expose ports
|
59 |
+
EXPOSE 8888 7860
|
60 |
|
61 |
+
# Set environment variables
|
62 |
+
ENV JUPYTERLAB_PORT=8888 \
|
63 |
+
NGINX_PORT=7860
|
64 |
|
65 |
+
# Run the entrypoint script
|
66 |
+
ENTRYPOINT ["$HOME/entrypoint.sh"]
|