Added flask support #70 #75 #71

Merged
edraft merged 107 commits from #70 into 0.3 2022-11-05 13:55:42 +01:00
13 changed files with 135 additions and 77 deletions
Showing only changes of commit f891587ce3 - Show all commits

View File

@ -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

View File

@ -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"]

View File

@ -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)

View File

@ -57,6 +57,14 @@
],
"outputHashing": "all"
},
"staging": {
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.staging.ts"
}
]
},
"development": {
"buildOptimizer": false,
"optimization": false,

View File

@ -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

36
kdb-web/nginx.conf Normal file
View File

@ -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 [16]\.”;
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;
}
}
}

View File

@ -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"
}
}
"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"
}
}

View File

@ -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 {

View File

@ -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) {

View File

@ -0,0 +1,4 @@
export const environment = {
production: true,
apiURL: "http://localhost:5000",
};

View File

@ -1,3 +1,4 @@
export const environment = {
production: true
production: true,
apiURL: "https://kdb.keksdose-gaming.de/",
};

View File

@ -0,0 +1,4 @@
export const environment = {
production: true,
apiURL: "https://kdb-test.keksdose-gaming.de/",
};

View File

@ -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",
};
/*