Add prod environment
This commit is contained in:
@@ -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
|
||||
|
||||
16
angular.json
16
angular.json
@@ -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"
|
||||
|
||||
@@ -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) {}
|
||||
|
||||
|
||||
4
src/environments/environment.prod.ts
Normal file
4
src/environments/environment.prod.ts
Normal file
@@ -0,0 +1,4 @@
|
||||
export const environment = {
|
||||
production: true,
|
||||
apiUrl: 'http://insurance.hzwnrw.my/api/insurance'
|
||||
};
|
||||
4
src/environments/environment.ts
Normal file
4
src/environments/environment.ts
Normal file
@@ -0,0 +1,4 @@
|
||||
export const environment = {
|
||||
production: false,
|
||||
apiUrl: 'http://localhost:1204/api/insurance'
|
||||
};
|
||||
Reference in New Issue
Block a user