aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaweł Dybiec <pawel@dybiec.info>2020-05-24 23:36:36 +0200
committerPaweł Dybiec <pawel@dybiec.info>2020-05-24 23:36:36 +0200
commit314c42acd1595146a66a9530c982b660832cf3e5 (patch)
tree34ef9ec80df82178887f6ae00a924d7a2b430c96
parentOptimize darling website (diff)
Add cs map service
-rw-r--r--compose/app/Dockerfile2
-rw-r--r--compose/cs/Dockerfile6
-rw-r--r--compose/cs/__pycache__/cs.cpython-38.pycbin0 -> 1474 bytes
-rw-r--r--compose/cs/cs.py30
-rw-r--r--compose/cs/requirements.txt1
-rw-r--r--compose/cs/static/icon.pngbin0 -> 3734 bytes
-rw-r--r--compose/cs/static/style.css35
-rw-r--r--compose/cs/templates/main.html27
-rw-r--r--docker.yml33
-rw-r--r--domains.yml5
10 files changed, 128 insertions, 11 deletions
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
--- /dev/null
+++ b/compose/cs/__pycache__/cs.cpython-38.pyc
Binary files 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
--- /dev/null
+++ b/compose/cs/static/icon.png
Binary files 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 @@
+<html>
+ <head>
+ <title> Map of a day </title>
+ <link rel="stylesheet" href="{{ url_for('static', filename='style.css') }}" />
+ <link rel="icon" type="image/png" href="{{ url_for('static', filename='icon.png') }}">
+ <link rel="apple-touch-icon" type="image/png" href="{{ url_for('static', filename='icon.png') }}">
+ </head>
+ <body>
+ <table class="maps">
+ <thead>
+ <th> Day </th>
+ <th> Map </th>
+ <th> Map </th>
+ <tbody>
+ {% for e in maps %}
+ <tr>
+ <td class="day">{{ e[0] }}</td>
+ <td class="map">{{ e[1] }}</td>
+ <td class="map">{{ e[2] }}</td>
+ </tr>
+
+ {% endfor %}
+ </tbody>
+ </table>
+ </body>
+
+</html>
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