Compare commits

..

5 Commits

Author SHA1 Message Date
3c9b8ba3f9 Trigger bot build process
All checks were successful
build
2023-03-28 12:04:22 +02:00
8f685e923e Fixed condition in bot build step 2023-03-28 12:03:59 +02:00
2219ad209d Trigger api and bot build process
All checks were successful
build
2023-03-28 11:58:14 +02:00
ded175cdd2 Use Gitea actions instead of woodpecker and updated dependencies
All checks were successful
build
2023-03-28 11:38:50 +02:00
c2cc959309 Test different port
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
ci/woodpecker/push/pipeline Pipeline failed
2023-02-19 19:54:37 +01:00
13 changed files with 171 additions and 11446 deletions

107
.gitea/workflows/build.yaml Normal file
View File

@ -0,0 +1,107 @@
name: Build & Publish Backend
on:
push:
paths:
- "api/**"
- "frontend/**"
- "telegram_bot/**"
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Check out the repo
uses: actions/checkout@v3
- name: Check changed directories
uses: https://github.com/dorny/paths-filter@v2
id: changes
with:
filters: |
api:
- 'api/**'
frontend:
- 'frontend/**'
telegram_bot:
- 'telegram_bot/**'
# Frontend
- name: "[Frontend] Docker meta"
if: steps.changes.outputs.frontend == 'true'
id: frontend-meta
uses: https://github.com/docker/metadata-action@v4
with:
images: git.flokaiser.com/dhbw/aktienbot-frontend
tags: |
type=sha,enable=true,priority=100,prefix={{branch}}-,suffix=,format=short
type=raw,value=latest,enable={{is_default_branch}}
# API
- name: "[API] Docker meta"
if: steps.changes.outputs.api == 'true'
id: api-meta
uses: https://github.com/docker/metadata-action@v4
with:
images: git.flokaiser.com/dhbw/aktienbot-api
tags: |
type=sha,enable=true,priority=100,prefix={{branch}}-,suffix=,format=short
type=raw,value=latest,enable={{is_default_branch}}
# Bot
- name: "[Bot] Docker meta"
if: steps.changes.outputs.telegram_bot == 'true'
id: bot-meta
uses: https://github.com/docker/metadata-action@v4
with:
images: git.flokaiser.com/dhbw/aktienbot-bot
tags: |
type=sha,enable=true,priority=100,prefix={{branch}}-,suffix=,format=short
type=raw,value=latest,enable={{is_default_branch}}
- name: Get get-docker.sh
run: curl -fsSL https://get.docker.com -o get-docker.sh
- name: Install docker
run: sh get-docker.sh
- name: Login to Registry
uses: docker/login-action@v2
with:
registry: git.flokaiser.com
username: ${{ secrets.REGISTRY_USERNAME }}
password: ${{ secrets.REGISTRY_TOKEN }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
# Frontend
- name: "[Frontend] Build and push"
if: steps.changes.outputs.frontend == 'true'
uses: docker/build-push-action@v4
with:
file: Dockerfile
context: "{{defaultContext}}:frontend"
platforms: linux/amd64
push: true
tags: ${{ steps.frontend-meta.outputs.tags }}
# API
- name: "[API] Build and push"
if: steps.changes.outputs.api == 'true'
uses: docker/build-push-action@v4
with:
file: Dockerfile
context: "{{defaultContext}}:api"
platforms: linux/amd64
push: true
tags: ${{ steps.api-meta.outputs.tags }}
# Bot
- name: "[Bot] Build and push"
if: steps.changes.outputs.telegram_bot == 'true'
uses: docker/build-push-action@v4
with:
file: Dockerfile
context: "{{defaultContext}}:telegram_bot"
platforms: linux/amd64
push: true
tags: ${{ steps.bot-meta.outputs.tags }}

View File

@ -1,87 +0,0 @@
pipeline:
generate_docker_tag:
image: golang
commands:
- echo -n "${CI_COMMIT_BRANCH//\//-}-${CI_COMMIT_SHA:0:8}, latest" > .tags
when:
path: [ "frontend/**", "telegram_bot/**", "api/**" ]
event: push
# -------------------------------------- API --------------------------------------
build_api:
image: woodpeckerci/plugin-docker-buildx
settings:
repo:
from_secret: repo_api
username:
from_secret: username
password:
from_secret: password
registry:
from_secret: registry
dockerfile: api/Dockerfile
platforms: linux/amd64
when:
path: "api/**"
event: push
# -------------------------------------- Bot --------------------------------------
build_bot:
image: woodpeckerci/plugin-docker-buildx
settings:
repo:
from_secret: repo_bot
username:
from_secret: username
password:
from_secret: password
registry:
from_secret: registry
dockerfile: telegram_bot/Dockerfile
platforms: linux/amd64
when:
path: "telegram_bot/**"
event: push
# -------------------------------------- Frontend --------------------------------------
build_frontend:
image: woodpeckerci/plugin-docker-buildx
settings:
repo:
from_secret: repo_frontend
username:
from_secret: username
password:
from_secret: password
registry:
from_secret: registry
dockerfile: frontend/Dockerfile
platforms: linux/amd64
when:
path: "frontend/**"
event: push
# -------------------------------------- Deploy --------------------------------------
deploy:
image: appleboy/drone-ssh
network_mode: host
settings:
host:
from_secret: ssh_host
username:
from_secret: ssh_user
password:
from_secret: ssh_password
script:
- cd ~/docker-compose-files/telegram_aktien_bot
- docker-compose pull
- docker-compose --env-file ~/docker-compose-env/telegram_aktien_bot.env up -d
when:
path: [ "frontend/**", "telegram_bot/**", "api/**" ]
event: push
branches: main

View File

@ -1,4 +1,3 @@
[![Build Status](https://gitea.woodpecker.flokaiser.com/api/badges/DHBW/TelegramAktienBot/status.svg)](https://gitea.woodpecker.flokaiser.com/DHBW/TelegramAktienBot)
# TelegramAktienBot
WebEngineering2 Projekt: Aktien und News Bot für Telegram

View File

@ -7,12 +7,12 @@ WORKDIR /srv/flask_app
RUN apt update && apt install -y python3 python3-pip curl nginx && rm -rf /var/lib/apt/lists/*
# Install the dependencies
COPY api/requirements.txt /srv/flask_app/
COPY requirements.txt /srv/flask_app/
RUN pip install -r requirements.txt --src /usr/local/src --no-warn-script-location
# Copy the source code to the working directory
COPY api /srv/flask_app
COPY api/deploy/nginx.conf /etc/nginx
COPY . /srv/flask_app
COPY ./deploy/nginx.conf /etc/nginx
# Change file permissions
RUN chmod +x ./deploy/start.sh

View File

@ -49,7 +49,7 @@ docker run -d \
--env "MYSQL_PORT=" \
--env "MYSQL_DATABASE=" \
--restart unless-stopped \
registry.flokaiser.com/aktienbot/api:latest
git.flokaiser.com/dhbw/aktienbot-api:latest
```
or load environment variables from file by using `--env-file <filename>`

View File

@ -7,6 +7,6 @@ __version__ = "1.0.0"
from app import create_app
# Create an application instance that web servers can use.
application = create_app('config/flask.cfg')
application.run()

View File

@ -24,8 +24,8 @@ http {
index index.html index.htm;
server {
listen 80 default_server;
listen [::]:80 default_server;
listen 81 default_server;
listen [::]:81 default_server;
server_name homeserver.flokaiser.com;
root /var/www/html;

View File

@ -1,18 +1,17 @@
Flask~=2.1.2
python-dotenv==0.21.0
Flask==2.2.3
python-dotenv==1.0.0
uwsgi==2.0.21
Flask_SQLAlchemy==3.0.2
python-dotenv==0.21.0
Flask_SQLAlchemy==3.0.3
pymysql==1.0.2
pyjwt==2.6.0
apiflask==1.0.0
apiflask==1.3.1
flask-cors==3.0.10
bcrypt==4.0.1
pytest~=7.2.0
pytest-cov
marshmallow~=3.19.0
faker~=15.3.4
requests~=2.28.1
investpy~=1.0.8
pandas~=1.5.0
currencyconverter~=0.17.1
pytest==7.2.2
pytest-cov==4.0.
marshmallow==3.19.0
faker==18.3.1
requests==2.28.1
investpy==1.0.8
pandas==1.5.3
currencyconverter==0.17.6

View File

@ -1,10 +1,10 @@
FROM node:latest as build
FROM node:18 as build
# Change to the project directory
WORKDIR /usr/local/app
# Copy the project files to the container
COPY frontend/ /usr/local/app/
COPY . /usr/local/app/
# Install dependencies
RUN npm install
@ -16,8 +16,8 @@ FROM nginx:latest
COPY --from=build /usr/local/app/dist/aktienbot /usr/share/nginx/html
# Copy configuration files
COPY frontend/deploy/nginx.conf /etc/nginx
COPY frontend/deploy deploy/
COPY ./deploy/nginx.conf /etc/nginx
COPY ./deploy deploy/
# Change file permissions
RUN chmod +x ./deploy/healthcheck.sh

11297
frontend/package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -4,50 +4,50 @@
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build --configuration production --build-optimizer",
"watch": "ng build --configuration development --watch",
"build": "ng build --prod --build-optimizer",
"watch": "ng build --watch --configuration development",
"test": "ng test",
"lint": "ng lint",
"compodoc": "npx compodoc -p tsconfig.doc.json"
},
"private": true,
"dependencies": {
"@angular/animations": "~15.0.0",
"@angular/cdk": "^15.0.0",
"@angular/common": "~15.0.0",
"@angular/compiler": "~15.0.0",
"@angular/core": "~15.0.0",
"@angular/forms": "~15.0.0",
"@angular/material": "^15.0.0",
"@angular/platform-browser": "~15.0.0",
"@angular/platform-browser-dynamic": "~15.0.0",
"@angular/router": "~15.0.0",
"bootstrap": "^5.1.3",
"ngx-cron-editor": "^0.7.3",
"rxjs": "~7.6.0",
"tslib": "^2.4.0",
"zone.js": "~0.12.0"
"@angular/animations": "~13.2.0",
"@angular/cdk": "~13.2.6",
"@angular/common": "~13.2.0",
"@angular/compiler": "~13.2.0",
"@angular/core": "~13.2.0",
"@angular/forms": "~13.2.0",
"@angular/material": "13.2.6",
"@angular/platform-browser": "~13.2.0",
"@angular/platform-browser-dynamic": "~13.2.0",
"@angular/router": "~13.2.0",
"bootstrap": "5.1.3",
"ngx-cron-editor": "0.7.3",
"rxjs": "~7.5.0",
"tslib": "2.4.0",
"zone.js": "~0.11.4"
},
"devDependencies": {
"@angular-devkit/build-angular": "~15.0.0",
"@angular-eslint/builder": "15.1.0",
"@angular-eslint/eslint-plugin": "15.1.0",
"@angular-eslint/eslint-plugin-template": "15.1.0",
"@angular-eslint/schematics": "15.2.1",
"@angular-eslint/template-parser": "15.1.0",
"@angular/cli": "~15.0.0",
"@angular/compiler-cli": "~15.0.0",
"@types/jasmine": "~4.3.0",
"@types/node": "^18.0.0",
"@typescript-eslint/eslint-plugin": "5.46.1",
"@typescript-eslint/parser": "5.46.1",
"@angular-devkit/build-angular": "~13.3.5",
"@angular-eslint/builder": "13.2.1",
"@angular-eslint/eslint-plugin": "13.2.1",
"@angular-eslint/eslint-plugin-template": "13.2.1",
"@angular-eslint/schematics": "13.2.1",
"@angular-eslint/template-parser": "13.2.1",
"@angular/cli": "~13.3.5",
"@angular/compiler-cli": "~13.2.0",
"@types/jasmine": "~4.0.3",
"@types/node": "^12.11.1",
"@typescript-eslint/eslint-plugin": "5.23.0",
"@typescript-eslint/parser": "5.22.0",
"eslint": "^8.15.0",
"jasmine-core": "~4.5.0",
"karma": "~6.4.0",
"jasmine-core": "~4.1.0",
"karma": "~6.3.19",
"karma-chrome-launcher": "~3.1.0",
"karma-coverage": "~2.2.0",
"karma-jasmine": "~5.1.0",
"karma-jasmine-html-reporter": "~2.0.0",
"typescript": "~4.9.0"
"karma-jasmine": "~5.0.0",
"karma-jasmine-html-reporter": "~1.7.0",
"typescript": "~4.5.2"
}
}

View File

@ -3,12 +3,16 @@ FROM python:3.11-slim
# Change the working directory to the root of the project
WORKDIR /srv/flask_app
# Create venv
RUN python -m venv myvenv
ENV PATH="myvenv/bin:$PATH"
# Install the dependencies
COPY telegram_bot/requirements.txt /srv/flask_app/
COPY requirements.txt /srv/flask_app/
RUN pip install -r requirements.txt --src /usr/local/src --no-warn-script-location
# Copy the source code to the working directory
COPY telegram_bot /srv/flask_app
COPY . /srv/flask_app
# Change file permissions
RUN chmod +x ./deploy/start.sh

View File

@ -32,7 +32,7 @@ docker run -d \
--env "BOT_API_KEY=" \
--env "NEWS_API_KEY=" \
--restart unless-stopped \
registry.flokaiser.com/aktienbot/bot:latest
git.flokaiser.com/dhbw/aktienbot-bot:latest
```
or load environment variables from file by using `--env-file <filename>`