Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 54 additions & 9 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -26,14 +52,33 @@ 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:
interval: "weekly"
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"]
13 changes: 13 additions & 0 deletions DockerFile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# 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

# 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
1 change: 1 addition & 0 deletions config-local.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{ "apiUrl": "http://localhost:8888/api" }
1 change: 1 addition & 0 deletions config-server.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{ "apiUrl": "http://72.60.41.133:8888/api" }
9 changes: 7 additions & 2 deletions docker-compose.prod-frontend.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:80"]
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:
Expand Down
2 changes: 1 addition & 1 deletion docker/angular-frontend.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions public/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{ "apiUrl": "http://localhost:8888/api" }
3 changes: 2 additions & 1 deletion src/app/core/services/config-service/api.enpoints.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down
3 changes: 0 additions & 3 deletions src/environments/environment.prod.ts
Original file line number Diff line number Diff line change
@@ -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',
};
11 changes: 10 additions & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Loading