Skip to content

Commit

Permalink
docs: update podman-compose and clean JSON_PATH
Browse files Browse the repository at this point in the history
Signed-off-by: Paul Spooren <[email protected]>
  • Loading branch information
aparcar committed Jan 30, 2025
1 parent ee439c4 commit f10a990
Show file tree
Hide file tree
Showing 7 changed files with 61 additions and 49 deletions.
1 change: 0 additions & 1 deletion asu/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ class Settings(BaseSettings):
model_config = SettingsConfigDict(env_file=".env", env_file_encoding="utf-8")

public_path: Path = Path.cwd() / "public"
json_path: Path = public_path / "json" / "v1"
redis_url: str = "redis://localhost:6379"
upstream_url: str = "https://downloads.openwrt.org"
allow_defaults: bool = False
Expand Down
8 changes: 0 additions & 8 deletions asu/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
app = FastAPI()
app.include_router(api.router, prefix="/api/v1")

(settings.public_path / "json").mkdir(parents=True, exist_ok=True)
(settings.public_path / "store").mkdir(parents=True, exist_ok=True)

app.mount("/store", StaticFiles(directory=settings.public_path / "store"), name="store")
Expand Down Expand Up @@ -167,13 +166,6 @@ def json_v1_overview():
return overview


app.mount(
"/json",
StaticFiles(directory=settings.public_path / "json"),
name="json",
)


@app.get("//{path:path}")
def api_double_slash(path: str):
print(f"Redirecting double slash to single slash: {path}")
Expand Down
7 changes: 4 additions & 3 deletions asu/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

import hishel
import nacl.signing
from fastapi import FastAPI
from httpx import Response
from podman import PodmanClient
from podman.domain.containers import Container
Expand Down Expand Up @@ -423,7 +424,7 @@ def parse_kernel_version(url: str) -> str:
return ""


def reload_versions(app):
def reload_versions(app: FastAPI) -> bool:
response = client_get(settings.upstream_url + "/.versions.json")

if response.extensions["from_cache"] and app.versions:
Expand All @@ -449,7 +450,7 @@ def reload_versions(app):
return True


def reload_targets(app, version: str):
def reload_targets(app: FastAPI, version: str) -> bool:
branch_data = get_branch(version)
version_path = branch_data["path"].format(version=version)
response = client_get(settings.upstream_url + f"/{version_path}/.targets.json")
Expand All @@ -462,7 +463,7 @@ def reload_targets(app, version: str):
return True


def reload_profiles(app, version: str, target: str):
def reload_profiles(app: FastAPI, version: str, target: str) -> bool:
branch_data = get_branch(version)
version_path = branch_data["path"].format(version=version)
response = client_get(
Expand Down
7 changes: 7 additions & 0 deletions misc/asu.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
ALLOW_DEFAULTS=1
CONTAINER_HOST=unix:///run/user/1000/podman/podman.sock
CONTAINER_SOCK=/run/user/1000/podman/podman.sock
PUBLIC_PATH=/home/openwrt/public/
REDIS_URL=redis://redis/
SERVER_STATS=stats
SQUID_CACHE=1
7 changes: 0 additions & 7 deletions misc/snippet.conf

This file was deleted.

17 changes: 7 additions & 10 deletions misc/squid.conf
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
include /etc/squid/conf.d/*
http_access allow localhost
http_access deny all
http_port 3128
coredump_dir /var/spool/squid
refresh_pattern . 0 20% 4320
refresh_pattern ^http://downloads.cdn.openwrt.org 1440 20% 10080
refresh_pattern ^http://downloads.openwrt.org 1440 20% 10080
maximum_object_size 512 MB
coredump_dir /var/spool/squid
maximum_object_size 6 GB
cache_dir ufs /var/spool/squid 30720 16 256
cache_mem 256 MB
maximum_object_size_in_memory 512 KB
cache_replacement_policy heap LFUDA
range_offset_limit -1
quick_abort_min -1 KB
63 changes: 43 additions & 20 deletions podman-compose.yml
Original file line number Diff line number Diff line change
@@ -1,32 +1,38 @@
version: "3"
version: "2"

volumes:
redis:
grafana-storage:

services:
server:
image: "asu:latest"
build:
context: ./
dockerfile: Containerfile
restart: always
environment:
- REDIS_URL=redis://redis/
image: "docker.io/openwrt/asu:latest"
restart: unless-stopped
command: uvicorn --host 0.0.0.0 asu.main:app
env_file: asu.env
volumes:
- $PUBLIC_PATH:$PUBLIC_PATH:ro
ports:
- "127.0.0.1:8000:8000"
depends_on:
- redis

worker:
image: "asu:latest"
build:
context: ./
dockerfile: Containerfile
restart: always
command: rqworker --with-scheduler
environment:
- CONTAINER_HOST=unix://$CONTAINER_SOCK
- REDIS_URL=redis://redis/
image: "docker.io/openwrt/asu:latest"
restart: unless-stopped
command: rqworker --logging_level INFO
env_file: asu.env
volumes:
- $PUBLIC_PATH:$PUBLIC_PATH:rw
- $CONTAINER_SOCK:$CONTAINER_SOCK:rw
depends_on:
- redis

worker2:
image: "docker.io/openwrt/asu:latest"
restart: unless-stopped
command: rqworker --logging_level INFO
env_file: asu.env
volumes:
- $PUBLIC_PATH:$PUBLIC_PATH:rw
- $CONTAINER_SOCK:$CONTAINER_SOCK:rw
Expand All @@ -35,15 +41,32 @@ services:

redis:
image: "docker.io/redis/redis-stack-server"
restart: always
restart: unless-stopped
volumes:
- redis:/data/:rw
ports:
- "127.0.0.1:6379:6379"

squid:
image: "docker.io/ubuntu/squid:latest"
restart: always
restart: unless-stopped
ports:
- "127.0.0.1:3128:3128"
volumes:
- "./misc/snippet.conf:/etc/squid/conf.d/snippet.conf:ro"
- ".squid.conf:/etc/squid/conf.d/snippet.conf:ro"
- "./squid/:/var/spool/squid/:rw"

grafana:
image: docker.io/grafana/grafana-oss
container_name: grafana
restart: unless-stopped
ports:
- "127.0.0.1:3000:3000"
depends_on:
- redis
environment:
GF_SERVER_DOMAIN: sysupgrade.openwrt.org
GF_SERVER_ROOT_URL: https://sysupgrade.openwrt.org/stats/
GF_SERVER_SERVE_FROM_SUB_PATH: "true"
volumes:
- grafana-storage:/var/lib/grafana

0 comments on commit f10a990

Please sign in to comment.