From 6fc765feb8bed6c734650447ae49ea4be8661663 Mon Sep 17 00:00:00 2001 From: Yunom Yxvia Date: Wed, 17 Sep 2025 16:04:35 +0700 Subject: [PATCH 1/4] Update dependabot.yml --- .github/dependabot.yml | 63 ++++++++++++++++++++++++++++++++++++------ 1 file changed, 54 insertions(+), 9 deletions(-) diff --git a/.github/dependabot.yml b/.github/dependabot.yml index d5b04450..3ba9aa5c 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -1,22 +1,48 @@ version: 2 updates: - # NPM (Angular app) + # (Angular app) - package-ecosystem: "npm" directory: "/" schedule: interval: "daily" time: "02:00" timezone: "Asia/Bangkok" - open-pull-requests-limit: 10 target-branch: "main" - labels: ["dependencies", "npm"] - allow: - - dependency-type: "direct" - - dependency-type: "all" + open-pull-requests-limit: 10 + labels: ["dependencies", "npm", "frontend"] + # CHỈ chặn nâng major Angular (v21+), vẫn cho phép 20.x ignore: - # ví dụ giữ cố định major của Angular 19 - dependency-name: "@angular/*" - versions: [">=20"] + update-types: ["version-update:semver-major"] + groups: + angular-core: + patterns: + - "@angular/*" + - "zone.js" + update-types: ["minor", "patch"] + tooling-and-tests: + patterns: + - "typescript" + - "karma*" + - "jasmine*" + - "@types/*" + - "cypress" + update-types: ["minor", "patch"] + ui-and-md: + patterns: + - "highlight.js" + - "marked" + - "github-markdown-css" + - "apexcharts" + - "ng-apexcharts" + - "ngx-*" + update-types: ["minor", "patch"] + codemirror-suite: + patterns: + - "codemirror" + - "@codemirror/*" + update-types: ["minor", "patch"] + # GitHub Actions - package-ecosystem: "github-actions" @@ -26,9 +52,11 @@ updates: day: "monday" time: "03:00" timezone: "Asia/Bangkok" + target-branch: "main" labels: ["dependencies", "github-actions"] + open-pull-requests-limit: 10 - # Docker base images (Nginx, Node…) + # Docker images (Nginx, Node…) - package-ecosystem: "docker" directory: "/docker" schedule: @@ -36,4 +64,21 @@ updates: day: "tuesday" time: "04:00" timezone: "Asia/Bangkok" + target-branch: "main" labels: ["dependencies", "docker"] + open-pull-requests-limit: 10 + groups: + nginx-node-base: + patterns: + - "nginx" + - "node" + update-types: ["minor", "patch"] + dotnet-base: + patterns: + - "mcr.microsoft.com/dotnet/*" + update-types: ["minor", "patch"] + jre-maven: + patterns: + - "eclipse-temurin:*" + - "maven:*" + update-types: ["minor", "patch"] From f31e1828e5b140b29e69d0d23dc371f97b10bf53 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?T=C3=B4=20Quang=20=C4=90=E1=BB=A9c?= Date: Wed, 17 Sep 2025 16:53:36 +0700 Subject: [PATCH 2/4] config docker --- DockerFile | 5 +++++ config-local.json | 1 + config-server.json | 1 + docker-compose.prod-frontend.yml | 9 +++++++-- entrypoint.sh | 12 ++++++++++++ public/config.json | 1 + src/app/core/services/config-service/api.enpoints.ts | 3 ++- src/environments/environment.prod.ts | 3 --- src/main.ts | 11 ++++++++++- 9 files changed, 39 insertions(+), 7 deletions(-) create mode 100644 DockerFile create mode 100644 config-local.json create mode 100644 config-server.json create mode 100644 entrypoint.sh create mode 100644 public/config.json diff --git a/DockerFile b/DockerFile new file mode 100644 index 00000000..95a6d0a8 --- /dev/null +++ b/DockerFile @@ -0,0 +1,5 @@ +# Copy entrypoint script +COPY entrypoint.sh /entrypoint.sh +RUN chmod +x /entrypoint.sh + +ENTRYPOINT ["/entrypoint.sh"] diff --git a/config-local.json b/config-local.json new file mode 100644 index 00000000..28b041be --- /dev/null +++ b/config-local.json @@ -0,0 +1 @@ +{ "apiUrl": "http://localhost:8888/api" } diff --git a/config-server.json b/config-server.json new file mode 100644 index 00000000..45d3b25c --- /dev/null +++ b/config-server.json @@ -0,0 +1 @@ +{ "apiUrl": "http://72.60.41.133:8888/api" } diff --git a/docker-compose.prod-frontend.yml b/docker-compose.prod-frontend.yml index 9ccfafb9..e115c1a8 100644 --- a/docker-compose.prod-frontend.yml +++ b/docker-compose.prod-frontend.yml @@ -5,8 +5,13 @@ services: container_name: codecampus-frontend image: ${DOCKERHUB_USER}/codecampus-frontend:${IMAGE_TAG:-latest} restart: unless-stopped - ports: [ "4200:4200" ] - networks: [ backend ] + ports: ["4200:4200"] + volumes: + # Dùng config local + - ./config-local.json:/usr/share/nginx/html/config.json + # Hoặc server + # - ./config-server.json:/usr/share/nginx/html/config.json + networks: [backend] networks: backend: diff --git a/entrypoint.sh b/entrypoint.sh new file mode 100644 index 00000000..e65258b6 --- /dev/null +++ b/entrypoint.sh @@ -0,0 +1,12 @@ +#!/bin/sh +# entrypoint.sh + +# Tạo file config.json dựa vào biến môi trường API_URL +cat < /usr/share/nginx/html/config.json +{ + "API_URL": "${API_URL}" +} +EOF + +# Chạy nginx foreground +nginx -g 'daemon off;' diff --git a/public/config.json b/public/config.json new file mode 100644 index 00000000..28b041be --- /dev/null +++ b/public/config.json @@ -0,0 +1 @@ +{ "apiUrl": "http://localhost:8888/api" } diff --git a/src/app/core/services/config-service/api.enpoints.ts b/src/app/core/services/config-service/api.enpoints.ts index 383e3d3d..b2edc1bd 100644 --- a/src/app/core/services/config-service/api.enpoints.ts +++ b/src/app/core/services/config-service/api.enpoints.ts @@ -12,7 +12,8 @@ export const version = '/v1'; export const API_CONFIG = { BASE_URLS: { - MAIN_API: environment.IP_SERVER + version, + MAIN_API: + ((window as any).env?.API_URL || 'http://localhost:8888/api') + version, SECONDARY_API: '', }, ENDPOINTS: { diff --git a/src/environments/environment.prod.ts b/src/environments/environment.prod.ts index 6a7f40fd..89f9dd68 100644 --- a/src/environments/environment.prod.ts +++ b/src/environments/environment.prod.ts @@ -1,7 +1,4 @@ export const environment = { production: true, IP_SERVER: 'http://72.60.41.133:8888/api', - IP_SERVER_NO_SSL: 'http://192.168.1.220:8000/api', - IP_SERVER_RADMIN: 'http://26.100.147.137:8888/api', - IP_LOCAL: 'http://localhost:8081/api', }; diff --git a/src/main.ts b/src/main.ts index 190f3418..dcd81db2 100644 --- a/src/main.ts +++ b/src/main.ts @@ -2,4 +2,13 @@ import { bootstrapApplication } from '@angular/platform-browser'; import { appConfig } from './app/app.config'; import { App } from './app/app'; -bootstrapApplication(App, appConfig).catch((err) => console.error(err)); +// Load runtime config trước khi bootstrap +fetch('/config.json') + .then((response) => response.json()) + .then((config) => { + (window as any).env = config; + return bootstrapApplication(App, appConfig); + }) + .catch((err) => console.error(err)); + +// bootstrapApplication(App, appConfig).catch((err) => console.error(err)); From 1ad3f6eed5132936ffbc206e9b9fee100cf1b162 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?T=C3=B4=20Quang=20=C4=90=E1=BB=A9c?= Date: Wed, 17 Sep 2025 17:12:21 +0700 Subject: [PATCH 3/4] config docker file --- DockerFile | 16 ++++++++++++---- docker-compose.prod-frontend.yml | 2 +- entrypoint.sh | 12 ------------ 3 files changed, 13 insertions(+), 17 deletions(-) delete mode 100644 entrypoint.sh diff --git a/DockerFile b/DockerFile index 95a6d0a8..44607438 100644 --- a/DockerFile +++ b/DockerFile @@ -1,5 +1,13 @@ -# Copy entrypoint script -COPY entrypoint.sh /entrypoint.sh -RUN chmod +x /entrypoint.sh +# Stage 1: build Angular app +FROM node:20-alpine AS build +WORKDIR /app +COPY package*.json ./ +RUN npm install +COPY . . +RUN npm run build --prod -ENTRYPOINT ["/entrypoint.sh"] +# Stage 2: serve với Nginx +FROM nginx:alpine +COPY --from=build /app/dist/codecampus /usr/share/nginx/html +# copy sẵn default nginx config nếu cần +COPY nginx.conf /etc/nginx/conf.d/default.conf diff --git a/docker-compose.prod-frontend.yml b/docker-compose.prod-frontend.yml index e115c1a8..bb262f7e 100644 --- a/docker-compose.prod-frontend.yml +++ b/docker-compose.prod-frontend.yml @@ -5,7 +5,7 @@ services: container_name: codecampus-frontend image: ${DOCKERHUB_USER}/codecampus-frontend:${IMAGE_TAG:-latest} restart: unless-stopped - ports: ["4200:4200"] + ports: ["4200:80"] volumes: # Dùng config local - ./config-local.json:/usr/share/nginx/html/config.json diff --git a/entrypoint.sh b/entrypoint.sh deleted file mode 100644 index e65258b6..00000000 --- a/entrypoint.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/sh -# entrypoint.sh - -# Tạo file config.json dựa vào biến môi trường API_URL -cat < /usr/share/nginx/html/config.json -{ - "API_URL": "${API_URL}" -} -EOF - -# Chạy nginx foreground -nginx -g 'daemon off;' From 0bc48a8f912c1d663ebb09cc91ef851ab5f4e89d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 17 Sep 2025 17:06:42 +0000 Subject: [PATCH 4/4] Bump nginx in /docker in the nginx-node-base group Bumps the nginx-node-base group in /docker with 1 update: nginx. Updates `nginx` from 1.27-alpine to 1.29-alpine --- updated-dependencies: - dependency-name: nginx dependency-version: 1.29-alpine dependency-type: direct:production dependency-group: nginx-node-base ... Signed-off-by: dependabot[bot] --- docker/angular-frontend.Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker/angular-frontend.Dockerfile b/docker/angular-frontend.Dockerfile index 470b2a50..42c6f02d 100644 --- a/docker/angular-frontend.Dockerfile +++ b/docker/angular-frontend.Dockerfile @@ -16,7 +16,7 @@ RUN npm run build -- --configuration=production RUN test -f dist/codecampus/browser/index.html # ====== Runtime stage ====== -FROM nginx:1.27-alpine +FROM nginx:1.29-alpine # file Nginx phục vụ SPA & fallback COPY docker/nginx.conf /etc/nginx/conf.d/default.conf