saq1b commited on
Commit
06ff5f0
·
verified ·
1 Parent(s): a6e975c

Upload Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +6 -42
Dockerfile CHANGED
@@ -1,49 +1,13 @@
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 { \
28
- listen 7860; \
29
- server_name _; \
30
- location / { \
31
- root /usr/share/nginx/html; \
32
- index index.html; \
33
- try_files $uri $uri/ /index.html; \
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;"]
 
1
  FROM nginx:alpine
2
 
3
+ # Copy all files to the NGINX html directory
4
+ COPY . /usr/share/nginx/html/
5
 
6
+ # Set proper permissions
7
+ RUN chmod -R 755 /usr/share/nginx/html
 
8
 
9
+ # Expose port 7860
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
10
  EXPOSE 7860
11
 
12
+ # Start NGINX
 
 
 
13
  CMD ["nginx", "-g", "daemon off;"]