From 314c42acd1595146a66a9530c982b660832cf3e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Dybiec?= Date: Sun, 24 May 2020 23:36:36 +0200 Subject: Add cs map service --- compose/app/Dockerfile | 2 +- compose/cs/Dockerfile | 6 ++++++ compose/cs/__pycache__/cs.cpython-38.pyc | Bin 0 -> 1474 bytes compose/cs/cs.py | 30 ++++++++++++++++++++++++++ compose/cs/requirements.txt | 1 + compose/cs/static/icon.png | Bin 0 -> 3734 bytes compose/cs/static/style.css | 35 +++++++++++++++++++++++++++++++ compose/cs/templates/main.html | 27 ++++++++++++++++++++++++ docker.yml | 33 ++++++++++++++++++++--------- domains.yml | 5 +++++ 10 files changed, 128 insertions(+), 11 deletions(-) create mode 100644 compose/cs/Dockerfile create mode 100644 compose/cs/__pycache__/cs.cpython-38.pyc create mode 100644 compose/cs/cs.py create mode 100644 compose/cs/requirements.txt create mode 100644 compose/cs/static/icon.png create mode 100644 compose/cs/static/style.css create mode 100644 compose/cs/templates/main.html diff --git a/compose/app/Dockerfile b/compose/app/Dockerfile index 8e67d74..8db20e0 100644 --- a/compose/app/Dockerfile +++ b/compose/app/Dockerfile @@ -1,4 +1,4 @@ -FROM python:3.4-alpine +FROM python:3.8-alpine ADD . /code WORKDIR /code RUN pip install -r requirements.txt diff --git a/compose/cs/Dockerfile b/compose/cs/Dockerfile new file mode 100644 index 0000000..57323dd --- /dev/null +++ b/compose/cs/Dockerfile @@ -0,0 +1,6 @@ +FROM python:3.7-alpine +ADD . /code +WORKDIR /code +RUN pip install -r requirements.txt +ENV FLASK_APP cs.py +CMD ["python3", "-m", "flask", "run", "--host=0.0.0.0"] diff --git a/compose/cs/__pycache__/cs.cpython-38.pyc b/compose/cs/__pycache__/cs.cpython-38.pyc new file mode 100644 index 0000000..9d63e21 Binary files /dev/null and b/compose/cs/__pycache__/cs.cpython-38.pyc differ diff --git a/compose/cs/cs.py b/compose/cs/cs.py new file mode 100644 index 0000000..b455af2 --- /dev/null +++ b/compose/cs/cs.py @@ -0,0 +1,30 @@ +import datetime +from typing import List, Tuple +from flask import Flask, render_template +app = Flask("Today's maps") +maps = [ "mirage 🇲🇦", + "inferno 🔥", + "overpass 🌉", + "vertigo 🏗️", + "nuke ☢", + "train 🚆", + "dust 🏜", + "anubis ☥", + "cache ☭", + "agency 🏢", + "office 🖥"] + +def maps_of_day(day: datetime.date) -> Tuple[str, str]: + l = len(maps) + i = (day-day.replace(day=1, month=1)).days+1 + return maps[(2*i)%l], maps[(2*i+1)%l] + +def maps_of_current_week() -> List[Tuple[str, str, str]]: + today = datetime.date.today() + days = [today+datetime.timedelta(days=i) for i in range(6)] + return [(day.strftime("%A"), *maps_of_day(day)) for day in days] + +@app.route("/") +def main(): + return render_template("main.html", maps=maps_of_current_week()) + diff --git a/compose/cs/requirements.txt b/compose/cs/requirements.txt new file mode 100644 index 0000000..7e10602 --- /dev/null +++ b/compose/cs/requirements.txt @@ -0,0 +1 @@ +flask diff --git a/compose/cs/static/icon.png b/compose/cs/static/icon.png new file mode 100644 index 0000000..b02d809 Binary files /dev/null and b/compose/cs/static/icon.png differ diff --git a/compose/cs/static/style.css b/compose/cs/static/style.css new file mode 100644 index 0000000..b4eac13 --- /dev/null +++ b/compose/cs/static/style.css @@ -0,0 +1,35 @@ +@import url("https://fonts.googleapis.com/css?family=Noto+Sans"); +html { + font-family: "Noto Sans", "Noto Color Emoji"; +} +html table { + font-size: 30px; + width: 40%; + margin: 0 auto; + border-collapse: collapse; + margin-bottom: 5mm; +} +html table th { + border-bottom: .2mm solid #5b5; + color: #5b5; + padding: 2mm; + text-transform: uppercase; +} +html table td { + padding: 2.5mm; +} +.map { + color: #55b; + font-weight: bold; + text-align: center; +} +.maps th:first-of-type, +.maps td:first-of-type { + text-align: left; + padding-left: 3mm; +} +.maps th:last-of-type, +.maps td:last-of-type { + text-align: right; + padding-right: 3mm; +} diff --git a/compose/cs/templates/main.html b/compose/cs/templates/main.html new file mode 100644 index 0000000..c93bfac --- /dev/null +++ b/compose/cs/templates/main.html @@ -0,0 +1,27 @@ + + + Map of a day + + + + + + + + + + + + {% for e in maps %} + + + + + + + {% endfor %} + +
Day Map Map
{{ e[0] }}{{ e[1] }}{{ e[2] }}
+ + + diff --git a/docker.yml b/docker.yml index 529b4f7..a8379ef 100644 --- a/docker.yml +++ b/docker.yml @@ -25,8 +25,24 @@ short_name: "{{item.key}}" with_items: "{{domains | dict2items}}" when: (item.value.disabled is undefined) or (item.value.disabled != true) + - name: nginx + docker_compose: + project_name: nginx + pull: yes + build: yes + restarted: yes + definition: + version: '3' + services: + main: + build: "{{docker_compose_dir}}/nginx" + network_mode: host + volumes: + - "/etc/letsencrypt/live/dybiec.info:/etc/letsencrypt/live/dybiec.info:ro" + - "/etc/letsencrypt/archive/dybiec.info:/etc/letsencrypt/archive/dybiec.info:ro" + restart: always - - name: Counter app + - name: counter app docker_compose: project_name: app pull: yes @@ -42,21 +58,18 @@ redis: image: "redis:alpine" restart: always - - name: nginx + - name: csgo docker_compose: - project_name: nginx + project_name: cs pull: yes build: yes - restarted: yes definition: version: '3' services: - main: - build: "{{docker_compose_dir}}/nginx" - network_mode: host - volumes: - - "/etc/letsencrypt/live/dybiec.info:/etc/letsencrypt/live/dybiec.info:ro" - - "/etc/letsencrypt/archive/dybiec.info:/etc/letsencrypt/archive/dybiec.info:ro" + web: + build: "{{docker_compose_dir}}/cs" + ports: + - "127.0.0.1:{{domains.cs.proxy.port}}:5000" restart: always - name: gitea diff --git a/domains.yml b/domains.yml index 154785e..90fac86 100644 --- a/domains.yml +++ b/domains.yml @@ -11,6 +11,11 @@ domains: port: 5001 cache: true keepalive: true + cs: + name: "cs.dybiec.info" + websocket: true + proxy: + port: 5002 cnt: name: "cnt.dybiec.info" websocket: true -- cgit v1.2.3