diff --git a/kdb-bot/docker-compose.staging.yml b/kdb-bot/docker-compose.staging.yml index d44ab90bb5..4014bd82bf 100644 --- a/kdb-bot/docker-compose.staging.yml +++ b/kdb-bot/docker-compose.staging.yml @@ -8,7 +8,7 @@ volumes: services: kdb_bot_staging_1: image: kdb-bot/kdb-bot:0.3 - container_name: kdb_staging_1 + container_name: kdb_bot_staging_1 depends_on: - kdb_db_staging_1 volumes: @@ -19,7 +19,8 @@ services: KDB_PREFIX: "!kt " restart: 'no' ports: - - '8043:80' + - '8044:80' + command: bash /app/bot/bot -stage kdb_web_staging_1: image: kdb-web/kdb-web:0.3 @@ -30,7 +31,7 @@ services: - kdb_web_staging_1:/app restart: 'no' ports: - - '8044:80' + - '8043:80' kdb_db_staging_1: image: mysql:latest diff --git a/kdb-bot/dockerfile b/kdb-bot/dockerfile index 144034000c..9857c8f10b 100644 --- a/kdb-bot/dockerfile +++ b/kdb-bot/dockerfile @@ -13,5 +13,6 @@ RUN apk add bash RUN apk add nano RUN pip install -r requirements.txt --extra-index-url https://pip.sh-edraft.de +RUN pip install flask[async] CMD [ "bash", "/app/bot/bot"] diff --git a/kdb-bot/src/bot_api/api.py b/kdb-bot/src/bot_api/api.py index 800898f5f9..f1e79077bd 100644 --- a/kdb-bot/src/bot_api/api.py +++ b/kdb-bot/src/bot_api/api.py @@ -51,7 +51,7 @@ class Api(Flask): self.error_handler_spec[None][code][exc_class] = self.handle_exception # websockets - self._socketio = SocketIO(self, cors_allowed_origins='*') + self._socketio = SocketIO(self, cors_allowed_origins='*', path='/api/socket.io') self._socketio.on_event('connect', self.on_connect) self._socketio.on_event('disconnect', self.on_disconnect) diff --git a/kdb-web/angular.json b/kdb-web/angular.json index b5ac5cd10c..74bfc464f1 100644 --- a/kdb-web/angular.json +++ b/kdb-web/angular.json @@ -57,6 +57,14 @@ ], "outputHashing": "all" }, + "staging": { + "fileReplacements": [ + { + "replace": "src/environments/environment.ts", + "with": "src/environments/environment.staging.ts" + } + ] + }, "development": { "buildOptimizer": false, "optimization": false, diff --git a/kdb-web/dockerfile b/kdb-web/dockerfile index 4564d92066..085b216a10 100644 --- a/kdb-web/dockerfile +++ b/kdb-web/dockerfile @@ -1,2 +1,4 @@ FROM nginx:alpine +COPY nginx.conf /etc/nginx/nginx.conf +RUN rm -rf /usr/share/nginx/html/* COPY ./dist/kdb-web/ /usr/share/nginx/html diff --git a/kdb-web/nginx.conf b/kdb-web/nginx.conf new file mode 100644 index 0000000000..a06f2fdc30 --- /dev/null +++ b/kdb-web/nginx.conf @@ -0,0 +1,36 @@ +events{} + +http { + include /etc/nginx/mime.types; + + server { + listen 80; + + sendfile on; + default_type application/octet-stream; + gzip on; + gzip_http_version 1.1; + gzip_disable “MSIE [1–6]\.”; + gzip_min_length 256; + gzip_vary on; + gzip_proxied expired no-cache no-store private auth; + gzip_types text/plain text/css application/json application/javascript application/x-javascript text/xml application/xml application/xml+rss text/javascript; + gzip_comp_level 9; + + root /usr/share/nginx/html; + index index.html; + location / { + try_files $uri $uri/ /index.html =404; + } + + location /api { + proxy_pass http://kdb_bot_staging_1; + proxy_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection 'upgrade'; + proxy_set_header Host $host; + proxy_cache_bypass $http_upgrade; + proxy_redirect off; + } + } +} diff --git a/kdb-web/package.json b/kdb-web/package.json index 6c04040205..3e8cf3d9a3 100644 --- a/kdb-web/package.json +++ b/kdb-web/package.json @@ -1,52 +1,54 @@ { - "name": "kdb-web", - "version": "0.3.dev70", - "scripts": { - "ng": "ng", - "update-version": "ts-node -O '{\"module\": \"commonjs\"}' update-version.ts", - "prestart": "npm run update-version", - "start": "ng serve", - "prebuild": "npm run update-version", - "build": "ng build", - "watch": "ng build --watch --configuration development", - "test": "ng test", - "docker-build": "export VERSION=$npm_package_version; ng build; docker build -t kdb-web/kdb-web:$VERSION ." - }, - "private": true, - "dependencies": { - "@angular/animations": "^14.0.0", - "@angular/common": "^14.0.0", - "@angular/compiler": "^14.0.0", - "@angular/core": "^14.0.0", - "@angular/forms": "^14.0.0", - "@angular/platform-browser": "^14.0.0", - "@angular/platform-browser-dynamic": "^14.0.0", - "@angular/router": "^14.0.0", - "@auth0/angular-jwt": "^5.1.0", - "@microsoft/signalr": "^6.0.9", - "@ngx-translate/core": "^14.0.0", - "@ngx-translate/http-loader": "^7.0.0", - "@types/socket.io-client": "^3.0.0", - "primeicons": "^6.0.1", - "primeng": "^14.1.2", - "rxjs": "~7.5.0", - "socket.io-client": "^4.5.3", - "tslib": "^2.3.0", - "zone.js": "~0.11.4" - }, - "devDependencies": { - "@angular-devkit/build-angular": "^14.0.0", - "@angular/cli": "~14.0.0", - "@angular/compiler-cli": "^14.0.0", - "@types/jasmine": "~4.0.0", - "@types/node": "^18.8.3", - "jasmine-core": "~4.1.0", - "karma": "~6.3.0", - "karma-chrome-launcher": "~3.1.0", - "karma-coverage": "~2.2.0", - "karma-jasmine": "~5.0.0", - "karma-jasmine-html-reporter": "~1.7.0", - "ts-node": "~8.3.0", - "typescript": "~4.7.2" - } -} \ No newline at end of file + "name": "kdb-web", + "version": "0.3.dev70", + "scripts": { + "ng": "ng", + "update-version": "ts-node -O '{\"module\": \"commonjs\"}' update-version.ts", + "prestart": "npm run update-version", + "start": "ng serve", + "prebuild": "npm run update-version", + "build": "ng build", + "watch": "ng build --watch --configuration development", + "test": "ng test", + "docker-build": "export VERSION=$npm_package_version; ng build; docker build -t kdb-web/kdb-web:$VERSION .", + "docker-build-dev": "export VERSION=$npm_package_version; ng build --configuration development; docker build -t kdb-web/kdb-web:$VERSION .", + "docker-build-stage": "export VERSION=$npm_package_version; ng build --configuration staging; docker build -t kdb-web/kdb-web:$VERSION ." + }, + "private": true, + "dependencies": { + "@angular/animations": "^14.0.0", + "@angular/common": "^14.0.0", + "@angular/compiler": "^14.0.0", + "@angular/core": "^14.0.0", + "@angular/forms": "^14.0.0", + "@angular/platform-browser": "^14.0.0", + "@angular/platform-browser-dynamic": "^14.0.0", + "@angular/router": "^14.0.0", + "@auth0/angular-jwt": "^5.1.0", + "@microsoft/signalr": "^6.0.9", + "@ngx-translate/core": "^14.0.0", + "@ngx-translate/http-loader": "^7.0.0", + "@types/socket.io-client": "^3.0.0", + "primeicons": "^6.0.1", + "primeng": "^14.1.2", + "rxjs": "~7.5.0", + "socket.io-client": "^4.5.3", + "tslib": "^2.3.0", + "zone.js": "~0.11.4" + }, + "devDependencies": { + "@angular-devkit/build-angular": "^14.0.0", + "@angular/cli": "~14.0.0", + "@angular/compiler-cli": "^14.0.0", + "@types/jasmine": "~4.0.0", + "@types/node": "^18.8.3", + "jasmine-core": "~4.1.0", + "karma": "~6.3.0", + "karma-chrome-launcher": "~3.1.0", + "karma-coverage": "~2.2.0", + "karma-jasmine": "~5.0.0", + "karma-jasmine-html-reporter": "~1.7.0", + "ts-node": "~8.3.0", + "typescript": "~4.7.2" + } +} diff --git a/kdb-web/src/app/services/settings/settings.service.ts b/kdb-web/src/app/services/settings/settings.service.ts index ec2b93d737..f594861cbe 100644 --- a/kdb-web/src/app/services/settings/settings.service.ts +++ b/kdb-web/src/app/services/settings/settings.service.ts @@ -1,11 +1,11 @@ -import { HttpClient } from '@angular/common/http'; -import { Injectable } from '@angular/core'; -import { throwError } from 'rxjs'; -import { catchError } from 'rxjs/operators'; -import { Appsettings } from 'src/app/models/config/appsettings'; -import { SoftwareVersion } from 'src/app/models/config/software-version'; -import { Theme } from 'src/app/models/view/theme'; -import { Themes } from 'src/app/models/view/themes.enum'; +import { HttpClient } from "@angular/common/http"; +import { Injectable } from "@angular/core"; +import { throwError } from "rxjs"; +import { catchError } from "rxjs/operators"; +import { Appsettings } from "src/app/models/config/appsettings"; +import { SoftwareVersion } from "src/app/models/config/software-version"; +import { Theme } from "src/app/models/view/theme"; +import { environment } from "../../../environments/environment"; @Injectable({ providedIn: 'root' @@ -31,11 +31,11 @@ export class SettingsService { } public getApiURL(): string { - if (!this.appsettings || !this.appsettings.ApiURL) { + if (!environment || !environment.apiURL) { console.error('ApiURL is not set!'); return ''; } - return this.appsettings.ApiURL; + return environment.apiURL; } public getWebVersion(): SoftwareVersion | null { @@ -43,12 +43,11 @@ export class SettingsService { console.error('WebVersion is not set!'); return null; } - const webVersion = new SoftwareVersion( + return new SoftwareVersion( this.appsettings.WebVersion.Major, this.appsettings.WebVersion.Minor, this.appsettings.WebVersion.Micro ); - return webVersion; } public getThemes(): Theme[] | null { diff --git a/kdb-web/src/app/services/socket/socket.service.ts b/kdb-web/src/app/services/socket/socket.service.ts index a29bba2c65..66b07cb175 100644 --- a/kdb-web/src/app/services/socket/socket.service.ts +++ b/kdb-web/src/app/services/socket/socket.service.ts @@ -1,11 +1,10 @@ -import { HttpClient } from '@angular/common/http'; -import { Injectable } from '@angular/core'; -import { ToastOptions } from 'src/app/models/utils/toast-options'; -import { SettingsService } from '../settings/settings.service'; -import { SpinnerService } from '../spinner/spinner.service'; -import { ToastService } from '../toast/toast.service'; +import { Injectable } from "@angular/core"; +import { ToastOptions } from "src/app/models/utils/toast-options"; +import { SettingsService } from "../settings/settings.service"; +import { SpinnerService } from "../spinner/spinner.service"; +import { ToastService } from "../toast/toast.service"; import io from "socket.io-client"; -import { MessageService } from 'primeng/api'; +import { MessageService } from "primeng/api"; @Injectable({ providedIn: 'root' @@ -23,7 +22,7 @@ export class SocketService { } startSocket() { - this.socket = io(`${this.settingsService.getApiURL()}`) + this.socket = io(`${this.settingsService.getApiURL()}`, {path: '/api/socket.io'}) this.socket.on('connect', () => { if (this.disconnected) { if (this.spinnerService.showSpinnerState) { diff --git a/kdb-web/src/environments/environment.development.ts b/kdb-web/src/environments/environment.development.ts new file mode 100644 index 0000000000..5b94a55f0b --- /dev/null +++ b/kdb-web/src/environments/environment.development.ts @@ -0,0 +1,4 @@ +export const environment = { + production: true, + apiURL: "http://localhost:5000", +}; diff --git a/kdb-web/src/environments/environment.prod.ts b/kdb-web/src/environments/environment.prod.ts index 3612073bc3..4aa3b02b16 100644 --- a/kdb-web/src/environments/environment.prod.ts +++ b/kdb-web/src/environments/environment.prod.ts @@ -1,3 +1,4 @@ export const environment = { - production: true + production: true, + apiURL: "https://kdb.keksdose-gaming.de/", }; diff --git a/kdb-web/src/environments/environment.staging.ts b/kdb-web/src/environments/environment.staging.ts new file mode 100644 index 0000000000..514ffb0ff1 --- /dev/null +++ b/kdb-web/src/environments/environment.staging.ts @@ -0,0 +1,4 @@ +export const environment = { + production: true, + apiURL: "https://kdb-test.keksdose-gaming.de/", +}; diff --git a/kdb-web/src/environments/environment.ts b/kdb-web/src/environments/environment.ts index f56ff47022..beaecd40d0 100644 --- a/kdb-web/src/environments/environment.ts +++ b/kdb-web/src/environments/environment.ts @@ -3,7 +3,8 @@ // The list of file replacements can be found in `angular.json`. export const environment = { - production: false + production: false, + apiURL: "https://kdb_web_prod_1", }; /*