Skip to content

Commit be26e6b

Browse files
committed
Initial commit
1 parent 4189a32 commit be26e6b

24 files changed

Lines changed: 27 additions & 2254 deletions

File tree

.github/workflows/main.yml

Lines changed: 5 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,12 @@ name: Main
22

33
on:
44
push:
5-
branches:
6-
- main
75
tags:
8-
- '*' # Triggers both builds and tag deployments
6+
- '*'
97

108
jobs:
119
build:
12-
name: Build and Test
10+
name: Build
1311
runs-on: ubuntu-latest
1412

1513
steps:
@@ -34,60 +32,12 @@ jobs:
3432
- name: Create Docker Buildx builder
3533
run: docker buildx create --use --name mybuilder
3634

37-
- name: Generate Docker Compose file
38-
run: |
39-
pip install jinja2-cli[yaml]
40-
jinja2 docker-compose.jinja values.yaml -D version=${{ env.VERSION }} -D production=true > docker-compose.yml
41-
4235
- name: Build and push image
43-
if: startsWith(github.ref, 'refs/tags/')
4436
uses: docker/build-push-action@v5
4537
with:
4638
context: .
4739
push: true
4840
tags: |
49-
${{ secrets.DOCKERHUB_USERNAME }}/bgpdata:latest
50-
${{ secrets.DOCKERHUB_USERNAME }}/bgpdata:${{ env.VERSION }}
51-
platforms: linux/amd64
52-
53-
- name: Upload Artifact
54-
uses: actions/upload-artifact@v4
55-
with:
56-
name: docker-compose.yml
57-
path: docker-compose.yml
58-
59-
deploy:
60-
name: Deploy to GitHub Pages
61-
needs: build
62-
if: startsWith(github.ref, 'refs/tags/')
63-
runs-on: ubuntu-latest
64-
permissions:
65-
contents: write
66-
67-
steps:
68-
- name: Checkout Repository
69-
uses: actions/checkout@v4
70-
with:
71-
token: ${{ secrets.GITHUB_TOKEN }}
72-
73-
- name: Set up Git user
74-
run: |
75-
git config user.name "github-actions[bot]"
76-
git config user.email "github-actions[bot]@users.noreply.github.com"
77-
78-
- name: Checkout gh-pages branch
79-
run: |
80-
git fetch --no-tags --filter=blob:none origin gh-pages
81-
git checkout gh-pages || git checkout --orphan gh-pages
82-
83-
- name: Download Artifact
84-
uses: actions/download-artifact@v4
85-
with:
86-
name: docker-compose.yml
87-
path: .
88-
89-
- name: Commit and Push Changes
90-
run: |
91-
git add docker-compose.yml
92-
git commit -m "Deploy latest docker-compose.yml to GitHub Pages"
93-
git push origin gh-pages || echo "No changes to push"
41+
${{ secrets.DOCKERHUB_USERNAME }}/web:latest
42+
${{ secrets.DOCKERHUB_USERNAME }}/web:${{ env.VERSION }}
43+
platforms: linux/amd64

app.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from flask import Flask, render_template, request, redirect, url_for, abort, session, current_app as app, jsonify
22
from utils.text import time_ago, format_text, clean_text, alphanumeric_text, clean_text, sanitize_text, date_text
33
from flask_compress import Compress
4-
from config import MainConfig as Config
4+
from config import Config
55
from flask_cors import CORS
66
from flask_talisman import Talisman
77
from utils.socket import sock, WebSocketBroadcaster

config.py

Lines changed: 14 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
import os
22

3-
class BaseConfig:
4-
ENVIRONMENT = os.getenv('ENVIRONMENT', 'development').lower()
5-
LOG_LEVEL = os.getenv('LOG_LEVEL', 'INFO' if ENVIRONMENT == 'production' else 'DEBUG').upper()
6-
7-
class MainConfig(BaseConfig):
3+
class Config():
84
# Flask
95
FLASK_HOST = os.getenv('FLASK_HOST')
106
SECRET_KEY = os.getenv('SECRET_KEY')
@@ -18,34 +14,23 @@ class MainConfig(BaseConfig):
1814

1915
# Postmark
2016
POSTMARK_API_KEY = os.getenv('POSTMARK_API_KEY')
17+
18+
# Environment
19+
ENVIRONMENT = os.getenv('ENVIRONMENT', 'development').lower()
20+
LOG_LEVEL = os.getenv('LOG_LEVEL', 'INFO' if ENVIRONMENT == 'production' else 'DEBUG').upper()
2121

2222
@staticmethod
2323
def validate():
2424
required = {
25-
'ENVIRONMENT': MainConfig.ENVIRONMENT,
26-
'SECRET_KEY': MainConfig.SECRET_KEY,
27-
'FLASK_HOST': MainConfig.FLASK_HOST,
28-
'POSTMARK_API_KEY': MainConfig.POSTMARK_API_KEY,
29-
'POSTGRES_HOST': MainConfig.POSTGRES_HOST,
30-
'POSTGRES_PORT': MainConfig.POSTGRES_PORT,
31-
'POSTGRES_DB': MainConfig.POSTGRES_DB,
32-
'POSTGRES_USER': MainConfig.POSTGRES_USER,
33-
'POSTGRES_PASSWORD': MainConfig.POSTGRES_PASSWORD,
34-
}
35-
for key, val in required.items():
36-
if not val:
37-
raise ValueError(f"{key} is not set")
38-
39-
40-
class RelayConfig(BaseConfig):
41-
HOST = os.getenv('HOST')
42-
OPENBMP_CONNECT = os.getenv('OPENBMP_CONNECT')
43-
44-
@staticmethod
45-
def validate():
46-
required = {
47-
'HOST': RelayConfig.HOST,
48-
'OPENBMP_CONNECT': RelayConfig.OPENBMP_CONNECT,
25+
'ENVIRONMENT': Config.ENVIRONMENT,
26+
'SECRET_KEY': Config.SECRET_KEY,
27+
'FLASK_HOST': Config.FLASK_HOST,
28+
'POSTMARK_API_KEY': Config.POSTMARK_API_KEY,
29+
'POSTGRES_HOST': Config.POSTGRES_HOST,
30+
'POSTGRES_PORT': Config.POSTGRES_PORT,
31+
'POSTGRES_DB': Config.POSTGRES_DB,
32+
'POSTGRES_USER': Config.POSTGRES_USER,
33+
'POSTGRES_PASSWORD': Config.POSTGRES_PASSWORD,
4934
}
5035
for key, val in required.items():
5136
if not val:

0 commit comments

Comments
 (0)