nolascoin commited on
Commit
559611f
·
1 Parent(s): f92cdbd

Final Dockerfile + Nginx configs for Hugging Face

Browse files
Files changed (2) hide show
  1. Dockerfile +3 -0
  2. default.conf +61 -0
Dockerfile CHANGED
@@ -1,9 +1,12 @@
 
1
  FROM nginx:alpine-slim
2
 
3
  WORKDIR /usr/share/nginx/html
4
 
5
  COPY dist/ .
 
6
  COPY default.conf /etc/nginx/conf.d/default.conf
7
  COPY nginx.conf /etc/nginx/nginx.conf
8
 
 
9
  EXPOSE 7860
 
1
+ # Use a lightweight Nginx image
2
  FROM nginx:alpine-slim
3
 
4
  WORKDIR /usr/share/nginx/html
5
 
6
  COPY dist/ .
7
+
8
  COPY default.conf /etc/nginx/conf.d/default.conf
9
  COPY nginx.conf /etc/nginx/nginx.conf
10
 
11
+ # Hugging Face expects the app to run on port 7860
12
  EXPOSE 7860
default.conf ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ server {
2
+ listen 7860;
3
+ server_name localhost;
4
+
5
+ root /usr/share/nginx/html;
6
+ index index.html;
7
+
8
+ # Enable gzip and pre-compressed file support
9
+ gzip on;
10
+ gzip_static on;
11
+ gzip_comp_level 6;
12
+ gzip_vary on;
13
+ gzip_proxied any;
14
+
15
+ gzip_types
16
+ text/plain
17
+ text/css
18
+ text/javascript
19
+ application/javascript
20
+ application/json
21
+ application/xml
22
+ application/font-woff
23
+ application/font-woff2
24
+ application/octet-stream
25
+ image/svg+xml;
26
+
27
+ # Serve .gz files manually if needed
28
+ location ~* \.gz$ {
29
+ add_header Content-Encoding gzip;
30
+ add_header Vary Accept-Encoding;
31
+ types {
32
+ text/javascript js;
33
+ text/css css;
34
+ text/html html;
35
+ application/octet-stream glb;
36
+ }
37
+ }
38
+
39
+ # 🔥 Cache-busting for fingerprinted assets
40
+ location ~* \.(js|css|woff2?|eot|ttf|otf|svg|glb|gltf|wasm|png|jpe?g|gif|ico|webp)$ {
41
+ add_header Cache-Control "public, max-age=31536000, immutable";
42
+ try_files $uri =404;
43
+ }
44
+
45
+ # 🚫 Prevent caching index.html (always load latest)
46
+ location = /index.html {
47
+ add_header Cache-Control "no-cache";
48
+ try_files $uri =404;
49
+ }
50
+
51
+ # 🧩 Optional: glb file support
52
+ location ~* \.glb$ {
53
+ add_header Content-Type application/octet-stream;
54
+ try_files $uri =404;
55
+ }
56
+
57
+ # 🎯 SPA fallback (Vue/React/etc.)
58
+ location / {
59
+ try_files $uri $uri/ /index.html;
60
+ }
61
+ }