MyComputer commited on
Commit
c206c66
·
1 Parent(s): 527f105

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +16 -6
Dockerfile CHANGED
@@ -8,7 +8,6 @@ ENV DEBIAN_FRONTEND=noninteractive \
8
  RUN rm -f /etc/apt/sources.list.d/*.list && \
9
  apt-get update && apt-get install -y --no-install-recommends \
10
  curl \
11
- wget \
12
  ca-certificates \
13
  sudo \
14
  git \
@@ -34,10 +33,17 @@ RUN curl -sL https://deb.nodesource.com/setup_14.x | bash - && \
34
  # Create a working directory
35
  WORKDIR /app
36
 
37
- USER root
 
 
 
 
 
38
 
39
  # All users can use /home/user as their home directory
40
- ENV HOME=/root
 
 
41
 
42
  # Set up the Conda environment
43
  ENV CONDA_AUTO_UPDATE_CONDA=false \
@@ -70,15 +76,19 @@ RUN --mount=target=/root/on_startup.sh,source=on_startup.sh,readwrite \
70
  # End root user section
71
  #######################################
72
 
73
- USER root
74
 
75
  # Python packages
76
  RUN --mount=target=requirements.txt,source=requirements.txt \
77
  pip install --no-cache-dir --upgrade -r requirements.txt
78
 
79
- COPY --chown=root . $HOME/app
 
 
80
  RUN chmod +x start_server.sh
81
 
 
 
82
  ENV PYTHONUNBUFFERED=1 \
83
  GRADIO_ALLOW_FLAGGING=never \
84
  GRADIO_NUM_PORTS=1 \
@@ -87,4 +97,4 @@ ENV PYTHONUNBUFFERED=1 \
87
  SYSTEM=spaces \
88
  SHELL=/bin/bash
89
 
90
- CMD ["./start_server.sh"]
 
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 \
 
33
  # Create a working directory
34
  WORKDIR /app
35
 
36
+ # Create a non-root user and switch to it
37
+ RUN adduser --disabled-password --gecos '' --shell /bin/bash user \
38
+ && chown -R user:user /app
39
+ RUN echo "user ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/90-user
40
+ RUN echo "user ALL = (ALL) NOPASSWD: ALL" >> /etc/sudoers
41
+ USER user
42
 
43
  # All users can use /home/user as their home directory
44
+ ENV HOME=/home/user
45
+ RUN mkdir $HOME/.cache $HOME/.config \
46
+ && chmod -R 777 $HOME
47
 
48
  # Set up the Conda environment
49
  ENV CONDA_AUTO_UPDATE_CONDA=false \
 
76
  # End root user section
77
  #######################################
78
 
79
+ USER user
80
 
81
  # Python packages
82
  RUN --mount=target=requirements.txt,source=requirements.txt \
83
  pip install --no-cache-dir --upgrade -r requirements.txt
84
 
85
+ # Copy the current directory contents into the container at $HOME/app setting the owner to the user
86
+ COPY --chown=user . $HOME/app
87
+
88
  RUN chmod +x start_server.sh
89
 
90
+ COPY --chown=user login.html /home/user/miniconda/lib/python3.9/site-packages/jupyter_server/templates/login.html
91
+
92
  ENV PYTHONUNBUFFERED=1 \
93
  GRADIO_ALLOW_FLAGGING=never \
94
  GRADIO_NUM_PORTS=1 \
 
97
  SYSTEM=spaces \
98
  SHELL=/bin/bash
99
 
100
+ CMD ["./start_server.sh"]