Spaces:
Runtime error
Runtime error
PhamDinhPhong commited on
Commit ·
b9780a1
1
Parent(s): f853d8a
update code
Browse files- Dockerfile +4 -13
- docker-compose.yml +0 -10
- nginx.conf +16 -20
Dockerfile
CHANGED
|
@@ -1,27 +1,18 @@
|
|
| 1 |
-
# Build Stage
|
| 2 |
FROM node:18 AS build
|
|
|
|
| 3 |
WORKDIR /app
|
| 4 |
|
| 5 |
-
# Copy package.json and install dependencies
|
| 6 |
COPY package*.json ./
|
| 7 |
RUN npm install
|
| 8 |
|
| 9 |
-
# Copy source code and build the app
|
| 10 |
COPY . .
|
| 11 |
RUN npm run build
|
| 12 |
|
| 13 |
-
# Run Stage with Nginx
|
| 14 |
-
# FROM nginx:1.23-alpine
|
| 15 |
FROM nginxinc/nginx-unprivileged:1.25-alpine
|
| 16 |
|
| 17 |
-
# Copy the build files from the build stage to Nginx's html folder
|
| 18 |
COPY --from=build /app/build /usr/share/nginx/html
|
| 19 |
|
| 20 |
-
|
| 21 |
-
COPY nginx.conf /etc/nginx/conf.d/default.conf
|
| 22 |
-
|
| 23 |
-
# Expose port 80 to access the app
|
| 24 |
-
EXPOSE 80
|
| 25 |
|
| 26 |
-
|
| 27 |
-
CMD ["nginx", "-g", "daemon off;"]
|
|
|
|
|
|
|
| 1 |
FROM node:18 AS build
|
| 2 |
+
|
| 3 |
WORKDIR /app
|
| 4 |
|
|
|
|
| 5 |
COPY package*.json ./
|
| 6 |
RUN npm install
|
| 7 |
|
|
|
|
| 8 |
COPY . .
|
| 9 |
RUN npm run build
|
| 10 |
|
|
|
|
|
|
|
| 11 |
FROM nginxinc/nginx-unprivileged:1.25-alpine
|
| 12 |
|
|
|
|
| 13 |
COPY --from=build /app/build /usr/share/nginx/html
|
| 14 |
|
| 15 |
+
COPY nginx.conf /etc/nginx/nginx.conf
|
|
|
|
|
|
|
|
|
|
|
|
|
| 16 |
|
| 17 |
+
EXPOSE 8080
|
| 18 |
+
CMD ["nginx", "-g", "daemon off;"]
|
docker-compose.yml
DELETED
|
@@ -1,10 +0,0 @@
|
|
| 1 |
-
version: '3.8'
|
| 2 |
-
|
| 3 |
-
services:
|
| 4 |
-
app:
|
| 5 |
-
build:
|
| 6 |
-
context: .
|
| 7 |
-
dockerfile: Dockerfile
|
| 8 |
-
ports:
|
| 9 |
-
- "8000:80"
|
| 10 |
-
restart: always
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
nginx.conf
CHANGED
|
@@ -1,10 +1,13 @@
|
|
| 1 |
worker_processes 1;
|
| 2 |
|
| 3 |
-
events {
|
|
|
|
|
|
|
| 4 |
|
| 5 |
http {
|
| 6 |
-
include mime.types;
|
| 7 |
default_type application/octet-stream;
|
|
|
|
| 8 |
sendfile on;
|
| 9 |
|
| 10 |
client_body_temp_path /tmp/client_temp;
|
|
@@ -14,27 +17,20 @@ http {
|
|
| 14 |
scgi_temp_path /tmp/scgi_temp;
|
| 15 |
|
| 16 |
server {
|
| 17 |
-
|
| 18 |
-
|
| 19 |
|
| 20 |
-
|
| 21 |
-
|
| 22 |
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
}
|
| 31 |
|
| 32 |
-
|
| 33 |
-
location /assets/ {
|
| 34 |
-
add_header Cache-Control "no-store";
|
| 35 |
}
|
| 36 |
-
|
| 37 |
-
# Chuyển hướng lỗi 404 về index.html
|
| 38 |
-
error_page 404 /index.html;
|
| 39 |
-
}
|
| 40 |
}
|
|
|
|
| 1 |
worker_processes 1;
|
| 2 |
|
| 3 |
+
events {
|
| 4 |
+
worker_connections 1024;
|
| 5 |
+
}
|
| 6 |
|
| 7 |
http {
|
| 8 |
+
include /etc/nginx/mime.types;
|
| 9 |
default_type application/octet-stream;
|
| 10 |
+
|
| 11 |
sendfile on;
|
| 12 |
|
| 13 |
client_body_temp_path /tmp/client_temp;
|
|
|
|
| 17 |
scgi_temp_path /tmp/scgi_temp;
|
| 18 |
|
| 19 |
server {
|
| 20 |
+
listen 8080;
|
| 21 |
+
server_name localhost;
|
| 22 |
|
| 23 |
+
root /usr/share/nginx/html;
|
| 24 |
+
index index.html;
|
| 25 |
|
| 26 |
+
location / {
|
| 27 |
+
try_files $uri $uri/ /index.html;
|
| 28 |
+
}
|
| 29 |
|
| 30 |
+
location /assets/ {
|
| 31 |
+
add_header Cache-Control "no-store";
|
| 32 |
+
}
|
|
|
|
| 33 |
|
| 34 |
+
error_page 404 /index.html;
|
|
|
|
|
|
|
| 35 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
| 36 |
}
|