Skip to content

Commit 09a3c8b

Browse files
committed
Add Dockerfile
1 parent a0e8d94 commit 09a3c8b

File tree

3 files changed

+54
-0
lines changed

3 files changed

+54
-0
lines changed

.dockerignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
node_modules
2+
.env
3+
coverage
4+
build
5+
README.md

Dockerfile

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Sử dụng một image node chính thức làm base image
2+
FROM node:16-alpine as build
3+
4+
# Thiết lập thư mục làm việc
5+
WORKDIR /app
6+
7+
# Copy package.json và package-lock.json
8+
COPY package*.json ./
9+
10+
# Cài đặt các dependencies
11+
RUN npm install
12+
13+
# Copy toàn bộ mã nguồn ứng dụng
14+
COPY . .
15+
16+
# Build ứng dụng
17+
RUN npm run build
18+
19+
# Sử dụng một image nginx chính thức để phục vụ build
20+
FROM nginx:alpine
21+
22+
# Copy build từ giai đoạn trước vào thư mục phục vụ của nginx
23+
COPY --from=build /app/build /usr/share/nginx/html
24+
25+
# Copy file cấu hình nginx
26+
COPY nginx.conf /etc/nginx/conf.d/default.conf
27+
28+
# Expose cổng 80 để có thể truy cập vào container
29+
EXPOSE 80
30+
31+
# Lệnh chạy nginx
32+
CMD ["nginx", "-g", "daemon off;"]

nginx.conf

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
server {
2+
listen 80;
3+
4+
server_name localhost;
5+
6+
root /usr/share/nginx/html;
7+
index index.html index.htm;
8+
9+
location / {
10+
try_files $uri $uri/ /index.html;
11+
}
12+
13+
error_page 500 502 503 504 /50x.html;
14+
location = /50x.html {
15+
root /usr/share/nginx/html;
16+
}
17+
}

0 commit comments

Comments
 (0)