Compare commits
4 Commits
9334160e89
...
6843da9fa3
Author | SHA1 | Date |
---|---|---|
|
6843da9fa3 | |
|
9433d4273d | |
|
6e53569d7a | |
|
396f26277f |
|
@ -51,5 +51,21 @@ pipeline {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
stage('Build Container') {
|
||||||
|
steps {
|
||||||
|
container('podman') {
|
||||||
|
sh '. ci/build-container.sh'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
stage('Publish Container') {
|
||||||
|
steps {
|
||||||
|
container('podman') {
|
||||||
|
sh '. ci/publish-container.sh'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
#!/bin/sh -ex
|
||||||
|
|
||||||
|
. ci/container-common.sh
|
||||||
|
|
||||||
|
cp -r svc/dist container/wheels
|
||||||
|
cp -r ui/dist container/ui
|
||||||
|
podman build -t hudctrl:$(tag_name ${BUILD_TAG}) container
|
|
@ -0,0 +1,10 @@
|
||||||
|
# shellcheck: shell=sh
|
||||||
|
|
||||||
|
tag_name() {
|
||||||
|
echo "$1" | sed -e 's/[^a-zA-Z0-9._-]/-/g' -e 's/^[.-]/_/'
|
||||||
|
}
|
||||||
|
|
||||||
|
push() {
|
||||||
|
tag=$(tag_name $1)
|
||||||
|
podman push hudctrl:${BUILD_TAG} registry.pyrocufflink.blue/hudctrl:${tag}
|
||||||
|
}
|
|
@ -27,3 +27,10 @@ spec:
|
||||||
securityContext:
|
securityContext:
|
||||||
readOnlyRootFilesystem: true
|
readOnlyRootFilesystem: true
|
||||||
runAsUser: 1000
|
runAsUser: 1000
|
||||||
|
- name: podman
|
||||||
|
image: quay.io/containers/podman:v3.4
|
||||||
|
command:
|
||||||
|
- sleep
|
||||||
|
- infinity
|
||||||
|
securityContext:
|
||||||
|
privileged: true
|
||||||
|
|
|
@ -0,0 +1,9 @@
|
||||||
|
#!/bin/sh -ex
|
||||||
|
|
||||||
|
. ci/container-common.sh
|
||||||
|
|
||||||
|
push ${BUILD_TAG}
|
||||||
|
push ${BRANCH_NAME}
|
||||||
|
if [ "${BRANCH_NAME}" = master ]; then
|
||||||
|
push latest
|
||||||
|
fi
|
|
@ -0,0 +1,2 @@
|
||||||
|
ui/
|
||||||
|
wheels/
|
|
@ -0,0 +1,19 @@
|
||||||
|
FROM docker.io/python:3.10-slim AS build
|
||||||
|
|
||||||
|
COPY wheels /tmp/wheels
|
||||||
|
COPY requirements.txt /tmp
|
||||||
|
RUN python -m venv /usr/local/hudctrl
|
||||||
|
RUN /usr/local/hudctrl/bin/python -m \
|
||||||
|
pip install -f /tmp/wheels -r /tmp/requirements.txt
|
||||||
|
|
||||||
|
COPY ui /usr/local/hudctrl/ui
|
||||||
|
|
||||||
|
FROM docker.io/python:3.10-slim
|
||||||
|
RUN apt-get update && \
|
||||||
|
apt-get install -y nginx tini && \
|
||||||
|
rm -rf /var/cache/apt /var/lib/apt
|
||||||
|
COPY nginx.conf /etc/nginx/nginx.conf
|
||||||
|
COPY --from=build /usr/local/hudctrl /usr/local/hudctrl
|
||||||
|
COPY run.sh /
|
||||||
|
|
||||||
|
CMD ["tini", "--", "/run.sh"]
|
|
@ -0,0 +1,42 @@
|
||||||
|
# vim: set sw=4 ts=4 sts=4 et :
|
||||||
|
|
||||||
|
user www-data;
|
||||||
|
worker_processes auto;
|
||||||
|
pid /run/nginx.pid;
|
||||||
|
|
||||||
|
events {
|
||||||
|
worker_connections 768;
|
||||||
|
}
|
||||||
|
|
||||||
|
http {
|
||||||
|
sendfile on;
|
||||||
|
tcp_nopush on;
|
||||||
|
types_hash_max_size 2048;
|
||||||
|
|
||||||
|
include /etc/nginx/mime.types;
|
||||||
|
default_type application/octet-stream;
|
||||||
|
|
||||||
|
access_log /dev/stderr;
|
||||||
|
error_log /var/log/nginx/error.log;
|
||||||
|
|
||||||
|
gzip on;
|
||||||
|
|
||||||
|
server {
|
||||||
|
listen 80 default_server;
|
||||||
|
listen [::]:80 default_server;
|
||||||
|
server_name _;
|
||||||
|
|
||||||
|
root /usr/local/hudctrl/ui;
|
||||||
|
index index.html;
|
||||||
|
|
||||||
|
location /api/ {
|
||||||
|
proxy_pass http://127.0.0.1:8000/;
|
||||||
|
|
||||||
|
real_ip_header X-Forwarded-For;
|
||||||
|
set_real_ip_from 0.0.0.0/0;
|
||||||
|
set_real_ip_from ::/0;
|
||||||
|
real_ip_recursive on;
|
||||||
|
proxy_set_header Host $proxy_host;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,3 @@
|
||||||
|
gunicorn
|
||||||
|
hudctrl
|
||||||
|
uvicorn
|
|
@ -0,0 +1,7 @@
|
||||||
|
#!/bin/sh
|
||||||
|
# vim: set sw=4 ts=4 sts=4 et :
|
||||||
|
|
||||||
|
nginx || exit $?
|
||||||
|
exec /usr/local/hudctrl/bin/gunicorn \
|
||||||
|
-k uvicorn.workers.UvicornWorker \
|
||||||
|
hudctrl.api:app
|
|
@ -9,7 +9,7 @@ python = "^3.10"
|
||||||
fastapi = "^0.75.1"
|
fastapi = "^0.75.1"
|
||||||
uvicorn = "^0.17.6"
|
uvicorn = "^0.17.6"
|
||||||
python-multipart = "^0.0.5"
|
python-multipart = "^0.0.5"
|
||||||
aiomarionette = "^0.0.2"
|
aiomarionette = "^0.0.3"
|
||||||
Pillow = "^9.1.0"
|
Pillow = "^9.1.0"
|
||||||
|
|
||||||
[tool.poetry.dev-dependencies]
|
[tool.poetry.dev-dependencies]
|
||||||
|
@ -61,3 +61,7 @@ warn_return_any = true
|
||||||
module = 'hudctrl.api'
|
module = 'hudctrl.api'
|
||||||
disallow_untyped_defs = false
|
disallow_untyped_defs = false
|
||||||
disallow_incomplete_defs = false
|
disallow_incomplete_defs = false
|
||||||
|
|
||||||
|
[tool.pyright]
|
||||||
|
venvPath = '.'
|
||||||
|
venv = '.venv'
|
||||||
|
|
|
@ -1,9 +1,11 @@
|
||||||
import io
|
import io
|
||||||
import logging
|
import logging
|
||||||
|
import os
|
||||||
|
from pathlib import Path
|
||||||
from typing import Optional
|
from typing import Optional
|
||||||
|
|
||||||
import fastapi
|
|
||||||
from PIL import Image
|
from PIL import Image
|
||||||
|
import fastapi
|
||||||
|
|
||||||
from .hud import HUDService, NoMonitorConfig
|
from .hud import HUDService, NoMonitorConfig
|
||||||
from .xrandr import MonitorConfig
|
from .xrandr import MonitorConfig
|
||||||
|
@ -15,11 +17,16 @@ log = logging.getLogger(__name__)
|
||||||
logging.basicConfig(level=logging.DEBUG)
|
logging.basicConfig(level=logging.DEBUG)
|
||||||
|
|
||||||
|
|
||||||
|
HUDCTRL_URLS_FILE = os.environ.get('HUDCTRL_URLS_FILE')
|
||||||
|
|
||||||
|
|
||||||
app = fastapi.FastAPI(
|
app = fastapi.FastAPI(
|
||||||
docs_url='/api-doc/',
|
docs_url='/api-doc/',
|
||||||
)
|
)
|
||||||
|
|
||||||
svc = HUDService()
|
svc = HUDService()
|
||||||
|
if HUDCTRL_URLS_FILE:
|
||||||
|
svc.urls_file = Path(HUDCTRL_URLS_FILE)
|
||||||
|
|
||||||
|
|
||||||
class PNGImageResponse(fastapi.Response):
|
class PNGImageResponse(fastapi.Response):
|
||||||
|
|
Loading…
Reference in New Issue