Skip to content

Commit

Permalink
Use Docker and prepare for 37c3
Browse files Browse the repository at this point in the history
  • Loading branch information
stblassitude committed Dec 17, 2023
1 parent f428c18 commit 59a7b9f
Show file tree
Hide file tree
Showing 7 changed files with 360 additions and 13 deletions.
22 changes: 22 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Docker Image CI

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

jobs:

build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Build the Docker image
run: docker build . --file Dockerfile --tag c3lingo/c3lingo-mumblestats:latest --tag c3lingo/c3lingo-mumblestats:$(date +%s)
- name: Log into registry
run: echo "${{ secrets.DOCKER_HUB_PASSWORD }}" | docker login -u ${{ secrets.DOCKER_HUB_USERNAME }} --password-stdin
- name: Push to Docker Hub
run: docker push c3lingo/c3lingo-mumblestats:latest
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.venv
*~
__pycache__
/.idea
19 changes: 19 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
FROM python:buster

RUN apt-get -y update && \
apt-get install -y libopus-dev portaudio19-dev pulseaudio && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*

COPY requirements.txt /tmp
RUN pip install -r /tmp/requirements.txt && \
rm -f /tmp/requirements.txt

RUN useradd -ms /bin/bash app
USER app
WORKDIR /home/app
COPY --chown=app mumblestats.py ./
COPY --chown=app index.tpl ./
COPY --chown=app static ./static

CMD ["/usr/local/bin/python", "mumblestats.py", "mumble.c3lingo.org"]
17 changes: 17 additions & 0 deletions Pipfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
[[source]]
url = "https://pypi.org/simple"
verify_ssl = true
name = "pypi"

[packages]
bottle = "*"
bottle-websocket = "*"
pymumble = "*"
prometheus-client = "*"
pyaudio = "*"

[dev-packages]

[requires]
python_version = "3.11"
python_full_version = "3.11.2"
281 changes: 281 additions & 0 deletions Pipfile.lock

Large diffs are not rendered by default.

8 changes: 5 additions & 3 deletions mumblestats.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import json
import math
import random
import re
import string
import sys
import time
Expand Down Expand Up @@ -35,7 +36,7 @@ def __init__(self, server, channel, nick='meter-{r}@{channel}',
self.mumble.start()
self.mumble.is_ready()

if self.channelname is not 'root':
if self.channelname != 'root':
self.channel = self.mumble.channels.find_by_name(self.channelname)
self.channel.move_in()

Expand Down Expand Up @@ -102,8 +103,9 @@ def __init__(self, server):
self.wsstats_clients = []
self.metrics = {}
self.running = True
channel_re = re.compile('Saal.*-(original|translation-1|translation-2)')
root = MumbleChannelStats(self.server, 'root')
self.channels = [c['name'] for c in list(root.get_channels())[1:]]
self.channels = [c['name'] for c in list(root.get_channels())[1:] if channel_re.match(c['name'])]
self.mumble_close(root)
# buckets = (-36, -30, -24, -18, -12, -6, -3, 0, 3)
# self.metric_level = Histogram(
Expand Down Expand Up @@ -238,7 +240,7 @@ def main():
mumble_stats = MumbleStats(sys.argv[1])
mumble_stats.thread()
try:
run(host='localhost', port=8080, server=GeventWebSocketServer,
run(host='0.0.0.0', port=8080, server=GeventWebSocketServer,
debug=False)
except KeyboardInterrupt:
mumble_stats.stop()
Expand Down
25 changes: 15 additions & 10 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
bottle
bottle-websocket
opuslib
prometheus-client
protobuf
pyaudio
# optional for transitive bottle-websocket -> gevent-websocket
wsaccel
ujson
-e git+git@github.com:stblassitude/pymumble.git#egg=pymumble
-i https://pypi.org/simple
bottle==0.12.25
bottle-websocket==0.2.9
gevent==23.9.1 ; python_version >= '3.8'
gevent-websocket==0.10.1
greenlet==3.0.2 ; python_version >= '3.11' and platform_python_implementation == 'CPython'
opuslib==3.0.1
prometheus-client==0.19.0
protobuf==3.12.2
pyaudio==0.2.14
pymumble==1.6.1
setuptools==69.0.2 ; python_version >= '3.8'
six==1.16.0 ; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'
zope.event==5.0 ; python_version >= '3.7'
zope.interface==6.1 ; python_version >= '3.7'

0 comments on commit 59a7b9f

Please # to comment.