OcDash Deploy commited on
Commit
052eea3
·
1 Parent(s): c213795

feat: inject HF_TOKEN from environment at startup

Browse files
Files changed (2) hide show
  1. Dockerfile +5 -2
  2. start.sh +6 -0
Dockerfile CHANGED
@@ -1,6 +1,9 @@
1
  FROM nginx:alpine
2
  COPY . /usr/share/nginx/html
3
  COPY nginx.conf /etc/nginx/conf.d/default.conf
4
- RUN rm -f /usr/share/nginx/html/Dockerfile /usr/share/nginx/html/nginx.conf /usr/share/nginx/html/README.md
 
 
 
5
  EXPOSE 8080
6
- CMD ["nginx", "-g", "daemon off;"]
 
1
  FROM nginx:alpine
2
  COPY . /usr/share/nginx/html
3
  COPY nginx.conf /etc/nginx/conf.d/default.conf
4
+ COPY start.sh /start.sh
5
+ RUN rm -f /usr/share/nginx/html/Dockerfile /usr/share/nginx/html/nginx.conf /usr/share/nginx/html/README.md /usr/share/nginx/html/start.sh /usr/share/nginx/html/.gitignore 2>/dev/null; \
6
+ rm -rf /usr/share/nginx/html/.git 2>/dev/null; \
7
+ chmod +x /start.sh
8
  EXPOSE 8080
9
+ CMD ["/start.sh"]
start.sh ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ #!/bin/sh
2
+ # Inject HF_TOKEN from environment into index.html for the SPA
3
+ if [ -n "$HF_TOKEN" ]; then
4
+ sed -i "s|</head>|<script>window.__HF_TOKEN__ = '$HF_TOKEN';</script></head>|" /usr/share/nginx/html/index.html
5
+ fi
6
+ exec nginx -g "daemon off;"