From 4c221e234861c4c878c9326b33246dc52d8ee98c Mon Sep 17 00:00:00 2001 From: Quang Khai Nguyen Date: Mon, 12 Oct 2026 09:41:35 +0200 Subject: [PATCH] deployment artifacts --- Dockerfile | 14 ++++++++++++++ docker-compose.yaml | 20 ++++++++++++++++++++ nginx.conf | 30 ++++++++++++++++++++++++++++++ 3 files changed, 64 insertions(+) create mode 100644 Dockerfile create mode 100644 docker-compose.yaml create mode 100644 nginx.conf diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..0f98097 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,14 @@ +FROM nginx:alpine + +# Xóa file cấu hình mặc định của Nginx +RUN rm -rf /etc/nginx/conf.d/* + +# Copy file cấu hình tùy chỉnh của bạn vào +COPY nginx.conf /etc/nginx/conf.d/default.conf + +# Copy source code web và thư mục ảnh vào +COPY index.html /usr/share/nginx/html/ +COPY images/ /usr/share/nginx/html/images/ + +EXPOSE 80 +CMD ["nginx", "-g", "daemon off;"] \ No newline at end of file diff --git a/docker-compose.yaml b/docker-compose.yaml new file mode 100644 index 0000000..03ac3d6 --- /dev/null +++ b/docker-compose.yaml @@ -0,0 +1,20 @@ +networks: + proxy_tier: + name: proxy_tier + external: true + +services: + nha-trang-web: + image: nha-trang-site:latest + build: + context: . + dockerfile: Dockerfile + container_name: nha-trang-app + restart: unless-stopped + labels: + - "traefik.enable=true" + - "traefik.http.routers.kyduyen.rule=Host(`kyduyen.quangkhai.ch`)" + - "traefik.http.routers.kyduyen.tls.certresolver=myresolver" + - "traefik.http.services.kyduyen.loadbalancer.server.port=80" + networks: + - proxy_tier \ No newline at end of file diff --git a/nginx.conf b/nginx.conf new file mode 100644 index 0000000..290a0d7 --- /dev/null +++ b/nginx.conf @@ -0,0 +1,30 @@ +server { + listen 80; + server_name localhost; + + # Thư mục gốc chứa mã nguồn website trong container + root /usr/share/nginx/html; + index index.html index.htm; + + # Cấu hình nén để website tải nhanh hơn + gzip on; + gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript; + gzip_min_length 1000; + + # Xử lý các request chính + location / { + try_files $uri $uri/ =404; + } + + # Tối ưu cache cho các file tĩnh (hình ảnh, CSS, JS) để tăng tốc độ tải trang + location ~* \.(jpg|jpeg|png|gif|ico|css|js|svg|woff|woff2|ttf)$ { + expires 30d; + add_header Cache-Control "public, no-transform"; + } + + # Trang lỗi tùy chỉnh (tùy chọn) + error_page 500 502 503 504 /50x.html; + location = /50x.html { + root /usr/share/nginx/html; + } +} \ No newline at end of file