Spaces:
Runtime error
Runtime error
da03
commited on
Commit
·
1828ec1
1
Parent(s):
0d2a979
- Dockerfile +11 -17
Dockerfile
CHANGED
@@ -18,20 +18,8 @@ RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
|
|
18 |
|
19 |
# Set up a new user named "user" with user ID 1000
|
20 |
RUN useradd -m -u 1000 user
|
21 |
-
# Switch to the "user" user
|
22 |
-
USER user
|
23 |
-
# Set home to the user's home directory
|
24 |
-
ENV HOME=/home/user \
|
25 |
-
PATH=/home/user/.local/bin:$PATH
|
26 |
-
|
27 |
-
# Set the working directory to the user's home directory
|
28 |
-
WORKDIR $HOME/app
|
29 |
-
|
30 |
-
# Copy the current directory contents into the container at $HOME/app setting the owner to the user
|
31 |
-
COPY --chown=user . $HOME/app
|
32 |
|
33 |
# Create nginx configuration for WebSocket support using echo commands
|
34 |
-
USER root
|
35 |
RUN echo 'server {' > /etc/nginx/sites-available/default && \
|
36 |
echo ' listen 7860;' >> /etc/nginx/sites-available/default && \
|
37 |
echo ' server_name _;' >> /etc/nginx/sites-available/default && \
|
@@ -62,9 +50,7 @@ RUN echo 'server {' > /etc/nginx/sites-available/default && \
|
|
62 |
# Give user sudo permissions for nginx
|
63 |
RUN echo "user ALL=(ALL) NOPASSWD: /usr/sbin/nginx, /usr/sbin/nginx -t, /usr/sbin/nginx -s quit" >> /etc/sudoers
|
64 |
|
65 |
-
|
66 |
-
|
67 |
-
# Create a startup script for HF Spaces with nginx
|
68 |
RUN echo '#!/bin/bash' > /start_hf_spaces.sh && \
|
69 |
echo 'set -e' >> /start_hf_spaces.sh && \
|
70 |
echo '' >> /start_hf_spaces.sh && \
|
@@ -162,9 +148,17 @@ RUN echo '#!/bin/bash' > /start_hf_spaces.sh && \
|
|
162 |
echo 'kill $TAIL_PID 2>/dev/null || true' >> /start_hf_spaces.sh && \
|
163 |
chmod +x /start_hf_spaces.sh
|
164 |
|
165 |
-
#
|
166 |
USER user
|
167 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
168 |
|
169 |
# Switch back to root for final startup
|
170 |
USER root
|
|
|
18 |
|
19 |
# Set up a new user named "user" with user ID 1000
|
20 |
RUN useradd -m -u 1000 user
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
21 |
|
22 |
# Create nginx configuration for WebSocket support using echo commands
|
|
|
23 |
RUN echo 'server {' > /etc/nginx/sites-available/default && \
|
24 |
echo ' listen 7860;' >> /etc/nginx/sites-available/default && \
|
25 |
echo ' server_name _;' >> /etc/nginx/sites-available/default && \
|
|
|
50 |
# Give user sudo permissions for nginx
|
51 |
RUN echo "user ALL=(ALL) NOPASSWD: /usr/sbin/nginx, /usr/sbin/nginx -t, /usr/sbin/nginx -s quit" >> /etc/sudoers
|
52 |
|
53 |
+
# Create a startup script that runs as root initially (while we're still root)
|
|
|
|
|
54 |
RUN echo '#!/bin/bash' > /start_hf_spaces.sh && \
|
55 |
echo 'set -e' >> /start_hf_spaces.sh && \
|
56 |
echo '' >> /start_hf_spaces.sh && \
|
|
|
148 |
echo 'kill $TAIL_PID 2>/dev/null || true' >> /start_hf_spaces.sh && \
|
149 |
chmod +x /start_hf_spaces.sh
|
150 |
|
151 |
+
# Switch to user and copy files
|
152 |
USER user
|
153 |
+
# Set home to the user's home directory
|
154 |
+
ENV HOME=/home/user \
|
155 |
+
PATH=/home/user/.local/bin:$PATH
|
156 |
+
|
157 |
+
# Set the working directory to the user's home directory
|
158 |
+
WORKDIR $HOME/app
|
159 |
+
|
160 |
+
# Copy the current directory contents into the container at $HOME/app setting the owner to the user
|
161 |
+
COPY --chown=user . $HOME/app
|
162 |
|
163 |
# Switch back to root for final startup
|
164 |
USER root
|