Spaces:
Running
Running
Nginx configuration added
Browse files- Dockerfile +12 -3
- nginx.conf +32 -0
Dockerfile
CHANGED
|
@@ -1,9 +1,18 @@
|
|
| 1 |
-
FROM node:22-alpine
|
| 2 |
WORKDIR /app
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
COPY . .
|
| 4 |
-
RUN npm install --silent
|
| 5 |
|
| 6 |
ENV VITE_API_BASE_URL=https://aixamine.qcri.org/api/v1
|
| 7 |
ENV VITE_AMPLITUDE_API_KEY=default_key
|
| 8 |
|
| 9 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
FROM node:22-alpine AS builder
|
| 2 |
WORKDIR /app
|
| 3 |
+
|
| 4 |
+
COPY package*.json ./
|
| 5 |
+
|
| 6 |
+
RUN npm ci --silent
|
| 7 |
+
|
| 8 |
COPY . .
|
|
|
|
| 9 |
|
| 10 |
ENV VITE_API_BASE_URL=https://aixamine.qcri.org/api/v1
|
| 11 |
ENV VITE_AMPLITUDE_API_KEY=default_key
|
| 12 |
|
| 13 |
+
RUN npm run build
|
| 14 |
+
FROM nginx:alpine
|
| 15 |
+
COPY --from=builder /app/dist /usr/share/nginx/html
|
| 16 |
+
COPY nginx.conf /etc/nginx/conf.d/default.conf
|
| 17 |
+
EXPOSE 7860
|
| 18 |
+
CMD ["nginx", "-g", "daemon off;"]
|
nginx.conf
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
server {
|
| 2 |
+
listen 7860;
|
| 3 |
+
server_name _;
|
| 4 |
+
root /usr/share/nginx/html;
|
| 5 |
+
index index.html;
|
| 6 |
+
|
| 7 |
+
# Enable gzip compression
|
| 8 |
+
gzip on;
|
| 9 |
+
gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
|
| 10 |
+
gzip_min_length 1000;
|
| 11 |
+
|
| 12 |
+
# SPA routing - redirect all requests to index.html
|
| 13 |
+
location / {
|
| 14 |
+
try_files $uri $uri/ /index.html;
|
| 15 |
+
}
|
| 16 |
+
|
| 17 |
+
# Cache static assets
|
| 18 |
+
location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot)$ {
|
| 19 |
+
expires 1y;
|
| 20 |
+
add_header Cache-Control "public, immutable";
|
| 21 |
+
}
|
| 22 |
+
|
| 23 |
+
# Don't cache index.html
|
| 24 |
+
location = /index.html {
|
| 25 |
+
add_header Cache-Control "no-cache, no-store, must-revalidate";
|
| 26 |
+
}
|
| 27 |
+
|
| 28 |
+
# Security headers
|
| 29 |
+
add_header X-Frame-Options "SAMEORIGIN" always;
|
| 30 |
+
add_header X-Content-Type-Options "nosniff" always;
|
| 31 |
+
add_header X-XSS-Protection "1; mode=block" always;
|
| 32 |
+
}
|