Upload Dockerfile
Browse files- Dockerfile +30 -5
Dockerfile
CHANGED
@@ -1,10 +1,27 @@
|
|
1 |
FROM nginx:alpine
|
2 |
|
3 |
-
#
|
4 |
-
|
5 |
|
6 |
-
#
|
7 |
-
RUN
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
8 |
|
9 |
# Create default.conf for nginx to listen on port 7860 (Hugging Face's default port)
|
10 |
RUN echo 'server { \
|
@@ -17,8 +34,16 @@ RUN echo 'server { \
|
|
17 |
} \
|
18 |
}' > /etc/nginx/conf.d/default.conf
|
19 |
|
|
|
|
|
|
|
|
|
|
|
20 |
# Expose port 7860 for Hugging Face Spaces
|
21 |
EXPOSE 7860
|
22 |
|
23 |
-
#
|
|
|
|
|
|
|
24 |
CMD ["nginx", "-g", "daemon off;"]
|
|
|
1 |
FROM nginx:alpine
|
2 |
|
3 |
+
# Set up a new user named "user" with user ID 1000
|
4 |
+
RUN adduser -D -u 1000 user
|
5 |
|
6 |
+
# Create necessary directories with proper ownership
|
7 |
+
RUN mkdir -p /usr/share/nginx/html && \
|
8 |
+
chown -R user:user /usr/share/nginx/html
|
9 |
+
|
10 |
+
# Switch to the "user" user for operations
|
11 |
+
USER user
|
12 |
+
|
13 |
+
# Set home to the user's home directory
|
14 |
+
ENV HOME=/home/user \
|
15 |
+
PATH=/home/user/.local/bin:$PATH
|
16 |
+
|
17 |
+
# Set the working directory
|
18 |
+
WORKDIR $HOME/app
|
19 |
+
|
20 |
+
# Copy files with proper ownership
|
21 |
+
COPY --chown=user . $HOME/app
|
22 |
+
|
23 |
+
# Switch back to root for nginx configuration (required)
|
24 |
+
USER root
|
25 |
|
26 |
# Create default.conf for nginx to listen on port 7860 (Hugging Face's default port)
|
27 |
RUN echo 'server { \
|
|
|
34 |
} \
|
35 |
}' > /etc/nginx/conf.d/default.conf
|
36 |
|
37 |
+
# Copy files from user's app directory to nginx serving directory
|
38 |
+
RUN cp -r $HOME/app/* /usr/share/nginx/html/ && \
|
39 |
+
chmod -R 755 /usr/share/nginx/html && \
|
40 |
+
chown -R user:user /usr/share/nginx/html
|
41 |
+
|
42 |
# Expose port 7860 for Hugging Face Spaces
|
43 |
EXPOSE 7860
|
44 |
|
45 |
+
# Switch back to user for running the service
|
46 |
+
USER user
|
47 |
+
|
48 |
+
# Start NGINX (with a slight modification to run as non-root)
|
49 |
CMD ["nginx", "-g", "daemon off;"]
|