From fa730cac1b1a476ab6c3b5e122890b64f6e49da3 Mon Sep 17 00:00:00 2001 From: ahoemann Date: Wed, 5 Feb 2025 18:28:17 +0100 Subject: [PATCH 01/39] docs: updated for docker; feat: local and latest dockerfiles; add: .dockerignore file; feat: implemented health check for adrianux app --- .dockerignore | 6 ++++++ .gitignore | 1 + README.md | 32 +++++++++++++++++++++++------- app.py | 32 +++++++++++++++++++++--------- docker-compose.yml | 13 ++++++++++++ Containerfile => latest.dockerfile | 0 local.dockerfile | 19 ++++++++++++++++++ 7 files changed, 87 insertions(+), 16 deletions(-) create mode 100644 .dockerignore create mode 100644 docker-compose.yml rename Containerfile => latest.dockerfile (100%) create mode 100644 local.dockerfile diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..c054be6 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,6 @@ +.forgejo +compose.yml +*.dockerfile +.gitignore +LICENSE +README.md diff --git a/.gitignore b/.gitignore index 033df5f..32ac21b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ .venv +.env __pycache__ diff --git a/README.md b/README.md index 37b9af4..d8bec04 100644 --- a/README.md +++ b/README.md @@ -1,32 +1,50 @@ # Installation - ## Setting up the environment 1. Create a virtual environment: -```bash +```sh python3 -m venv .venv ``` 2. Activate the virtual environment: -```bash +```sh . .venv/bin/activate ``` 3. Install dependencies: -```bash +```sh pip install requirements.txt ``` +4. Set the environment variables: +```sh +export GIT_URL=http://git.adrianux.net +export WEBSITE_URL=http://adrianux.net +export DEBUGMODE=False +``` + +5. Run the app: +```sh +waitress-serve --listen=0.0.0.0:8080 app:app +``` + +# Docker + ## Building the container -``` -# build -t adrianux: . +```sh +docker build -t adrianux:latest - < latest.dockerfile ``` ## Running the container +```sh +docker run adrianux:latest ``` -# run adrianux: +# Docker Compose + +```sh +docker compose up adrianux ``` diff --git a/app.py b/app.py index 29999af..99b6757 100755 --- a/app.py +++ b/app.py @@ -1,7 +1,10 @@ #!/usr/bin/env python3 from flask import Flask, render_template, redirect, url_for +from concurrent.futures import ThreadPoolExecutor import requests import os +import time + app = Flask(__name__) @@ -19,17 +22,18 @@ def homepage(): @app.route("/monitoring") def monitoring(): - git_url = os.environ['GIT_URL'] - website_url = os.environ['WEBSITE_URL'] - return render_template("monitoring.html", git_status = get_status(git_url), website_status = get_status(website_url) ) + global git_status + global website_status + executor = ThreadPoolExecutor(2) + executor.submit(monitor) + return render_template("monitoring.html", git_status = git_status, website_status = website_status) -def get_status_code(link): - requested_site = requests.get(link) - return requested_site.status_code def get_status(link): + requested_site = requests.get(link) + status_code = requested_site.status_code try: - match get_status_code(link): + match status_code: case 200: return "ONLINE" case _: @@ -37,6 +41,16 @@ def get_status(link): except: return "OFFLINE" +def monitor(): + while True: + git_status = get_status(os.environ['GIT_URL']) + website_status = get_status(os.environ['WEBSITE_URL']) + time.sleep(5) + + + if __name__ == "__main__": - mode = os.environ['DEBUG_MODE'] - app.run(debug=mode) + app.run(debug=os.environ['DEBUG_MODE']) + + + diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..731ba82 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,13 @@ +--- + services: + build: + context: "." + dockerfile: "latest.dockerfile" + container_name: "adrianux" + image: "adrianux:latest" + environment: + - "GIT_URL=http://git.adrianux.net" + - "WEBSITE_URL=http://adrianux.net" + - "DEBUG_MODE=False" + ports: + - "127.0.0.1:8080:8080" diff --git a/Containerfile b/latest.dockerfile similarity index 100% rename from Containerfile rename to latest.dockerfile diff --git a/local.dockerfile b/local.dockerfile new file mode 100644 index 0000000..1e8a9f6 --- /dev/null +++ b/local.dockerfile @@ -0,0 +1,19 @@ +FROM alpine:latest +WORKDIR /opt/ + +ENV GIT_URL=https://git.adrianux.net +ENV WEBSITE_URL=https://adrianux.net +ENV DEBUG_MODE=False + +COPY . . + +RUN apk add --no-cache git python3 +RUN python3 -m venv /opt/.venv +RUN /opt/.venv/bin/pip install --no-cache-dir -r requirements.txt +RUN apk del git + +EXPOSE 8080 + +HEALTHCHECK --interval=5m CMD wget --delete-after http://localhost:8080 + +CMD [ "/opt/.venv/bin/waitress-serve", "--listen=0.0.0.0:8080", "app:app" ] From c9d61cd9fb74544e35df88b6ed82456961f7b2e5 Mon Sep 17 00:00:00 2001 From: ahoemann Date: Wed, 5 Feb 2025 18:29:37 +0100 Subject: [PATCH 02/39] docs: updated for docker; feat: local and latest dockerfiles; add: .dockerignore file; feat: implemented health check for adrianux app --- latest.dockerfile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/latest.dockerfile b/latest.dockerfile index d8812f0..d1433b1 100644 --- a/latest.dockerfile +++ b/latest.dockerfile @@ -13,4 +13,6 @@ RUN apk del git EXPOSE 8080 +HEALTHCHECK --interval=5m CMD wget --delete-after http://localhost:8080 + CMD [ "/opt/.venv/bin/waitress-serve", "--listen=0.0.0.0:8080", "app:app" ] From ee4c6978e69c08e049d1d1411f0d85c703eb5b84 Mon Sep 17 00:00:00 2001 From: ahoemann Date: Wed, 12 Feb 2025 10:40:57 +0100 Subject: [PATCH 03/39] fix: ignore all things containing git information --- .dockerignore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.dockerignore b/.dockerignore index c054be6..35f2d33 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,6 +1,6 @@ .forgejo compose.yml *.dockerfile -.gitignore +.git* LICENSE README.md From c001c5f0b82e945649bd0bd1d458673074e7517d Mon Sep 17 00:00:00 2001 From: ahoemann Date: Wed, 12 Feb 2025 16:48:53 +0100 Subject: [PATCH 04/39] Delete .forgejo/workflows/update.yaml --- .forgejo/workflows/update.yaml | 7 ------- 1 file changed, 7 deletions(-) delete mode 100644 .forgejo/workflows/update.yaml diff --git a/.forgejo/workflows/update.yaml b/.forgejo/workflows/update.yaml deleted file mode 100644 index 981d93d..0000000 --- a/.forgejo/workflows/update.yaml +++ /dev/null @@ -1,7 +0,0 @@ -on: [push] -jobs: - update: - runs-on: self-hosted - steps: - - run: sudo git -C /opt/Adrianux.net/ pull - - run: sudo systemctl restart adrianux \ No newline at end of file From eff59303bf95480b84f05d36fed60b97e3499440 Mon Sep 17 00:00:00 2001 From: ahoemann Date: Thu, 13 Feb 2025 17:29:42 +0100 Subject: [PATCH 05/39] add: initial Jenkinsfile --- Jenkinsfile | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 Jenkinsfile diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 0000000..2452bbd --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,23 @@ +pipeline { + agent any + stages { + stage('Pull Alpine Image') { + steps { + script { + // Pull the Alpine Docker image + + dockerImage = docker.image('alpine:latest') + + dockerImage.pull() + } + } + } + stage('Deploy') { + steps { + script { + } + } + } + } + +} \ No newline at end of file From 38b91d6fc99009badfd36f4947cc60df37fa8030 Mon Sep 17 00:00:00 2001 From: ahoemann Date: Fri, 14 Feb 2025 08:52:08 +0100 Subject: [PATCH 06/39] Update Jenkinsfile --- Jenkinsfile | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 2452bbd..347dc1b 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,5 +1,5 @@ pipeline { - agent any + agent { dockerfile true } stages { stage('Pull Alpine Image') { steps { @@ -12,9 +12,16 @@ pipeline { } } } - stage('Deploy') { + stage('Build') { steps { script { + docker.withRegistry('https://git.adrianux.net/ahoemann/') { + + /* Build the container image */ + def dockerImage = docker.build("adrianux:${env.BUILD_ID}") + + /* Push the container to the custom Registry */ + dockerImage.push() } } } From 4253e606eba006166631059ac49b0155531ba3e8 Mon Sep 17 00:00:00 2001 From: ahoemann Date: Fri, 14 Feb 2025 08:52:22 +0100 Subject: [PATCH 07/39] Update Jenkinsfile --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 347dc1b..13203e0 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -15,7 +15,7 @@ pipeline { stage('Build') { steps { script { - docker.withRegistry('https://git.adrianux.net/ahoemann/') { + docker.withRegistry('https://git.adrianux.net/ahoemann/') { /* Build the container image */ def dockerImage = docker.build("adrianux:${env.BUILD_ID}") From e1e158421498aa9cc282f58812bb7bca2bdbf90c Mon Sep 17 00:00:00 2001 From: ahoemann Date: Fri, 14 Feb 2025 08:53:29 +0100 Subject: [PATCH 08/39] Update Jenkinsfile --- Jenkinsfile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Jenkinsfile b/Jenkinsfile index 13203e0..8b1ce5a 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -23,6 +23,8 @@ pipeline { /* Push the container to the custom Registry */ dockerImage.push() } + /* Remove docker image*/ + sh 'docker rmi -f adrianux:${env.BUILD_ID}' } } } From 06bb092b37f840c70220915021f3524072d73147 Mon Sep 17 00:00:00 2001 From: ahoemann Date: Fri, 14 Feb 2025 09:03:48 +0100 Subject: [PATCH 09/39] Update Jenkinsfile --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 8b1ce5a..ca3175a 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -25,8 +25,8 @@ pipeline { } /* Remove docker image*/ sh 'docker rmi -f adrianux:${env.BUILD_ID}' + } } } } - } \ No newline at end of file From dec236e2f9ff15036292cf096a2a17c5887c8d24 Mon Sep 17 00:00:00 2001 From: ahoemann Date: Fri, 14 Feb 2025 12:05:14 +0100 Subject: [PATCH 10/39] Delete latest.dockerfile --- latest.dockerfile | 18 ------------------ 1 file changed, 18 deletions(-) delete mode 100644 latest.dockerfile diff --git a/latest.dockerfile b/latest.dockerfile deleted file mode 100644 index d1433b1..0000000 --- a/latest.dockerfile +++ /dev/null @@ -1,18 +0,0 @@ -FROM alpine:latest -WORKDIR /opt/ - -ENV GIT_URL=https://git.adrianux.net -ENV WEBSITE_URL=https://adrianux.net -ENV DEBUG_MODE=False - -RUN apk add --no-cache git python3 -RUN git clone https://git.adrianux.net/ahoemann/Adrianux.net.git /opt -RUN python3 -m venv /opt/.venv -RUN /opt/.venv/bin/pip install --no-cache-dir -r requirements.txt -RUN apk del git - -EXPOSE 8080 - -HEALTHCHECK --interval=5m CMD wget --delete-after http://localhost:8080 - -CMD [ "/opt/.venv/bin/waitress-serve", "--listen=0.0.0.0:8080", "app:app" ] From bdb8898adc7e7ef4e6f48bf5b40904e937c7b9a3 Mon Sep 17 00:00:00 2001 From: ahoemann Date: Fri, 14 Feb 2025 12:05:28 +0100 Subject: [PATCH 11/39] Update Dockerfile --- local.dockerfile => Dockerfile | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename local.dockerfile => Dockerfile (100%) diff --git a/local.dockerfile b/Dockerfile similarity index 100% rename from local.dockerfile rename to Dockerfile From 053b5737587f7d572232162fcff3fdc3009fba62 Mon Sep 17 00:00:00 2001 From: ahoemann Date: Wed, 12 Mar 2025 17:44:53 +0100 Subject: [PATCH 12/39] Update templates/about.html --- templates/about.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/about.html b/templates/about.html index 6184755..92bb7fe 100644 --- a/templates/about.html +++ b/templates/about.html @@ -10,7 +10,7 @@

Languages: German, English

Programming languages: Python, Bash, POSIX Shell, Powershell

Markup languages: HTML, MD

-

Structure languages: JSON, XML, YAML, TOML

+

Structure languages: JSON, XML, YAML, TOML, Jinja

Query languages: SQL(MariaDB, SQLite3)

Services managed: SSH, DNS, DHCP, AD, PF, UFW, NF-Tables, RDP(XRDP, Microsoft RDP), Webserver(Apache24, Nginx, OpenBSD-httpd, From 341b725d5f054e0fc08729667d68f16a22a68901 Mon Sep 17 00:00:00 2001 From: ahoemann Date: Fri, 14 Mar 2025 17:19:35 +0100 Subject: [PATCH 13/39] remove: monitoring(replaced by statping-ng); fix: template naming --- Dockerfile | 2 -- app.py | 34 +++--------------------- templates/{about.html => about.j2} | 2 +- templates/{base.html => base.j2} | 0 templates/{homepage.html => homepage.j2} | 2 +- templates/{imprint.html => imprint.j2} | 2 +- templates/monitoring.html | 9 ------- 7 files changed, 6 insertions(+), 45 deletions(-) rename templates/{about.html => about.j2} (97%) rename templates/{base.html => base.j2} (100%) rename templates/{homepage.html => homepage.j2} (91%) rename templates/{imprint.html => imprint.j2} (91%) delete mode 100644 templates/monitoring.html diff --git a/Dockerfile b/Dockerfile index 1e8a9f6..96fc7ff 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,8 +1,6 @@ FROM alpine:latest WORKDIR /opt/ -ENV GIT_URL=https://git.adrianux.net -ENV WEBSITE_URL=https://adrianux.net ENV DEBUG_MODE=False COPY . . diff --git a/app.py b/app.py index 99b6757..e6f86b0 100755 --- a/app.py +++ b/app.py @@ -10,43 +10,15 @@ app = Flask(__name__) @app.route("/imprint") def root(): - return render_template("imprint.html") + return render_template("imprint.j2") @app.route("/about") def about(): - return render_template("about.html") + return render_template("about.j2") @app.route("/") def homepage(): - return render_template("homepage.html") - -@app.route("/monitoring") -def monitoring(): - global git_status - global website_status - executor = ThreadPoolExecutor(2) - executor.submit(monitor) - return render_template("monitoring.html", git_status = git_status, website_status = website_status) - - -def get_status(link): - requested_site = requests.get(link) - status_code = requested_site.status_code - try: - match status_code: - case 200: - return "ONLINE" - case _: - return "ERROR" - except: - return "OFFLINE" - -def monitor(): - while True: - git_status = get_status(os.environ['GIT_URL']) - website_status = get_status(os.environ['WEBSITE_URL']) - time.sleep(5) - + return render_template("homepage.j2") if __name__ == "__main__": diff --git a/templates/about.html b/templates/about.j2 similarity index 97% rename from templates/about.html rename to templates/about.j2 index 92bb7fe..0da40b0 100644 --- a/templates/about.html +++ b/templates/about.j2 @@ -1,4 +1,4 @@ -{% extends "base.html" %} +{% extends "base.j2" %} {% block title %}About{% endblock %} {% block head %} {{ super() }} diff --git a/templates/base.html b/templates/base.j2 similarity index 100% rename from templates/base.html rename to templates/base.j2 diff --git a/templates/homepage.html b/templates/homepage.j2 similarity index 91% rename from templates/homepage.html rename to templates/homepage.j2 index 72ce93c..493b71c 100644 --- a/templates/homepage.html +++ b/templates/homepage.j2 @@ -1,4 +1,4 @@ -{% extends "base.html" %} +{% extends "base.j2" %} {% block title %}Homepage{% endblock %} {% block head %} {{ super() }} diff --git a/templates/imprint.html b/templates/imprint.j2 similarity index 91% rename from templates/imprint.html rename to templates/imprint.j2 index 59c6e38..bdd4d3b 100644 --- a/templates/imprint.html +++ b/templates/imprint.j2 @@ -1,4 +1,4 @@ -{% extends "base.html" %} +{% extends "base.js" %} {% block title %}Imprint{% endblock %} {% block head %} {{ super() }} diff --git a/templates/monitoring.html b/templates/monitoring.html deleted file mode 100644 index c41ec0b..0000000 --- a/templates/monitoring.html +++ /dev/null @@ -1,9 +0,0 @@ -{% extends "base.html" %} -{% block title %}Monitoring{% endblock %} -{% block head %} - {{ super() }} -{% endblock %} -{% block content %} -

Git status: {{ git_status }}

-

Website status: {{ website_status }}

-{% endblock %} From cff6024fdeb1efa104ca183f91ebdca75dcc6a75 Mon Sep 17 00:00:00 2001 From: ahoemann Date: Fri, 14 Mar 2025 17:31:27 +0100 Subject: [PATCH 14/39] fix: typo in imprint template --- templates/imprint.j2 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/imprint.j2 b/templates/imprint.j2 index bdd4d3b..011a5f2 100644 --- a/templates/imprint.j2 +++ b/templates/imprint.j2 @@ -1,4 +1,4 @@ -{% extends "base.js" %} +{% extends "base.j2" %} {% block title %}Imprint{% endblock %} {% block head %} {{ super() }} From 70eb980887c70c30a58c95fb8000a5fbbd0af5b4 Mon Sep 17 00:00:00 2001 From: ahoemann Date: Thu, 20 Mar 2025 12:21:09 +0100 Subject: [PATCH 15/39] Update templates/base.j2 --- templates/base.j2 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/base.j2 b/templates/base.j2 index c0305b6..7b14633 100644 --- a/templates/base.j2 +++ b/templates/base.j2 @@ -14,7 +14,7 @@
  • Homepage
  • Imprint
  • About
  • -
  • Monitoring
  • +
  • Monitoring
  • Git
  • From d8c836d2120b64db85c6cb7a357a603c6081d036 Mon Sep 17 00:00:00 2001 From: ahoemann Date: Thu, 20 Mar 2025 14:12:23 +0100 Subject: [PATCH 16/39] feat: force light mode --- templates/base.j2 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/base.j2 b/templates/base.j2 index 7b14633..11e99ce 100644 --- a/templates/base.j2 +++ b/templates/base.j2 @@ -1,5 +1,5 @@ - + {% block head %} From 20b4a54a6770d1e3830c6437fa33b1df6f644be9 Mon Sep 17 00:00:00 2001 From: ahoemann Date: Thu, 20 Mar 2025 14:38:24 +0100 Subject: [PATCH 17/39] Update Jenkinsfile --- Jenkinsfile | 5 ----- 1 file changed, 5 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index ca3175a..17cb593 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -13,8 +13,6 @@ pipeline { } } stage('Build') { - steps { - script { docker.withRegistry('https://git.adrianux.net/ahoemann/') { /* Build the container image */ @@ -23,9 +21,6 @@ pipeline { /* Push the container to the custom Registry */ dockerImage.push() } - /* Remove docker image*/ - sh 'docker rmi -f adrianux:${env.BUILD_ID}' - } } } } From 4b5a9fc9c6c0b54892110244f8c60fcfb792bbd1 Mon Sep 17 00:00:00 2001 From: ahoemann Date: Thu, 20 Mar 2025 14:40:18 +0100 Subject: [PATCH 18/39] Update Jenkinsfile --- Jenkinsfile | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 17cb593..dcd0d42 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -13,15 +13,14 @@ pipeline { } } stage('Build') { - docker.withRegistry('https://git.adrianux.net/ahoemann/') { + docker.withRegistry('https://git.adrianux.net/ahoemann/') { /* Build the container image */ def dockerImage = docker.build("adrianux:${env.BUILD_ID}") /* Push the container to the custom Registry */ dockerImage.push() - } - } + } } } } \ No newline at end of file From 6750c1730678507bfa56dba33ad7d48d0ed43bcc Mon Sep 17 00:00:00 2001 From: ahoemann Date: Thu, 20 Mar 2025 14:41:11 +0100 Subject: [PATCH 19/39] Update Jenkinsfile --- Jenkinsfile | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index dcd0d42..97754e7 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -13,6 +13,7 @@ pipeline { } } stage('Build') { + steps { docker.withRegistry('https://git.adrianux.net/ahoemann/') { /* Build the container image */ @@ -20,7 +21,8 @@ pipeline { /* Push the container to the custom Registry */ dockerImage.push() - } + } + } } } } \ No newline at end of file From 77508a984ec23b9a87e5268d9d6cd7816c3bc5f9 Mon Sep 17 00:00:00 2001 From: ahoemann Date: Thu, 20 Mar 2025 18:08:08 +0100 Subject: [PATCH 20/39] feat: links defined by environment variables --- .dockerignore | 1 + .gitignore | 2 +- app.py | 2 +- docker-compose.yml | 4 ++-- templates/base.j2 | 4 ++-- 5 files changed, 7 insertions(+), 6 deletions(-) diff --git a/.dockerignore b/.dockerignore index 35f2d33..7dab203 100644 --- a/.dockerignore +++ b/.dockerignore @@ -2,5 +2,6 @@ compose.yml *.dockerfile .git* +Jenkinsfile LICENSE README.md diff --git a/.gitignore b/.gitignore index 32ac21b..e2efa92 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,3 @@ -.venv +.venv* .env __pycache__ diff --git a/app.py b/app.py index e6f86b0..bd477a3 100755 --- a/app.py +++ b/app.py @@ -18,7 +18,7 @@ def about(): @app.route("/") def homepage(): - return render_template("homepage.j2") + return render_template("homepage.j2", MONITORING_URL = os.environ['MONITORING_URL'], GIT_URL = os.environ['GIT_URL']) if __name__ == "__main__": diff --git a/docker-compose.yml b/docker-compose.yml index 731ba82..01e34a4 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -2,12 +2,12 @@ services: build: context: "." - dockerfile: "latest.dockerfile" + dockerfile: "Dockerfile" container_name: "adrianux" image: "adrianux:latest" environment: - "GIT_URL=http://git.adrianux.net" - - "WEBSITE_URL=http://adrianux.net" + - "MONITORING_URL=http://adrianux.net" - "DEBUG_MODE=False" ports: - "127.0.0.1:8080:8080" diff --git a/templates/base.j2 b/templates/base.j2 index 11e99ce..2ac8dd6 100644 --- a/templates/base.j2 +++ b/templates/base.j2 @@ -14,8 +14,8 @@
  • Homepage
  • Imprint
  • About
  • -
  • Monitoring
  • -
  • Git
  • +
  • Monitoring
  • +
  • Git
  • From d74916f2c79effca891e2b31905dd64ce72c3ab2 Mon Sep 17 00:00:00 2001 From: ahoemann Date: Thu, 20 Mar 2025 18:11:51 +0100 Subject: [PATCH 21/39] typo: Jinja -> Jinja2 --- templates/about.j2 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/about.j2 b/templates/about.j2 index 0da40b0..16e4c30 100644 --- a/templates/about.j2 +++ b/templates/about.j2 @@ -10,7 +10,7 @@

    Languages: German, English

    Programming languages: Python, Bash, POSIX Shell, Powershell

    Markup languages: HTML, MD

    -

    Structure languages: JSON, XML, YAML, TOML, Jinja

    +

    Structure languages: JSON, XML, YAML, TOML, Jinja2

    Query languages: SQL(MariaDB, SQLite3)

    Services managed: SSH, DNS, DHCP, AD, PF, UFW, NF-Tables, RDP(XRDP, Microsoft RDP), Webserver(Apache24, Nginx, OpenBSD-httpd, From 40306538ba89c6ee1a5544b9392917450cfa60f6 Mon Sep 17 00:00:00 2001 From: ahoemann Date: Fri, 21 Mar 2025 08:36:35 +0100 Subject: [PATCH 22/39] fix: remove url variables; docs: updated to current --- README.md | 20 ++++++++++++++++---- app.py | 7 +++---- docker-compose.yml | 5 +---- templates/base.j2 | 4 ++-- 4 files changed, 22 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index d8bec04..7cf7903 100644 --- a/README.md +++ b/README.md @@ -3,28 +3,41 @@ ## Setting up the environment 1. Create a virtual environment: + ```sh python3 -m venv .venv ``` 2. Activate the virtual environment: + ```sh . .venv/bin/activate ``` 3. Install dependencies: + ```sh pip install requirements.txt ``` 4. Set the environment variables: + ```sh -export GIT_URL=http://git.adrianux.net -export WEBSITE_URL=http://adrianux.net export DEBUGMODE=False ``` +Or source the .env file: + +```sh +cp .env.example .env # change the variables to suit your environment as needed +``` + +```sh +. .env +``` + 5. Run the app: + ```sh waitress-serve --listen=0.0.0.0:8080 app:app ``` @@ -34,10 +47,9 @@ waitress-serve --listen=0.0.0.0:8080 app:app ## Building the container ```sh -docker build -t adrianux:latest - < latest.dockerfile +docker build -t adrianux:latest . ``` - ## Running the container ```sh diff --git a/app.py b/app.py index bd477a3..5837049 100755 --- a/app.py +++ b/app.py @@ -1,9 +1,6 @@ #!/usr/bin/env python3 from flask import Flask, render_template, redirect, url_for -from concurrent.futures import ThreadPoolExecutor -import requests import os -import time app = Flask(__name__) @@ -18,10 +15,12 @@ def about(): @app.route("/") def homepage(): - return render_template("homepage.j2", MONITORING_URL = os.environ['MONITORING_URL'], GIT_URL = os.environ['GIT_URL']) + return render_template("homepage.j2") if __name__ == "__main__": + GIT_URL = os.environ['GIT_URL'] + MONITORING_URL = os.environ['MONITORING_URL'] app.run(debug=os.environ['DEBUG_MODE']) diff --git a/docker-compose.yml b/docker-compose.yml index 01e34a4..9241790 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -5,9 +5,6 @@ dockerfile: "Dockerfile" container_name: "adrianux" image: "adrianux:latest" - environment: - - "GIT_URL=http://git.adrianux.net" - - "MONITORING_URL=http://adrianux.net" - - "DEBUG_MODE=False" + env_file: .env ports: - "127.0.0.1:8080:8080" diff --git a/templates/base.j2 b/templates/base.j2 index 2ac8dd6..a043f1b 100644 --- a/templates/base.j2 +++ b/templates/base.j2 @@ -14,8 +14,8 @@

  • Homepage
  • Imprint
  • About
  • -
  • Monitoring
  • -
  • Git
  • +
  • Monitoring
  • +
  • Git
  • From 0fd8db97490b6f55b3a71b8880f531af7afa83de Mon Sep 17 00:00:00 2001 From: ahoemann Date: Thu, 27 Mar 2025 09:17:26 +0100 Subject: [PATCH 23/39] fix: site monitoring on homepage link --- app.py | 2 -- templates/homepage.j2 | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/app.py b/app.py index 5837049..c4d8872 100755 --- a/app.py +++ b/app.py @@ -19,8 +19,6 @@ def homepage(): if __name__ == "__main__": - GIT_URL = os.environ['GIT_URL'] - MONITORING_URL = os.environ['MONITORING_URL'] app.run(debug=os.environ['DEBUG_MODE']) diff --git a/templates/homepage.j2 b/templates/homepage.j2 index 493b71c..087b123 100644 --- a/templates/homepage.j2 +++ b/templates/homepage.j2 @@ -4,6 +4,6 @@ {{ super() }} {% endblock %} {% block content %} -

    This is Adrian's homepage, checkout his running services and their state here

    +

    This is Adrian's homepage, checkout his running services and their state here

    Yes, Adrian is refering to himself in the third person.

    {% endblock %} From 50552d72453ee2b5c9ef1b70f419652017f8e011 Mon Sep 17 00:00:00 2001 From: ahoemann Date: Thu, 27 Mar 2025 09:19:42 +0100 Subject: [PATCH 24/39] fix: link uri --- templates/homepage.j2 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/homepage.j2 b/templates/homepage.j2 index 087b123..c40b0eb 100644 --- a/templates/homepage.j2 +++ b/templates/homepage.j2 @@ -4,6 +4,6 @@ {{ super() }} {% endblock %} {% block content %} -

    This is Adrian's homepage, checkout his running services and their state here

    +

    This is Adrian's homepage, checkout his running services and their state here

    Yes, Adrian is refering to himself in the third person.

    {% endblock %} From f6db4212fd9fe26880e599ec80e7bb7b2eb76b27 Mon Sep 17 00:00:00 2001 From: ahoemann Date: Thu, 27 Mar 2025 12:16:32 +0100 Subject: [PATCH 25/39] change: to new build environment --- .dockerignore | 4 ++-- Dockerfile | 7 ++----- Jenkinsfile | 28 ---------------------------- 3 files changed, 4 insertions(+), 35 deletions(-) delete mode 100644 Jenkinsfile diff --git a/.dockerignore b/.dockerignore index 7dab203..ade01cc 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,6 +1,6 @@ .forgejo -compose.yml -*.dockerfile +*compose.yml +Dockerfile .git* Jenkinsfile LICENSE diff --git a/Dockerfile b/Dockerfile index 96fc7ff..951996a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,13 +5,10 @@ ENV DEBUG_MODE=False COPY . . -RUN apk add --no-cache git python3 -RUN python3 -m venv /opt/.venv -RUN /opt/.venv/bin/pip install --no-cache-dir -r requirements.txt -RUN apk del git +RUN apk add --no-cache python3 py3-flask py3-waitress EXPOSE 8080 HEALTHCHECK --interval=5m CMD wget --delete-after http://localhost:8080 -CMD [ "/opt/.venv/bin/waitress-serve", "--listen=0.0.0.0:8080", "app:app" ] +CMD [ "waitress-serve", "--listen=0.0.0.0:8080", "app:app" ] diff --git a/Jenkinsfile b/Jenkinsfile deleted file mode 100644 index 97754e7..0000000 --- a/Jenkinsfile +++ /dev/null @@ -1,28 +0,0 @@ -pipeline { - agent { dockerfile true } - stages { - stage('Pull Alpine Image') { - steps { - script { - // Pull the Alpine Docker image - - dockerImage = docker.image('alpine:latest') - - dockerImage.pull() - } - } - } - stage('Build') { - steps { - docker.withRegistry('https://git.adrianux.net/ahoemann/') { - - /* Build the container image */ - def dockerImage = docker.build("adrianux:${env.BUILD_ID}") - - /* Push the container to the custom Registry */ - dockerImage.push() - } - } - } - } -} \ No newline at end of file From 0704dc6ba38fcd4d31dda8ee0a1bbf9f0349db05 Mon Sep 17 00:00:00 2001 From: ahoemann Date: Thu, 27 Mar 2025 12:37:34 +0100 Subject: [PATCH 26/39] Add .forgejo/workflows/build-image.yml --- .forgejo/workflows/build-image.yml | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 .forgejo/workflows/build-image.yml diff --git a/.forgejo/workflows/build-image.yml b/.forgejo/workflows/build-image.yml new file mode 100644 index 0000000..42fd0e1 --- /dev/null +++ b/.forgejo/workflows/build-image.yml @@ -0,0 +1,4 @@ +on: [push] +jobs: + test: + runs-on: docker \ No newline at end of file From c2591e843230f38f4e1460198d39be80deb43e58 Mon Sep 17 00:00:00 2001 From: ahoemann Date: Thu, 27 Mar 2025 12:39:51 +0100 Subject: [PATCH 27/39] Update .forgejo/workflows/build-image.yml --- .forgejo/workflows/build-image.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.forgejo/workflows/build-image.yml b/.forgejo/workflows/build-image.yml index 42fd0e1..6cde0c4 100644 --- a/.forgejo/workflows/build-image.yml +++ b/.forgejo/workflows/build-image.yml @@ -1,4 +1,6 @@ on: [push] jobs: test: - runs-on: docker \ No newline at end of file + runs-on: docker + steps: + - run: docker build \ No newline at end of file From 44cd8886f79af360cc91de4111b3f3d9d0d737af Mon Sep 17 00:00:00 2001 From: ahoemann Date: Thu, 27 Mar 2025 12:41:19 +0100 Subject: [PATCH 28/39] Update .forgejo/workflows/build-image.yml --- .forgejo/workflows/build-image.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.forgejo/workflows/build-image.yml b/.forgejo/workflows/build-image.yml index 6cde0c4..9676dc4 100644 --- a/.forgejo/workflows/build-image.yml +++ b/.forgejo/workflows/build-image.yml @@ -1,6 +1,5 @@ on: [push] jobs: test: - runs-on: docker - steps: - - run: docker build \ No newline at end of file + runs-on: adrianux + \ No newline at end of file From 4dc4e78572f87c45196f433a22ec59cdb615bcdc Mon Sep 17 00:00:00 2001 From: ahoemann Date: Thu, 27 Mar 2025 12:41:46 +0100 Subject: [PATCH 29/39] Update .forgejo/workflows/build-image.yml --- .forgejo/workflows/build-image.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.forgejo/workflows/build-image.yml b/.forgejo/workflows/build-image.yml index 9676dc4..501d33b 100644 --- a/.forgejo/workflows/build-image.yml +++ b/.forgejo/workflows/build-image.yml @@ -2,4 +2,6 @@ on: [push] jobs: test: runs-on: adrianux + steps: + - run: docker build \ No newline at end of file From e3afb17d07d0f5e2701d26026b9dbc3ee67ec237 Mon Sep 17 00:00:00 2001 From: ahoemann Date: Thu, 27 Mar 2025 12:56:14 +0100 Subject: [PATCH 30/39] Update .forgejo/workflows/build-image.yml --- .forgejo/workflows/build-image.yml | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/.forgejo/workflows/build-image.yml b/.forgejo/workflows/build-image.yml index 501d33b..e69cb35 100644 --- a/.forgejo/workflows/build-image.yml +++ b/.forgejo/workflows/build-image.yml @@ -1,7 +1,13 @@ on: [push] jobs: - test: - runs-on: adrianux + build: + runs-on: docker steps: - - run: docker build - \ No newline at end of file + - name: Login to GitLab + uses: docker/login-action@v3 + with: + registry: git.adrianux.net/ahoemann/ + username: ${{ vars.FORGEJO_USERNAME }} + password: ${{ secrets.FORGEJO_PASSWORD }} + - run: git clone https://git.adrianux.net/ahoemann/Adrianux.net + - run: cd Adrianux.net docker build -t git.adrianux.net/ahoemann/adrianux:latest . \ No newline at end of file From 2186a11e4a06a72ea8e89154ac8a804d61fe6402 Mon Sep 17 00:00:00 2001 From: ahoemann Date: Thu, 27 Mar 2025 12:56:24 +0100 Subject: [PATCH 31/39] Update .forgejo/workflows/build-image.yml --- .forgejo/workflows/build-image.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.forgejo/workflows/build-image.yml b/.forgejo/workflows/build-image.yml index e69cb35..ee001fe 100644 --- a/.forgejo/workflows/build-image.yml +++ b/.forgejo/workflows/build-image.yml @@ -10,4 +10,4 @@ jobs: username: ${{ vars.FORGEJO_USERNAME }} password: ${{ secrets.FORGEJO_PASSWORD }} - run: git clone https://git.adrianux.net/ahoemann/Adrianux.net - - run: cd Adrianux.net docker build -t git.adrianux.net/ahoemann/adrianux:latest . \ No newline at end of file + - run: cd Adrianux.net && docker build -t git.adrianux.net/ahoemann/adrianux:latest . \ No newline at end of file From 7e5819f8b8075a9d16d0e42ee4fb317263d715a1 Mon Sep 17 00:00:00 2001 From: ahoemann Date: Fri, 28 Mar 2025 12:55:48 +0100 Subject: [PATCH 32/39] feat: added pytsebin link --- .env.example | 1 + templates/base.j2 | 1 + 2 files changed, 2 insertions(+) create mode 100644 .env.example diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..68a5b06 --- /dev/null +++ b/.env.example @@ -0,0 +1 @@ +DEBUG_MODE=False diff --git a/templates/base.j2 b/templates/base.j2 index a043f1b..af3d45f 100644 --- a/templates/base.j2 +++ b/templates/base.j2 @@ -16,6 +16,7 @@
  • About
  • Monitoring
  • Git
  • +
  • Bin
  • From a76cbd86f0e4774b3a22b23224b9e4287c932260 Mon Sep 17 00:00:00 2001 From: ahoemann Date: Fri, 28 Mar 2025 13:52:39 +0100 Subject: [PATCH 33/39] Update .forgejo/workflows/build-image.yml --- .forgejo/workflows/build-image.yml | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/.forgejo/workflows/build-image.yml b/.forgejo/workflows/build-image.yml index ee001fe..04aaf90 100644 --- a/.forgejo/workflows/build-image.yml +++ b/.forgejo/workflows/build-image.yml @@ -3,11 +3,17 @@ jobs: build: runs-on: docker steps: - - name: Login to GitLab + - name: Setup Docker Buildx + uses: docker/setup-buildx-action@v1 + - name: Login to Forgejo uses: docker/login-action@v3 with: registry: git.adrianux.net/ahoemann/ username: ${{ vars.FORGEJO_USERNAME }} password: ${{ secrets.FORGEJO_PASSWORD }} - - run: git clone https://git.adrianux.net/ahoemann/Adrianux.net - - run: cd Adrianux.net && docker build -t git.adrianux.net/ahoemann/adrianux:latest . \ No newline at end of file + - name: Build and Push + uses: docker/build-push-action@v6 + with: + push: true + tags: docker pull git.adrianux.net/ahoemann/adrianux.net:1.2.0 + file: Dockerfile \ No newline at end of file From 1236a024efccabc10d1b87542e6fe6b7811cbc32 Mon Sep 17 00:00:00 2001 From: ahoemann Date: Fri, 28 Mar 2025 13:54:29 +0100 Subject: [PATCH 34/39] Update .forgejo/workflows/build-image.yml --- .forgejo/workflows/build-image.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.forgejo/workflows/build-image.yml b/.forgejo/workflows/build-image.yml index 04aaf90..3d03516 100644 --- a/.forgejo/workflows/build-image.yml +++ b/.forgejo/workflows/build-image.yml @@ -3,6 +3,8 @@ jobs: build: runs-on: docker steps: + - name: Checkout the repo + uses: actions/checkout@v4 - name: Setup Docker Buildx uses: docker/setup-buildx-action@v1 - name: Login to Forgejo From 251b1c8a0b71380760b16bba57961d218d8cc776 Mon Sep 17 00:00:00 2001 From: ahoemann Date: Tue, 1 Apr 2025 15:02:01 +0200 Subject: [PATCH 35/39] Update templates/base.j2 --- templates/base.j2 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/base.j2 b/templates/base.j2 index af3d45f..e3f8a47 100644 --- a/templates/base.j2 +++ b/templates/base.j2 @@ -15,7 +15,7 @@
  • Imprint
  • About
  • Monitoring
  • -
  • Git
  • +
  • Git
  • Bin
  • From 1b5dd6e7d53e8c0efe50487db2228c602b0baa9a Mon Sep 17 00:00:00 2001 From: ahoemann Date: Thu, 3 Apr 2025 08:08:29 +0200 Subject: [PATCH 36/39] Delete .forgejo/workflows/build-image.yml --- .forgejo/workflows/build-image.yml | 21 --------------------- 1 file changed, 21 deletions(-) delete mode 100644 .forgejo/workflows/build-image.yml diff --git a/.forgejo/workflows/build-image.yml b/.forgejo/workflows/build-image.yml deleted file mode 100644 index 3d03516..0000000 --- a/.forgejo/workflows/build-image.yml +++ /dev/null @@ -1,21 +0,0 @@ -on: [push] -jobs: - build: - runs-on: docker - steps: - - name: Checkout the repo - uses: actions/checkout@v4 - - name: Setup Docker Buildx - uses: docker/setup-buildx-action@v1 - - name: Login to Forgejo - uses: docker/login-action@v3 - with: - registry: git.adrianux.net/ahoemann/ - username: ${{ vars.FORGEJO_USERNAME }} - password: ${{ secrets.FORGEJO_PASSWORD }} - - name: Build and Push - uses: docker/build-push-action@v6 - with: - push: true - tags: docker pull git.adrianux.net/ahoemann/adrianux.net:1.2.0 - file: Dockerfile \ No newline at end of file From 0ba3df677832eb354b43207d3d0eb757e589fbd6 Mon Sep 17 00:00:00 2001 From: ahoemann Date: Thu, 3 Apr 2025 08:12:26 +0200 Subject: [PATCH 37/39] fix: image registry --- docker-compose.yml | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 9241790..7107bd6 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,10 +1,7 @@ --- - services: - build: - context: "." - dockerfile: "Dockerfile" - container_name: "adrianux" - image: "adrianux:latest" - env_file: .env - ports: - - "127.0.0.1:8080:8080" +services: + container_name: "adrianux" + image: "git.adrianux.net/ahoemann/adrianux.net:1.2.0" + env_file: .env + ports: + - "127.0.0.1:8080:8080" From 4f882b8dad32fb9ce7b18c27a01aecb84a8bb1f4 Mon Sep 17 00:00:00 2001 From: ahoemann Date: Thu, 3 Apr 2025 07:22:10 +0000 Subject: [PATCH 38/39] add: theia-workspace to gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index e2efa92..03741ec 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ .venv* .env __pycache__ +*theia-workspace \ No newline at end of file From ec4edea53647fca5285e4a4cc867797c6d3fd4ff Mon Sep 17 00:00:00 2001 From: ahoemann Date: Thu, 3 Apr 2025 08:49:00 +0000 Subject: [PATCH 39/39] feat: removed old depedencies --- app.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/app.py b/app.py index c4d8872..aa9dfa6 100755 --- a/app.py +++ b/app.py @@ -1,5 +1,5 @@ #!/usr/bin/env python3 -from flask import Flask, render_template, redirect, url_for +from flask import Flask, render_template, url_for import os @@ -20,6 +20,3 @@ def homepage(): if __name__ == "__main__": app.run(debug=os.environ['DEBUG_MODE']) - - -