Add prod environment

This commit is contained in:
2025-08-26 15:01:09 +08:00
parent 19af68b203
commit 7e7aea66c6
5 changed files with 29 additions and 5 deletions

View File

@@ -1,9 +1,12 @@
FROM node:22.12 AS build
# Stage 1: Build Angular app
FROM node:20 AS build
WORKDIR /app
COPY package*.json ./
RUN npm install
COPY . .
RUN npm run build -- --configuration production
RUN npm run build --configuration production
# Stage 2: Serve with Nginx
FROM nginx:alpine
COPY --from=build /app/dist/insurance-fe/browser /usr/share/nginx/html
EXPOSE 80

View File

@@ -45,12 +45,24 @@
"maximumError": "8kB"
}
],
"outputHashing": "all"
"outputHashing": "all",
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.prod.ts"
}
]
},
"development": {
"optimization": false,
"extractLicenses": false,
"sourceMap": true
"sourceMap": true,
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.ts"
}
]
}
},
"defaultConfiguration": "production"

View File

@@ -2,6 +2,7 @@ import { Injectable } from '@angular/core';
import { HttpClient, HttpErrorResponse } from '@angular/common/http';
import { Observable, throwError } from 'rxjs';
import { catchError } from 'rxjs/operators';
import { environment } from '../../../environments/environment';
export interface Insurance {
id: number;
@@ -26,7 +27,7 @@ export interface InsuranceDetail {
providedIn: 'root'
})
export class InsuranceService {
private apiUrl = 'http://localhost:1204/api/insurance';
private apiUrl = environment.apiUrl;
constructor(private http: HttpClient) {}

View File

@@ -0,0 +1,4 @@
export const environment = {
production: true,
apiUrl: 'http://insurance.hzwnrw.my/api/insurance'
};

View File

@@ -0,0 +1,4 @@
export const environment = {
production: false,
apiUrl: 'http://localhost:1204/api/insurance'
};