switch to bjoern

This commit is contained in:
Marco Andronaco 2023-08-09 12:02:01 +02:00
parent 1380bba5ce
commit fc2d8ecb92
7 changed files with 40 additions and 37 deletions

View File

@ -1,9 +1,9 @@
FROM python:3-alpine
FROM tecktron/python-bjoern:latest-slim
WORKDIR /app
RUN pip install --upgrade pip
COPY ./requirements.txt .
RUN pip install -r requirements.txt
COPY . .
CMD ["waitress-serve", "--host", "0.0.0.0", "--port", "1111", "docker_status:app"]
COPY ./docker_status /app/docker_status
WORKDIR /app
ENV APP_MODULE=docker_status:app

View File

@ -1,14 +1,16 @@
# docker-status
A simple status page for my Docker containers.
# Config
## Config
First of all, copy `config.json.example` into `config.json` and fill it out accordingly.
### Poetry
1. Install dependencies: `poetry install`.
2. Start the program:
* Debug: `poetry run flask --app docker_status run --port 1111 --debug`.
* Production: `poetry run waitress-serve --host 0.0.0.0 --port 1111 docker_status:app`
### Docker
Just use `docker-compose up -d`.
Just use `docker-compose up --build --detach`.
### Poetry (debug)
1. Install dependencies: `poetry install`;
2. Start the server: `poetry run flask --app docker_status run --port 1111 --debug`.
### Poetry (production)
1. Install dependencies: `poetry install --with prod`;
2. Start the server: `poetry run python docker_status`.

View File

@ -1,10 +1,10 @@
services:
artbound_python:
app:
build: .
image: docker_status:latest
container_name: docker-status
ports:
- 127.0.0.1:1111:1111
- 127.0.0.1:1111:80
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- ${PWD}/config.json:/app/config.json:ro
@ -12,4 +12,4 @@ services:
test: wget -nv --tries=1 --spider http://localhost:1111/stats || exit 1
interval: 30s
timeout: 5s
retries: 2
retries: 2

View File

@ -0,0 +1,4 @@
import bjoern
from docker_status import app
bjoern.run(app, "0.0.0.0", 1111)

27
poetry.lock generated
View File

@ -1,5 +1,15 @@
# This file is automatically @generated by Poetry 1.5.1 and should not be changed by hand.
[[package]]
name = "bjoern"
version = "3.2.2"
description = "A screamingly fast Python 2 + 3 WSGI server written in C."
optional = false
python-versions = "*"
files = [
{file = "bjoern-3.2.2.tar.gz", hash = "sha256:16e5a02a9a17a7f5f8bea0d7c58650e78ab80ead6fe3e390037573d4355baf31"},
]
[[package]]
name = "blinker"
version = "1.6.2"
@ -344,21 +354,6 @@ secure = ["certifi", "cryptography (>=1.9)", "idna (>=2.0.0)", "pyopenssl (>=17.
socks = ["pysocks (>=1.5.6,!=1.5.7,<2.0)"]
zstd = ["zstandard (>=0.18.0)"]
[[package]]
name = "waitress"
version = "2.1.2"
description = "Waitress WSGI server"
optional = false
python-versions = ">=3.7.0"
files = [
{file = "waitress-2.1.2-py3-none-any.whl", hash = "sha256:7500c9625927c8ec60f54377d590f67b30c8e70ef4b8894214ac6e4cad233d2a"},
{file = "waitress-2.1.2.tar.gz", hash = "sha256:780a4082c5fbc0fde6a2fcfe5e26e6efc1e8f425730863c04085769781f51eba"},
]
[package.extras]
docs = ["Sphinx (>=1.8.1)", "docutils", "pylons-sphinx-themes (>=1.0.9)"]
testing = ["coverage (>=5.0)", "pytest", "pytest-cover"]
[[package]]
name = "websocket-client"
version = "1.6.1"
@ -395,4 +390,4 @@ watchdog = ["watchdog (>=2.3)"]
[metadata]
lock-version = "2.0"
python-versions = "^3.11"
content-hash = "27316642675ea16658ac63df115a9145dea871dd679534ebfbf654ddf28e24d5"
content-hash = "7b49838ba7ada1db17ba863aa5d6284cf5081f6f61bd38c1f170ce76d1b43719"

View File

@ -1,7 +1,7 @@
[tool.poetry]
name = "docker-status"
version = "0.1.0"
description = ""
description = "A simple status page for my Docker containers."
authors = ["Marco Andronaco <andronacomarco@gmail.com>"]
readme = "README.md"
packages = [{include = "docker_status"}]
@ -10,9 +10,14 @@ packages = [{include = "docker_status"}]
python = "^3.11"
flask = "^2.3.2"
requests = "^2.31.0"
waitress = "^2.1.2"
docker = "^6.1.3"
[tool.poetry.group.prod]
optional = true
[tool.poetry.group.prod.dependencies]
bjoern = "^3.2.2"
[build-system]
requires = ["poetry-core"]

View File

@ -176,9 +176,6 @@ requests==2.31.0 ; python_version >= "3.11" and python_version < "4.0" \
urllib3==2.0.4 ; python_version >= "3.11" and python_version < "4.0" \
--hash=sha256:8d22f86aae8ef5e410d4f539fde9ce6b2113a001bb4d189e0aed70642d602b11 \
--hash=sha256:de7df1803967d2c2a98e4b11bb7d6bd9210474c46e8a0401514e3a42a75ebde4
waitress==2.1.2 ; python_version >= "3.11" and python_version < "4.0" \
--hash=sha256:7500c9625927c8ec60f54377d590f67b30c8e70ef4b8894214ac6e4cad233d2a \
--hash=sha256:780a4082c5fbc0fde6a2fcfe5e26e6efc1e8f425730863c04085769781f51eba
websocket-client==1.6.1 ; python_version >= "3.11" and python_version < "4.0" \
--hash=sha256:c951af98631d24f8df89ab1019fc365f2227c0892f12fd150e935607c79dd0dd \
--hash=sha256:f1f9f2ad5291f0225a49efad77abf9e700b6fef553900623060dad6e26503b9d