diff --git a/.dockerignore b/.dockerignore deleted file mode 100644 index ade01cc..0000000 --- a/.dockerignore +++ /dev/null @@ -1,7 +0,0 @@ -.forgejo -*compose.yml -Dockerfile -.git* -Jenkinsfile -LICENSE -README.md diff --git a/.env.example b/.env.example deleted file mode 100644 index 68a5b06..0000000 --- a/.env.example +++ /dev/null @@ -1 +0,0 @@ -DEBUG_MODE=False diff --git a/.forgejo/workflows/update.yaml b/.forgejo/workflows/update.yaml new file mode 100644 index 0000000..981d93d --- /dev/null +++ b/.forgejo/workflows/update.yaml @@ -0,0 +1,7 @@ +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 diff --git a/.gitignore b/.gitignore index 03741ec..033df5f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,2 @@ -.venv* -.env +.venv __pycache__ -*theia-workspace \ No newline at end of file diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index 951996a..0000000 --- a/Dockerfile +++ /dev/null @@ -1,14 +0,0 @@ -FROM alpine:latest -WORKDIR /opt/ - -ENV DEBUG_MODE=False - -COPY . . - -RUN apk add --no-cache python3 py3-flask py3-waitress - -EXPOSE 8080 - -HEALTHCHECK --interval=5m CMD wget --delete-after http://localhost:8080 - -CMD [ "waitress-serve", "--listen=0.0.0.0:8080", "app:app" ] diff --git a/README.md b/README.md index 7cf7903..a741db1 100644 --- a/README.md +++ b/README.md @@ -1,62 +1,37 @@ # Installation + ## Setting up the environment 1. Create a virtual environment: - -```sh +```bash python3 -m venv .venv ``` 2. Activate the virtual environment: - -```sh +```bash . .venv/bin/activate ``` 3. Install dependencies: - -```sh +```bash pip install requirements.txt ``` -4. Set the environment variables: +```systemd +# /etc/systemd/system/adrianux.service +[Unit] +Description=WSGI app +After=network.target -```sh -export DEBUGMODE=False +[Service] +Type=simple +User=adrianux +WorkingDirectory=/opt/Adrianux.net +ExecStart=/opt/Adrianux.net/.venv/bin/waitress-serve --listen=127.0.0.1:8080 app:app +Restart=always + +[Install] +WantedBy=multi-user.target ``` -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 -``` - -# Docker - -## Building the container - -```sh -docker build -t adrianux:latest . -``` - -## Running the container - -```sh -docker run adrianux:latest -``` -# Docker Compose - -```sh -docker compose up adrianux -``` diff --git a/app.py b/app.py index aa9dfa6..3aa37fb 100755 --- a/app.py +++ b/app.py @@ -1,22 +1,39 @@ #!/usr/bin/env python3 -from flask import Flask, render_template, url_for -import os - +from flask import Flask, render_template, redirect, url_for +import requests app = Flask(__name__) @app.route("/imprint") def root(): - return render_template("imprint.j2") + return render_template("imprint.html") @app.route("/about") def about(): - return render_template("about.j2") + return render_template("about.html") @app.route("/") def homepage(): - return render_template("homepage.j2") + return render_template("homepage.html") +@app.route("/monitoring") +def monitoring(): + git_status = get_status("https://git.adrianux.net") + website_status = get_status("https://adrianux.net") + 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): + match get_status_code(link): + case 200: + return "ONLINE" + case 500: + return "ERROR" + case _: + return "OFFLINE" if __name__ == "__main__": - app.run(debug=os.environ['DEBUG_MODE']) + app.run(debug=False) diff --git a/docker-compose.yml b/docker-compose.yml deleted file mode 100644 index 7107bd6..0000000 --- a/docker-compose.yml +++ /dev/null @@ -1,7 +0,0 @@ ---- -services: - container_name: "adrianux" - image: "git.adrianux.net/ahoemann/adrianux.net:1.2.0" - env_file: .env - ports: - - "127.0.0.1:8080:8080" diff --git a/templates/about.j2 b/templates/about.html similarity index 93% rename from templates/about.j2 rename to templates/about.html index 16e4c30..6184755 100644 --- a/templates/about.j2 +++ b/templates/about.html @@ -1,4 +1,4 @@ -{% extends "base.j2" %} +{% extends "base.html" %} {% block title %}About{% endblock %} {% block head %} {{ super() }} @@ -10,7 +10,7 @@

Languages: German, English

Programming languages: Python, Bash, POSIX Shell, Powershell

Markup languages: HTML, MD

-

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

+

Structure languages: JSON, XML, YAML, TOML

Query languages: SQL(MariaDB, SQLite3)

Services managed: SSH, DNS, DHCP, AD, PF, UFW, NF-Tables, RDP(XRDP, Microsoft RDP), Webserver(Apache24, Nginx, OpenBSD-httpd, diff --git a/templates/base.j2 b/templates/base.html similarity index 73% rename from templates/base.j2 rename to templates/base.html index e3f8a47..e406f79 100644 --- a/templates/base.j2 +++ b/templates/base.html @@ -1,5 +1,5 @@ - + {% block head %} @@ -14,9 +14,8 @@

  • Homepage
  • Imprint
  • About
  • -
  • Monitoring
  • -
  • Git
  • -
  • Bin
  • +
  • Monitoring
  • +
  • Git
  • @@ -26,8 +25,8 @@ diff --git a/templates/homepage.j2 b/templates/homepage.html similarity index 74% rename from templates/homepage.j2 rename to templates/homepage.html index c40b0eb..72ce93c 100644 --- a/templates/homepage.j2 +++ b/templates/homepage.html @@ -1,9 +1,9 @@ -{% extends "base.j2" %} +{% extends "base.html" %} {% block title %}Homepage{% endblock %} {% block head %} {{ 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 %} diff --git a/templates/imprint.j2 b/templates/imprint.html similarity index 91% rename from templates/imprint.j2 rename to templates/imprint.html index 011a5f2..59c6e38 100644 --- a/templates/imprint.j2 +++ b/templates/imprint.html @@ -1,4 +1,4 @@ -{% extends "base.j2" %} +{% extends "base.html" %} {% block title %}Imprint{% endblock %} {% block head %} {{ super() }} diff --git a/templates/monitoring.html b/templates/monitoring.html new file mode 100644 index 0000000..c41ec0b --- /dev/null +++ b/templates/monitoring.html @@ -0,0 +1,9 @@ +{% extends "base.html" %} +{% block title %}Monitoring{% endblock %} +{% block head %} + {{ super() }} +{% endblock %} +{% block content %} +

    Git status: {{ git_status }}

    +

    Website status: {{ website_status }}

    +{% endblock %}