Initial commit

This commit is contained in:
2025-11-26 23:43:34 -06:00
commit d05a462c4d
9 changed files with 88 additions and 0 deletions

2
.gitignore vendored Normal file
View File

@@ -0,0 +1,2 @@
.venv/
*.ini

3
Dockerfile Normal file
View File

@@ -0,0 +1,3 @@
FROM python:3-trixie as base
WORKDIR /app

0
crontab Normal file
View File

0
docker-compose.yml Normal file
View File

50
main.py Normal file
View File

@@ -0,0 +1,50 @@
import configparser
import requests
from package import pkg
# Local Variables
## Application State
_state = "test"
if _state == "prod":
datafile = "/etc/autopkg/data.ini"
elif _state == "test":
datafile = "data.ini"
## Apps to be packaged
apps = {
"bitcoinknots": "https://api.github.com/repos/bitcoinknots/bitcoin/releases/latest",
"electrs": "https://api.github.com/repos/romanz/electrs/releases/latest"
}
# Setup data file
data = configparser.ConfigParser()
data.read(datafile)
## Setup file if not present
if "Versions" not in data:
data["Versions"] = {}
if __name__ == "__main__":
# Handle apps (get versions)
for app, url in apps.items():
response = requests.get(url)
# Parse through JSON data
if response.status_code == 200:
json = response.json()
version = json["id"]
data["Versions"][app] = str(version)
# Package new versions if available
if version != data["Versions"][app]:
pkg(app, version)
# Write changes
with open("data.ini", "w") as datafile:
data.write(datafile)

26
package.py Normal file
View File

@@ -0,0 +1,26 @@
import docker
from docker import DockerClient
# Container Management
## Build Image
def build(client: DockerClient, app: str):
with open(f"{app}/Dockerfile") as dockerfile:
image, _ = client.images.build(fileobj=dockerfile, tag="")
return image
## Run Image
def run(client: DockerClient, image, app: str):
container = client.containers.run(image, detach=True, name=app)
# Main Packaging Function
def pkg(app, version):
client = docker.from_env()
try:
image = build(client, app)
container = run(client, image, app)
except Exception as e:
print("Error")

View File

1
pkg/electrs/Dockerfile Normal file
View File

@@ -0,0 +1 @@
FROM debian:bookworm as base

6
requirements.txt Normal file
View File

@@ -0,0 +1,6 @@
certifi==2025.11.12
charset-normalizer==3.4.4
docker==7.1.0
idna==3.11
requests==2.32.5
urllib3==2.5.0