File size: 1,728 Bytes
c520e0a
511bc62
e9576fd
 
6992e29
e9576fd
 
 
6992e29
e9576fd
 
6992e29
e9576fd
f1bd50d
0d321d4
 
 
 
 
e9576fd
 
 
 
 
 
 
 
 
0d321d4
e9576fd
 
511bc62
e9576fd
 
 
 
7182945
e9576fd
 
7182945
e9576fd
 
676bf15
 
 
e9576fd
b26378c
676bf15
e9576fd
 
 
6992e29
e9576fd
 
6992e29
e9576fd
511bc62
e9576fd
 
6992e29
e9576fd
 
 
6992e29
e9576fd
 
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
FROM jupyter/scipy-notebook

# Create a user with ID 1000
RUN useradd -m -u 1000 user

# Set environment variables
ENV HOME=/home/user \
    PATH=/home/user/.local/bin:$PATH

# Set working directory
WORKDIR $HOME/app

# Install system dependencies
USER root
RUN apt-get update && apt-get install -y \
    wget \
    nginx \
    && apt-get clean && rm -rf /var/lib/apt/lists/*

# Switch back to the user
USER user

# Upgrade pip
RUN pip install --no-cache-dir --upgrade pip

# Copy requirements and install Python dependencies
COPY --chown=user requirements.txt .
RUN pip install --user --no-cache-dir -r requirements.txt

# Copy static files
COPY --chown=user public $HOME/app/public

# Copy configuration files
COPY --chown=user jupyter_config.py $HOME/.jupyter/jupyter_config.py
COPY --chown=user nginx.conf $HOME/nginx.conf
COPY --chown=user entrypoint.sh $HOME/entrypoint.sh

# Make entrypoint executable
RUN chmod +x $HOME/entrypoint.sh

# Create necessary directories for Nginx
USER root
RUN mkdir -p /var/lib/nginx/body /var/lib/nginx/fastcgi \
             /var/lib/nginx/proxy /var/lib/nginx/scgi \
             /var/lib/nginx/uwsgi /var/log/nginx \
    && chown -R user:user /var/lib/nginx /var/log/nginx /var/run /run \
    && chmod 755 /var/lib/nginx /var/run /run

# Create Nginx log files
RUN touch /var/log/nginx/error.log /var/log/nginx/access.log \
    && chown user:user /var/log/nginx/error.log /var/log/nginx/access.log

# Create a directory for persistent data
RUN mkdir -p /data && chown user:user /data && chmod 777 /data

USER user

# Expose ports
EXPOSE 8888 7860

# Set environment variables
ENV JUPYTERLAB_PORT=8888 \
    NGINX_PORT=7860

# Run the entrypoint script
ENTRYPOINT ["$HOME/entrypoint.sh"]