Emalawi19 commited on
Commit
215f22a
·
verified ·
1 Parent(s): 7910801

Create Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +28 -0
Dockerfile ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Use PHP 8.2 with FPM and Alpine Linux for a small footprint
2
+ FROM php:8.2-fpm-alpine
3
+
4
+ # Install Nginx
5
+ RUN apk add --no-cache nginx
6
+
7
+ # Create a non-root user (Hugging Face requires user ID 1000)
8
+ RUN adduser -D -u 1000 user
9
+
10
+ # Configure Nginx for non-root execution
11
+ RUN mkdir -p /var/cache/nginx /var/run/nginx /var/lib/nginx/logs \
12
+ && chown -R user:user /var/cache/nginx /var/run/nginx /var/lib/nginx /var/log/nginx
13
+
14
+ # Copy our custom Nginx configuration
15
+ COPY nginx.conf /etc/nginx/nginx.conf
16
+
17
+ # Set up the web directory
18
+ WORKDIR /app
19
+ COPY --chown=user:user . /app
20
+
21
+ # Switch to the non-root user
22
+ USER user
23
+
24
+ # Hugging Face Spaces must run on port 7860
25
+ EXPOSE 7860
26
+
27
+ # Start both PHP-FPM and Nginx
28
+ CMD ["sh", "-c", "php-fpm -D && nginx -g 'daemon off;'"]