Skip to content

Commit

Permalink
Bump requirements, push to Docker Hub
Browse files Browse the repository at this point in the history
  • Loading branch information
dcwatson committed Apr 25, 2024
1 parent 01277e9 commit 8578af8
Show file tree
Hide file tree
Showing 18 changed files with 99 additions and 50 deletions.
19 changes: 7 additions & 12 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@ on:
- main
workflow_dispatch: {}

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

jobs:
build-and-push-image:
runs-on: ubuntu-latest
Expand All @@ -19,25 +15,24 @@ jobs:

steps:
- name: Checkout repository
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Log in to the container registry
uses: docker/login-action@v1
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_TOKEN }}

- name: Extract metadata for Docker
id: meta
uses: docker/metadata-action@v3
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
images: ${{ github.repository }}
tags: |
type=raw,value=latest
- name: Build and push Docker image
uses: docker/build-push-action@v2
uses: docker/build-push-action@v5
with:
context: .
push: true
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
__pycache__
*.pyc
.vscode
.nova
.DS_Store
/db.sqlite3
/secret.key
1 change: 1 addition & 0 deletions .python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.12.2
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ ENV LANG=C.UTF-8 \
DEBUG=false \
DATA_DIR=/data

COPY requirements.txt /app/
RUN pip install --no-cache-dir -Ur /app/requirements.txt
COPY requirements.lock /app/
RUN pip install --no-cache-dir -r /app/requirements.lock

COPY . /app

Expand Down
2 changes: 1 addition & 1 deletion gunicorn.conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
import os

bind = os.getenv("GUNICORN_BIND", "0.0.0.0:8000")
workers = int(os.getenv("GUNICORN_WORKERS", multiprocessing.cpu_count() * 2 + 1))
workers = int(os.getenv("GUNICORN_WORKERS", multiprocessing.cpu_count()))
forwarded_allow_ips = "*"
1 change: 1 addition & 0 deletions manage.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/usr/bin/env python
"""Django's command-line utility for administrative tasks."""

import os
import sys

Expand Down
20 changes: 20 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
[project]
name = "tracker"
version = "1.0.0"
description = "Tracker server for Avara"
authors = [
{ name = "Dan Watson", email = "[email protected]" }
]
dependencies = [
"django~=4.2.0",
"gunicorn>=22.0.0",
"requests>=2.31.0",
"whitenoise>=6.6.0",
]
readme = "README.md"
requires-python = ">= 3.8"

[tool.rye]
managed = true
virtual = true
dev-dependencies = []
27 changes: 27 additions & 0 deletions requirements-dev.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# generated by rye
# use `rye lock` or `rye sync` to update this lockfile
#
# last locked with the following flags:
# pre: false
# features: []
# all-features: false
# with-sources: false

asgiref==3.8.1
# via django
certifi==2024.2.2
# via requests
charset-normalizer==3.3.2
# via requests
django==4.2.11
gunicorn==22.0.0
idna==3.7
# via requests
packaging==24.0
# via gunicorn
requests==2.31.0
sqlparse==0.5.0
# via django
urllib3==2.2.1
# via requests
whitenoise==6.6.0
4 changes: 0 additions & 4 deletions requirements.in

This file was deleted.

27 changes: 27 additions & 0 deletions requirements.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# generated by rye
# use `rye lock` or `rye sync` to update this lockfile
#
# last locked with the following flags:
# pre: false
# features: []
# all-features: false
# with-sources: false

asgiref==3.8.1
# via django
certifi==2024.2.2
# via requests
charset-normalizer==3.3.2
# via requests
django==4.2.11
gunicorn==22.0.0
idna==3.7
# via requests
packaging==24.0
# via gunicorn
requests==2.31.0
sqlparse==0.5.0
# via django
urllib3==2.2.1
# via requests
whitenoise==6.6.0
11 changes: 0 additions & 11 deletions requirements.txt

This file was deleted.

5 changes: 0 additions & 5 deletions setup.cfg

This file was deleted.

2 changes: 1 addition & 1 deletion tracker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ spec:
claimName: tracker
containers:
- name: tracker
image: "ghcr.io/avaraline/tracker"
image: "avaraline/tracker"
imagePullPolicy: Always
envFrom:
- configMapRef:
Expand Down
1 change: 0 additions & 1 deletion tracker/migrations/0001_initial.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@


class Migration(migrations.Migration):

initial = True

dependencies = []
Expand Down
1 change: 0 additions & 1 deletion tracker/migrations/0002_game_password.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@


class Migration(migrations.Migration):

dependencies = [
("tracker", "0001_initial"),
]
Expand Down
7 changes: 3 additions & 4 deletions tracker/migrations/0003_game_discord_msgid.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,14 @@


class Migration(migrations.Migration):

dependencies = [
('tracker', '0002_game_password'),
("tracker", "0002_game_password"),
]

operations = [
migrations.AddField(
model_name='game',
name='discord_msgid',
model_name="game",
name="discord_msgid",
field=models.TextField(blank=True),
),
]
11 changes: 6 additions & 5 deletions tracker/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,11 @@ def prune(cls):
continue
try:
requests.patch(
settings.TRACKER_DISCORD_WEBHOOK + f"/messages/{game.discord_msgid}",
json={ "content": "~~" + game.discord_msg() + "~~" })
except:
settings.TRACKER_DISCORD_WEBHOOK
+ f"/messages/{game.discord_msgid}",
json={"content": "~~" + game.discord_msg() + "~~"},
)
except Exception:
pass

cls.objects.filter(last_seen__lt=cutoff).delete()
Expand Down Expand Up @@ -96,8 +98,7 @@ def handle_notification(self, existing_msg):
if existing_msg != new_msg:
# update existing message
resp = requests.patch(
d_url + f"/messages/{self.discord_msgid}",
json={ "content": new_msg }
d_url + f"/messages/{self.discord_msgid}", json={"content": new_msg}
)

def player_list(self):
Expand Down
5 changes: 2 additions & 3 deletions tracker/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,8 @@ def post(self, request, *args, **kwargs):
)
existing_msg = game.discord_msg()
game.update(self.json)
notify = (
settings.TRACKER_DISCORD_WEBHOOK
and (settings.TRACKER_DISCORD_NOTIFY_PASSWORDED or not game.password)
notify = settings.TRACKER_DISCORD_WEBHOOK and (
settings.TRACKER_DISCORD_NOTIFY_PASSWORDED or not game.password
)
if notify:
game.handle_notification(existing_msg)
Expand Down

0 comments on commit 8578af8

Please sign in to comment.