mirror of
https://github.com/FAUSheppy/open-web-leaderboard.git
synced 2025-12-06 15:11:35 +01:00
feat: add build & update to latest python
This commit is contained in:
32
.github/workflows/main.yaml
vendored
Normal file
32
.github/workflows/main.yaml
vendored
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
name: Container Build for open-web-leaderboard
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- "master"
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
docker:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
environment:
|
||||||
|
name: prod
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
-
|
||||||
|
name: Checkout
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
-
|
||||||
|
name: Login to Docker Registry
|
||||||
|
uses: docker/login-action@v2
|
||||||
|
with:
|
||||||
|
registry: ${{ secrets.REGISTRY }}
|
||||||
|
username: ${{ secrets.REGISTRY_USER }}
|
||||||
|
password: ${{ secrets.REGISTRY_PASS }}
|
||||||
|
-
|
||||||
|
name: open-web-leaderboard
|
||||||
|
uses: docker/build-push-action@v3
|
||||||
|
with:
|
||||||
|
context: .
|
||||||
|
platforms: linux/amd64
|
||||||
|
push: true
|
||||||
|
tags: "${{ secrets.REGISTRY }}/atlantishq/open-web-leaderboard:latest"
|
||||||
13
Dockerfile
Normal file
13
Dockerfile
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
FROM alpine
|
||||||
|
|
||||||
|
RUN apk add --no-cache py3-pip
|
||||||
|
RUN python3 -m pip install --no-cache-dir --break-system-packages waitress
|
||||||
|
COPY req.txt .
|
||||||
|
RUN python3 -m pip install --no-cache-dir --break-system-packages -r req.txt
|
||||||
|
|
||||||
|
RUN mkdir /app
|
||||||
|
WORKDIR /app
|
||||||
|
COPY ./ .
|
||||||
|
|
||||||
|
ENTRYPOINT ["waitress-serve"]
|
||||||
|
CMD ["--host", "0.0.0.0", "--port", "5000", "--call", "app:createApp"]
|
||||||
2
app.py
2
app.py
@@ -1,3 +1,5 @@
|
|||||||
import server
|
import server
|
||||||
def createApp(envivorment=None, start_response=None):
|
def createApp(envivorment=None, start_response=None):
|
||||||
|
with server.app.app_context():
|
||||||
|
server.create_app()
|
||||||
return server.app
|
return server.app
|
||||||
|
|||||||
40
server.py
40
server.py
@@ -10,8 +10,8 @@ import os
|
|||||||
import MapSummary
|
import MapSummary
|
||||||
|
|
||||||
from database import DatabaseConnection
|
from database import DatabaseConnection
|
||||||
import valve.source.a2s
|
#import valve.source.a2s
|
||||||
from valve.source import NoResponseError
|
#from valve.source import NoResponseError
|
||||||
|
|
||||||
|
|
||||||
app = flask.Flask("open-leaderboard")
|
app = flask.Flask("open-leaderboard")
|
||||||
@@ -42,8 +42,9 @@ def playersOnline():
|
|||||||
|
|
||||||
for s in SERVERS:
|
for s in SERVERS:
|
||||||
try:
|
try:
|
||||||
with valve.source.a2s.ServerQuerier((s["host"], s["port"])) as server:
|
pass
|
||||||
playerTotal += int(server.info()["player_count"])
|
#with valve.source.a2s.ServerQuerier((s["host"], s["port"])) as server:
|
||||||
|
# playerTotal += int(server.info()["player_count"])
|
||||||
except NoResponseError:
|
except NoResponseError:
|
||||||
error = "Server Unreachable"
|
error = "Server Unreachable"
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
@@ -276,11 +277,11 @@ def leaderboard():
|
|||||||
if maxEntry <= 100:
|
if maxEntry <= 100:
|
||||||
start = max(start, 0)
|
start = max(start, 0)
|
||||||
|
|
||||||
finalResponse = flask.render_template("base.html", playerList=playerList, \
|
finalResponse = flask.render_template("base.html", playerList=playerList,
|
||||||
doNotComputeRank=doNotComputeRank, \
|
doNotComputeRank=doNotComputeRank,
|
||||||
start=start, \
|
start=start,
|
||||||
endOfBoardIndicator=endOfBoardIndicator, \
|
endOfBoardIndicator=endOfBoardIndicator,
|
||||||
findPlayer=cannotFindPlayer, \
|
findPlayer=cannotFindPlayer,
|
||||||
searchName=searchName,
|
searchName=searchName,
|
||||||
nextPageNumber=int(pageInt)+1,
|
nextPageNumber=int(pageInt)+1,
|
||||||
prevPageNumber=int(pageInt)-1)
|
prevPageNumber=int(pageInt)-1)
|
||||||
@@ -288,12 +289,14 @@ def leaderboard():
|
|||||||
|
|
||||||
@app.route('/static/<path:path>')
|
@app.route('/static/<path:path>')
|
||||||
def send_js(path):
|
def send_js(path):
|
||||||
|
|
||||||
response = send_from_directory('static', path)
|
response = send_from_directory('static', path)
|
||||||
response.headers['Cache-Control'] = "max-age=2592000"
|
response.headers['Cache-Control'] = "max-age=2592000"
|
||||||
return response
|
return response
|
||||||
|
|
||||||
@app.before_first_request
|
|
||||||
def init():
|
def create_app():
|
||||||
|
|
||||||
global SERVERS
|
global SERVERS
|
||||||
|
|
||||||
SERVERS_FILE = "servers.json"
|
SERVERS_FILE = "servers.json"
|
||||||
@@ -302,15 +305,18 @@ def init():
|
|||||||
SERVERS = json.load(f)
|
SERVERS = json.load(f)
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
parser = argparse.ArgumentParser(description='Start open-leaderboard', \
|
|
||||||
formatter_class=argparse.ArgumentDefaultsHelpFormatter)
|
parser = argparse.ArgumentParser(description='Start open-leaderboard',
|
||||||
parser.add_argument('--interface', default="localhost", \
|
formatter_class=argparse.ArgumentDefaultsHelpFormatter)
|
||||||
|
parser.add_argument('--interface', default="localhost",
|
||||||
help='Interface on which flask (this server) will take requests on')
|
help='Interface on which flask (this server) will take requests on')
|
||||||
parser.add_argument('--port', default="5002", \
|
parser.add_argument('--port', default="5002",
|
||||||
help='Port on which flask (this server) will take requests on')
|
help='Port on which flask (this server) will take requests on')
|
||||||
|
parser.add_argument('--skillbird-db', required=True,
|
||||||
|
help='skillbird database (overrides web connection if set)')
|
||||||
|
|
||||||
parser.add_argument('--skillbird-db', required=True, help='skillbird database (overrides web connection if set)')
|
with app.app_context():
|
||||||
|
create_app()
|
||||||
|
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
app.config["DB_PATH"] = args.skillbird_db
|
app.config["DB_PATH"] = args.skillbird_db
|
||||||
|
|||||||
Reference in New Issue
Block a user