41
.gitea/workflows/build.yml
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
name: Build Docker
|
||||||
|
run-name: Build Docker Images
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
Build Image:
|
||||||
|
runs-on: [ubuntu-latest, amd]
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
- name: Install Docker
|
||||||
|
run : |
|
||||||
|
apt-get install ca-certificates curl gnupg
|
||||||
|
install -m 0755 -d /etc/apt/keyrings
|
||||||
|
curl -fsSL https://download.docker.com/linux/debian/gpg | gpg --dearmor -o /etc/apt/keyrings/docker.gpg
|
||||||
|
chmod a+r /etc/apt/keyrings/docker.gpg
|
||||||
|
echo "deb [arch="$(dpkg --print-architecture)" signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/debian "$(. /etc/os-release && echo "$VERSION_CODENAME")" stable" | tee /etc/apt/sources.list.d/docker.list > /dev/null
|
||||||
|
apt-get update
|
||||||
|
apt-get install docker-ce-cli -y
|
||||||
|
- name: Build Docker image
|
||||||
|
run : |
|
||||||
|
echo "${{ secrets.DOCKERGIT_TOKEN }}" | docker login git.woodburn.au -u nathanwoodburn --password-stdin
|
||||||
|
echo "branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}"
|
||||||
|
tag=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}
|
||||||
|
tag=${tag//\//-}
|
||||||
|
tag_num=${GITHUB_RUN_NUMBER}
|
||||||
|
echo "tag_num=$tag_num"
|
||||||
|
|
||||||
|
if [[ "$tag" == "main" ]]; then
|
||||||
|
tag="latest"
|
||||||
|
else
|
||||||
|
tag_num="${tag}-${tag_num}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
docker build -t hnsau:$tag_num .
|
||||||
|
docker tag hnsau:$tag_num git.woodburn.au/nathanwoodburn/hnsau:$tag_num
|
||||||
|
docker push git.woodburn.au/nathanwoodburn/hnsau:$tag_num
|
||||||
|
docker tag hnsau:$tag_num git.woodburn.au/nathanwoodburn/hnsau:$tag
|
||||||
|
docker push git.woodburn.au/nathanwoodburn/hnsau:$tag
|
||||||
42
main.py
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
import time
|
||||||
|
from flask import Flask
|
||||||
|
from server import app
|
||||||
|
import server
|
||||||
|
from gunicorn.app.base import BaseApplication
|
||||||
|
import os
|
||||||
|
import dotenv
|
||||||
|
import sys
|
||||||
|
import json
|
||||||
|
|
||||||
|
|
||||||
|
class GunicornApp(BaseApplication):
|
||||||
|
def __init__(self, app, options=None):
|
||||||
|
self.options = options or {}
|
||||||
|
self.application = app
|
||||||
|
super().__init__()
|
||||||
|
|
||||||
|
def load_config(self):
|
||||||
|
for key, value in self.options.items():
|
||||||
|
if key in self.cfg.settings and value is not None:
|
||||||
|
self.cfg.set(key.lower(), value)
|
||||||
|
|
||||||
|
def load(self):
|
||||||
|
return self.application
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
workers = os.getenv('WORKERS')
|
||||||
|
threads = os.getenv('THREADS')
|
||||||
|
if workers is None:
|
||||||
|
workers = 1
|
||||||
|
if threads is None:
|
||||||
|
threads = 2
|
||||||
|
workers = int(workers)
|
||||||
|
threads = int(threads)
|
||||||
|
options = {
|
||||||
|
'bind': '0.0.0.0:5000',
|
||||||
|
'workers': workers,
|
||||||
|
'threads': threads,
|
||||||
|
}
|
||||||
|
gunicorn_app = GunicornApp(app, options)
|
||||||
|
print('Starting server with ' + str(workers) + ' workers and ' + str(threads) + ' threads', flush=True)
|
||||||
|
gunicorn_app.run()
|
||||||
5
requirements.txt
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
flask
|
||||||
|
python-dotenv
|
||||||
|
gunicorn
|
||||||
|
requests
|
||||||
|
cloudflare
|
||||||
66
server.py
Normal file
@@ -0,0 +1,66 @@
|
|||||||
|
from flask import Flask, make_response, redirect, request, jsonify, render_template, send_from_directory
|
||||||
|
import os
|
||||||
|
import dotenv
|
||||||
|
import requests
|
||||||
|
import CloudFlare
|
||||||
|
|
||||||
|
app = Flask(__name__)
|
||||||
|
dotenv.load_dotenv()
|
||||||
|
|
||||||
|
|
||||||
|
#Assets routes
|
||||||
|
@app.route('/assets/<path:path>')
|
||||||
|
def send_report(path):
|
||||||
|
return send_from_directory('templates/assets', path)
|
||||||
|
|
||||||
|
@app.route('/sitemap')
|
||||||
|
@app.route('/sitemap.xml')
|
||||||
|
def sitemap():
|
||||||
|
# Remove all .html from sitemap
|
||||||
|
with open('templates/sitemap.xml') as file:
|
||||||
|
sitemap = file.read()
|
||||||
|
|
||||||
|
sitemap = sitemap.replace('.html', '')
|
||||||
|
return make_response(sitemap, 200, {'Content-Type': 'application/xml'})
|
||||||
|
|
||||||
|
@app.route('/favicon.png')
|
||||||
|
def faviconPNG():
|
||||||
|
return send_from_directory('templates/assets/img', 'favicon.png')
|
||||||
|
|
||||||
|
@app.route('/https.js')
|
||||||
|
@app.route('/handshake.js')
|
||||||
|
@app.route('/redirect.js')
|
||||||
|
def handshake():
|
||||||
|
# return request.path
|
||||||
|
return send_from_directory('templates/', request.path.split('/')[-1])
|
||||||
|
|
||||||
|
@app.route('/.well-known/wallets/<path:path>')
|
||||||
|
def wallet(path):
|
||||||
|
return send_from_directory('.well-known/wallets', path, mimetype='text/plain')
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# Main routes
|
||||||
|
@app.route('/')
|
||||||
|
def index():
|
||||||
|
return render_template('index.html')
|
||||||
|
|
||||||
|
@app.route('/<path:path>')
|
||||||
|
def catch_all(path):
|
||||||
|
# If file exists, load it
|
||||||
|
if os.path.isfile('templates/' + path):
|
||||||
|
return render_template(path)
|
||||||
|
|
||||||
|
# Try with .html
|
||||||
|
if os.path.isfile('templates/' + path + '.html'):
|
||||||
|
return render_template(path + '.html')
|
||||||
|
|
||||||
|
return render_template('404.html'), 404
|
||||||
|
|
||||||
|
# 404 catch all
|
||||||
|
@app.errorhandler(404)
|
||||||
|
def not_found(e):
|
||||||
|
return render_template('404.html'), 404
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
app.run(debug=True, port=5000, host='0.0.0.0')
|
||||||
|
Before Width: | Height: | Size: 692 KiB After Width: | Height: | Size: 692 KiB |
|
Before Width: | Height: | Size: 141 KiB After Width: | Height: | Size: 141 KiB |
|
Before Width: | Height: | Size: 829 KiB After Width: | Height: | Size: 829 KiB |
|
Before Width: | Height: | Size: 326 KiB After Width: | Height: | Size: 326 KiB |
|
Before Width: | Height: | Size: 547 B After Width: | Height: | Size: 547 B |
|
Before Width: | Height: | Size: 7.6 KiB After Width: | Height: | Size: 7.6 KiB |
|
Before Width: | Height: | Size: 6.9 KiB After Width: | Height: | Size: 6.9 KiB |
|
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.1 KiB |
|
Before Width: | Height: | Size: 25 KiB After Width: | Height: | Size: 25 KiB |
|
Before Width: | Height: | Size: 406 KiB After Width: | Height: | Size: 406 KiB |
|
Before Width: | Height: | Size: 88 KiB After Width: | Height: | Size: 88 KiB |
|
Before Width: | Height: | Size: 101 KiB After Width: | Height: | Size: 101 KiB |
|
Before Width: | Height: | Size: 60 KiB After Width: | Height: | Size: 60 KiB |
|
Before Width: | Height: | Size: 67 KiB After Width: | Height: | Size: 67 KiB |
|
Before Width: | Height: | Size: 25 KiB After Width: | Height: | Size: 25 KiB |
|
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 1.2 KiB |
|
Before Width: | Height: | Size: 13 KiB After Width: | Height: | Size: 13 KiB |
|
Before Width: | Height: | Size: 13 KiB After Width: | Height: | Size: 13 KiB |
|
Before Width: | Height: | Size: 1.9 KiB After Width: | Height: | Size: 1.9 KiB |
|
Before Width: | Height: | Size: 58 KiB After Width: | Height: | Size: 58 KiB |
|
Before Width: | Height: | Size: 70 KiB After Width: | Height: | Size: 70 KiB |
|
Before Width: | Height: | Size: 547 B After Width: | Height: | Size: 547 B |
|
Before Width: | Height: | Size: 7.6 KiB After Width: | Height: | Size: 7.6 KiB |
|
Before Width: | Height: | Size: 6.9 KiB After Width: | Height: | Size: 6.9 KiB |
|
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.1 KiB |
|
Before Width: | Height: | Size: 25 KiB After Width: | Height: | Size: 25 KiB |
|
Before Width: | Height: | Size: 769 KiB After Width: | Height: | Size: 769 KiB |
|
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 12 KiB |
|
Before Width: | Height: | Size: 5.1 KiB After Width: | Height: | Size: 5.1 KiB |
|
Before Width: | Height: | Size: 80 KiB After Width: | Height: | Size: 80 KiB |
|
Before Width: | Height: | Size: 284 KiB After Width: | Height: | Size: 284 KiB |
|
Before Width: | Height: | Size: 102 KiB After Width: | Height: | Size: 102 KiB |
|
Before Width: | Height: | Size: 84 KiB After Width: | Height: | Size: 84 KiB |
|
Before Width: | Height: | Size: 110 KiB After Width: | Height: | Size: 110 KiB |
|
Before Width: | Height: | Size: 186 KiB After Width: | Height: | Size: 186 KiB |
|
Before Width: | Height: | Size: 117 KiB After Width: | Height: | Size: 117 KiB |
|
Before Width: | Height: | Size: 249 KiB After Width: | Height: | Size: 249 KiB |
|
Before Width: | Height: | Size: 85 KiB After Width: | Height: | Size: 85 KiB |
|
Before Width: | Height: | Size: 25 KiB After Width: | Height: | Size: 25 KiB |