diff --git a/Dockerfile b/Dockerfile index 700fb9c..3c35c28 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,27 @@ -FROM node:18-alpine +## STEP 1 BUILD ## +FROM node:18-alpine AS build + +RUN mkdir -p /app + WORKDIR /app -COPY . . + +RUN npm cache clean --force + +COPY package*.json /app + RUN npm install -EXPOSE 9002 -RUN npm run build -CMD ["npm", "start"] + +COPY . /app + +RUN npm run build --prod + +## STEP 2 DEPLOY ## +FROM nginx:1.21.3 AS ngi + +COPY --from=build /app/dist/* /usr/share/nginx/html +COPY /nginx.conf /etc/nginx/conf.d/default.conf +# COPY /nginx.conf /etc/nginx/nginx.conf + +# EXPOSE 9002 + +CMD ["nginx", "-g", "daemon off;"] diff --git a/nginx.conf b/nginx.conf new file mode 100644 index 0000000..8930e5d --- /dev/null +++ b/nginx.conf @@ -0,0 +1,22 @@ +upstream docker-web { + server 178.18.0.5:9001; +} + +server { + include /etc/nginx/extra-conf.d/*.conf; + + listen 80; + + include /etc/nginx/mime.types; + + location / { + root /usr/share/nginx/html; + try_files $uri $uri/ /index.html; + } + + + location /api/ { + proxy_pass http://docker-web; + } + +} \ No newline at end of file diff --git a/proxy.conf.json b/proxy.conf.json new file mode 100644 index 0000000..b38fe93 --- /dev/null +++ b/proxy.conf.json @@ -0,0 +1,7 @@ +{ + "/api/*": { + "target": "http://localhost:9002", + "secure": false, + "timeout": 600000 + } +} diff --git a/src/app/service/employee.service.ts b/src/app/service/employee.service.ts deleted file mode 100644 index 29f20f0..0000000 --- a/src/app/service/employee.service.ts +++ /dev/null @@ -1,34 +0,0 @@ -import { Injectable } from "@angular/core"; -import { Observable } from "rxjs"; -import { Employee } from '../model/employee'; -import { HttpClient } from '@angular/common/http'; -import { environment } from '../../environments/environment'; - -@Injectable({ - providedIn: 'root' -}) -export class EmployeeService { - private apiServerUrl = environment.apiBaseUrl; - - constructor(private http: HttpClient) {} - - public getAllEmployees(): Observable { - return this.http.get(`${this.apiServerUrl}/api/employees/all`); - } - - public getEmployee(employeeId: number): Observable { - return this.http.get(`${this.apiServerUrl}/api/employee/${employeeId}`); - } - - public addEmployee(employee: Employee): Observable { - return this.http.post(`${this.apiServerUrl}/api/employee/add`, employee); - } - - public updateEmployee(employee: Employee, employeeId: number): Observable { - return this.http.put(`${this.apiServerUrl}/api/employee/update/${employeeId}`, employee); - } - - public deleteEmployee(employeeId: number): Observable { - return this.http.delete(`${this.apiServerUrl}/api/employee/delete/${employeeId}`); - } -} diff --git a/src/app/service/info-column.service.ts b/src/app/service/info-column.service.ts index 0064bc0..385f751 100644 --- a/src/app/service/info-column.service.ts +++ b/src/app/service/info-column.service.ts @@ -1,5 +1,4 @@ import { Injectable } from '@angular/core'; -import { environment } from '../../environments/environment.development'; import { HttpClient, HttpParams } from '@angular/common/http'; import { InfoColumn } from '../model/info-column'; import { Observable } from 'rxjs'; @@ -9,30 +8,28 @@ import { Observable } from 'rxjs'; }) export class InfoColumnService { - - - private apiServerUrl = environment.apiBaseUrl; - constructor(private http: HttpClient) { } public getAllColumns(): Observable{ - return this.http.get(`${this.apiServerUrl}/api/columns/all`); + return this.http.get(`/api/columns/all`); } public getColumn(columnId: Number): Observable{ - return this.http.get(`${this.apiServerUrl}/api/column/${columnId}`); + return this.http.get(`/api/column/${columnId}`); } public getSelectedColumns(schema: String, table: String): Observable{ - return this.http.get(`${this.apiServerUrl}/api/columns/${schema}/${table}`); + return this.http.get(`/api/columns/${schema}/${table}`); } public getColumnsForJoin(firstSchema: String, secondSchema: String, firstTable: String, secondTable: String): Observable{ - return this.http.get(`${this.apiServerUrl}/api/columns/${firstSchema}/${secondSchema}/${firstTable}/${secondTable}`); + return this.http.get(`/api/columns/${firstSchema}/${secondSchema}/${firstTable}/${secondTable}`); } public getColumnsForJoinTwo(tables: string[], schemas: string[]): Observable{ - const paramsGetJoins = new HttpParams().set('tables', tables.toString()).set('schemas', schemas.toString()); - return this.http.get(`${this.apiServerUrl}/api/columns/joins`, {params: paramsGetJoins}); + const paramsGetJoins = new HttpParams() + .set('tables', tables.toString()) + .set('schemas', schemas.toString()); + return this.http.get(`/api/columns/joins`, {params: paramsGetJoins}); } } diff --git a/src/app/service/info-table.service.ts b/src/app/service/info-table.service.ts index 93bd29c..8fcadf0 100644 --- a/src/app/service/info-table.service.ts +++ b/src/app/service/info-table.service.ts @@ -2,42 +2,40 @@ import { Injectable } from '@angular/core'; import { HttpClient } from '@angular/common/http'; import { Observable } from 'rxjs'; import { InfoTable } from '../model/info-table'; -import { environment } from 'src/environments/environment'; @Injectable({ providedIn: 'root' }) export class InfoTableService { - private apiServerUrl = environment.apiBaseUrl; constructor(private http: HttpClient) { } public getAllTables(): Observable{ - return this.http.get(`${this.apiServerUrl}/api/tables/all`); + return this.http.get(`/api/tables/all`); } public getTable(tableId: Number): Observable{ - return this.http.get(`${this.apiServerUrl}/api/table/${tableId}`); + return this.http.get(`/api/table/${tableId}`); } public getSchemas(): Observable{ - return this.http.get(`${this.apiServerUrl}/api/schemas/all`); + return this.http.get(`/api/schemas/all`); } public getTablesBySchema(nameSchema : String): Observable{ - return this.http.get(`${this.apiServerUrl}/api/tables/${nameSchema}`); + return this.http.get(`/api/tables/${nameSchema}`); } public getSchemasByTable(nameTable : String): Observable{ - return this.http.get(`${this.apiServerUrl}/api/schemas/${nameTable}`); + return this.http.get(`/api/schemas/${nameTable}`); } public getTablesWithFilter(filter : String): Observable{ - return this.http.get(`${this.apiServerUrl}/api/tables/filter/${filter}`); + return this.http.get(`/api/tables/filter/${filter}`); } public getTablesWithFilterAndSchema(filter : String, schema: String): Observable{ - return this.http.get(`${this.apiServerUrl}/api/tables/filter/${schema}/${filter}`); + return this.http.get(`/api/tables/filter/${schema}/${filter}`); } } diff --git a/src/app/service/reset_data.service.ts b/src/app/service/reset_data.service.ts index 6abee0f..7099b73 100644 --- a/src/app/service/reset_data.service.ts +++ b/src/app/service/reset_data.service.ts @@ -1,22 +1,19 @@ import { Injectable } from '@angular/core'; -import { environment } from '../../environments/environment.development'; -import { HttpClient, HttpParams } from '@angular/common/http'; -import { Observable } from 'rxjs'; +import { HttpClient } from '@angular/common/http'; @Injectable({ providedIn: 'root' }) export class ResetDataService { - private apiServerUrl = environment.apiBaseUrl; constructor(private http: HttpClient) { } public resetDatabase(){ - return this.http.post(`${this.apiServerUrl}/api/reset`, null); + return this.http.post(`/api/reset`, null); } public testres(){ - return this.http.post(`${this.apiServerUrl}/api/testres`, null); + return this.http.post(`/api/testres`, null); } } diff --git a/src/app/service/script.service.ts b/src/app/service/script.service.ts index 6c85aa1..4ed78d7 100644 --- a/src/app/service/script.service.ts +++ b/src/app/service/script.service.ts @@ -1,7 +1,6 @@ import { Injectable } from '@angular/core'; -import { environment } from '../../environments/environment.development'; import { HttpClient, HttpParams } from '@angular/common/http'; -import { Observable, from } from 'rxjs'; +import { Observable } from 'rxjs'; import { Script } from '../model/script'; import { LinkScriptTag } from '../model/link-script-tag'; @@ -9,29 +8,37 @@ import { LinkScriptTag } from '../model/link-script-tag'; providedIn: 'root' }) export class ScriptService { - private apiServerUrl = environment.apiBaseUrl; constructor(private http: HttpClient) { } public retreiveScripts(): Observable{ - return this.http.get(`${this.apiServerUrl}/api/scripts`); + return this.http.get(`/api/scripts`); } public getAllScriptsWithTags(): Observable{ - return this.http.get(`${this.apiServerUrl}/api/scripts/link`); + return this.http.get(`/api/scripts/link`); } public deleteScript(name: String){ - return this.http.delete(`${this.apiServerUrl}/api/script/delete/${name}`); + return this.http.delete(`/api/script/delete/${name}`); } public addOneScript(script: Script, description: String, tagList: String[], id: number){ - const paramsAddScript = new HttpParams().set('name', script.name.toString()).set('desc', description.toString()).set('tagList', tagList.join(', ')).set('linkid', id); - return this.http.post(`${this.apiServerUrl}/api/script/add`, script.data, {params: paramsAddScript}); + const paramsAddScript = new HttpParams() + .set('name', script.name.toString()) + .set('desc', description.toString()) + .set('tagList', tagList.join(', ')) + .set('linkid', id); + return this.http.post(`/api/script/add`, script.data, {params: paramsAddScript}); } public editScript(content: String, defaultName: String, newName: String, description: String, tagList: String[], id: number){ - const paramsAddScript = new HttpParams().set('defaultname', defaultName.toString()).set('newname', newName.toString()).set('desc', description.toString()).set('tagList', tagList.join(', ')).set('linkid', id); - return this.http.post(`${this.apiServerUrl}/api/script/edit`, content, {params: paramsAddScript}); + const paramsAddScript = new HttpParams() + .set('defaultname', defaultName.toString()) + .set('newname', newName.toString()) + .set('desc', description.toString()) + .set('tagList', tagList.join(', ')) + .set('linkid', id); + return this.http.post(`/api/script/edit`, content, {params: paramsAddScript}); } } diff --git a/src/app/service/tags.service.ts b/src/app/service/tags.service.ts index f9555e4..9178465 100644 --- a/src/app/service/tags.service.ts +++ b/src/app/service/tags.service.ts @@ -1,5 +1,4 @@ import { Injectable } from '@angular/core'; -import { environment } from '../../environments/environment.development'; import { HttpClient } from '@angular/common/http'; import { Observable } from 'rxjs'; import { Tag } from '../model/tag'; @@ -8,31 +7,30 @@ import { Tag } from '../model/tag'; providedIn: 'root' }) export class TagsService { - private apiServerUrl = environment.apiBaseUrl; constructor(private http: HttpClient) { } public addTag(tag: Tag){ - return this.http.post(`${this.apiServerUrl}/api/tag/add`, tag); + return this.http.post(`/api/tag/add`, tag); } public updateTag(prevName: string, tag: Tag){ - return this.http.put(`${this.apiServerUrl}/api/tag/update/${prevName}`, tag); + return this.http.put(`/api/tag/update/${prevName}`, tag); } public getTag(tagId: Number): Observable{ - return this.http.get(`${this.apiServerUrl}/api/tag/${tagId}`); + return this.http.get(`/api/tag/${tagId}`); } public getAllTags(): Observable{ - return this.http.get(`${this.apiServerUrl}/api/tags/all`); + return this.http.get(`/api/tags/all`); } public deleteTag(tagName: String){ - return this.http.delete(`${this.apiServerUrl}/api/tag/delete/${tagName}`); + return this.http.delete(`/api/tag/delete/${tagName}`); } public deleteAllTags(){ - return this.http.delete(`${this.apiServerUrl}/api/tags/deleteAll`); + return this.http.delete(`/api/tags/deleteAll`); } } diff --git a/src/environments/environment.development.ts b/src/environments/environment.development.ts index 76db777..a20cfe5 100644 --- a/src/environments/environment.development.ts +++ b/src/environments/environment.development.ts @@ -1,4 +1,3 @@ export const environment = { production: false, - apiBaseUrl: 'http://178.18.0.5:9001' }; diff --git a/src/environments/environment.ts b/src/environments/environment.ts index 5f4a3c3..a20cfe5 100644 --- a/src/environments/environment.ts +++ b/src/environments/environment.ts @@ -1,5 +1,3 @@ export const environment = { production: false, - apiBaseUrl: 'http://178.18.0.5:9001' - };