Skip to content

Commit

Permalink
feat: add build & update to latest python
Browse files Browse the repository at this point in the history
  • Loading branch information
FAUSheppy committed Jul 21, 2024
1 parent c32155f commit ee14c3f
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 18 deletions.
32 changes: 32 additions & 0 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
@@ -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 changes: 13 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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 changes: 2 additions & 0 deletions app.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import server
def createApp(envivorment=None, start_response=None):
with server.app.app_context():
server.create_app()
return server.app
42 changes: 24 additions & 18 deletions server.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
import MapSummary

from database import DatabaseConnection
import valve.source.a2s
from valve.source import NoResponseError
#import valve.source.a2s
#from valve.source import NoResponseError


app = flask.Flask("open-leaderboard")
Expand Down Expand Up @@ -42,8 +42,9 @@ def playersOnline():

for s in SERVERS:
try:
with valve.source.a2s.ServerQuerier((s["host"], s["port"])) as server:
playerTotal += int(server.info()["player_count"])
pass
#with valve.source.a2s.ServerQuerier((s["host"], s["port"])) as server:
# playerTotal += int(server.info()["player_count"])
except NoResponseError:
error = "Server Unreachable"
except Exception as e:
Expand Down Expand Up @@ -276,24 +277,26 @@ def leaderboard():
if maxEntry <= 100:
start = max(start, 0)

finalResponse = flask.render_template("base.html", playerList=playerList, \
doNotComputeRank=doNotComputeRank, \
start=start, \
endOfBoardIndicator=endOfBoardIndicator, \
findPlayer=cannotFindPlayer, \
finalResponse = flask.render_template("base.html", playerList=playerList,
doNotComputeRank=doNotComputeRank,
start=start,
endOfBoardIndicator=endOfBoardIndicator,
findPlayer=cannotFindPlayer,
searchName=searchName,
nextPageNumber=int(pageInt)+1,
prevPageNumber=int(pageInt)-1)
return finalResponse

@app.route('/static/<path:path>')
def send_js(path):

response = send_from_directory('static', path)
response.headers['Cache-Control'] = "max-age=2592000"
return response

@app.before_first_request
def init():

def create_app():

global SERVERS

SERVERS_FILE = "servers.json"
Expand All @@ -302,16 +305,19 @@ def init():
SERVERS = json.load(f)

if __name__ == "__main__":
parser = argparse.ArgumentParser(description='Start open-leaderboard', \
formatter_class=argparse.ArgumentDefaultsHelpFormatter)
parser.add_argument('--interface', default="localhost", \

parser = argparse.ArgumentParser(description='Start open-leaderboard',
formatter_class=argparse.ArgumentDefaultsHelpFormatter)
parser.add_argument('--interface', default="localhost",
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')
parser.add_argument('--skillbird-db', required=True,
help='skillbird database (overrides web connection if set)')

with app.app_context():
create_app()

parser.add_argument('--skillbird-db', required=True, help='skillbird database (overrides web connection if set)')


args = parser.parse_args()
app.config["DB_PATH"] = args.skillbird_db
app.run(host=args.interface, port=args.port)

0 comments on commit ee14c3f

Please sign in to comment.