Spaces:
Sleeping
Sleeping
Update Dockerfile
Browse files- Dockerfile +26 -58
Dockerfile
CHANGED
|
@@ -1,58 +1,26 @@
|
|
| 1 |
-
#
|
| 2 |
-
FROM node:18-alpine
|
| 3 |
-
|
| 4 |
-
# Set working directory
|
| 5 |
-
WORKDIR /app
|
| 6 |
-
|
| 7 |
-
# Copy package
|
| 8 |
-
COPY package*.json ./
|
| 9 |
-
|
| 10 |
-
# Install dependencies
|
| 11 |
-
RUN npm
|
| 12 |
-
|
| 13 |
-
# Copy
|
| 14 |
-
COPY . .
|
| 15 |
-
|
| 16 |
-
# Build the
|
| 17 |
-
RUN npm run build
|
| 18 |
-
|
| 19 |
-
#
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
#
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
#
|
| 26 |
-
|
| 27 |
-
listen 80; \
|
| 28 |
-
server_name localhost; \
|
| 29 |
-
root /usr/share/nginx/html; \
|
| 30 |
-
index index.html; \
|
| 31 |
-
\
|
| 32 |
-
location / { \
|
| 33 |
-
try_files $uri $uri/ /index.html; \
|
| 34 |
-
} \
|
| 35 |
-
\
|
| 36 |
-
# Cache static assets \
|
| 37 |
-
location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot)$ { \
|
| 38 |
-
expires 1y; \
|
| 39 |
-
add_header Cache-Control "public, immutable"; \
|
| 40 |
-
} \
|
| 41 |
-
\
|
| 42 |
-
# Security headers \
|
| 43 |
-
add_header X-Frame-Options "SAMEORIGIN" always; \
|
| 44 |
-
add_header X-Content-Type-Options "nosniff" always; \
|
| 45 |
-
add_header X-XSS-Protection "1; mode=block" always; \
|
| 46 |
-
\
|
| 47 |
-
# Gzip compression \
|
| 48 |
-
gzip on; \
|
| 49 |
-
gzip_vary on; \
|
| 50 |
-
gzip_min_length 1000; \
|
| 51 |
-
gzip_types text/plain text/css text/xml text/javascript application/javascript application/xml+rss application/json; \
|
| 52 |
-
}' > /etc/nginx/conf.d/default.conf
|
| 53 |
-
|
| 54 |
-
# Expose port 80
|
| 55 |
-
EXPOSE 80
|
| 56 |
-
|
| 57 |
-
# Start nginx
|
| 58 |
-
CMD ["nginx", "-g", "daemon off;"]
|
|
|
|
| 1 |
+
# Use an official Node.js runtime as the base image
|
| 2 |
+
FROM node:18-alpine
|
| 3 |
+
|
| 4 |
+
# Set working directory inside the container
|
| 5 |
+
WORKDIR /app
|
| 6 |
+
|
| 7 |
+
# Copy package.json and package-lock.json first (for caching)
|
| 8 |
+
COPY package*.json ./
|
| 9 |
+
|
| 10 |
+
# Install dependencies
|
| 11 |
+
RUN npm install
|
| 12 |
+
|
| 13 |
+
# Copy the rest of the project files
|
| 14 |
+
COPY . .
|
| 15 |
+
|
| 16 |
+
# Build the app for production
|
| 17 |
+
RUN npm run build
|
| 18 |
+
|
| 19 |
+
# Install a simple static file server to serve the built files
|
| 20 |
+
RUN npm install -g serve
|
| 21 |
+
|
| 22 |
+
# Expose the port your app will run on
|
| 23 |
+
EXPOSE 3000
|
| 24 |
+
|
| 25 |
+
# Command to run the app
|
| 26 |
+
CMD ["serve", "-s", "build", "-l", "3000"]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|