Compare commits
4 commits
Author | SHA1 | Date | |
---|---|---|---|
a2b99b2976 | |||
9f8f0c94ff | |||
b83a60f822 | |||
709b0fbe21 |
16 changed files with 116 additions and 104 deletions
|
@ -1,7 +0,0 @@
|
||||||
.forgejo
|
|
||||||
*compose.yml
|
|
||||||
Dockerfile
|
|
||||||
.git*
|
|
||||||
Jenkinsfile
|
|
||||||
LICENSE
|
|
||||||
README.md
|
|
|
@ -1 +0,0 @@
|
||||||
DEBUG_MODE=False
|
|
7
.forgejo/workflows/update.yaml
Normal file
7
.forgejo/workflows/update.yaml
Normal file
|
@ -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
|
4
.gitignore
vendored
4
.gitignore
vendored
|
@ -1,4 +1,2 @@
|
||||||
.venv*
|
.venv
|
||||||
.env
|
|
||||||
__pycache__
|
__pycache__
|
||||||
*theia-workspace
|
|
14
Containerfile
Normal file
14
Containerfile
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
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 go
|
||||||
|
COPY . .
|
||||||
|
RUN chmod +x website
|
||||||
|
|
||||||
|
EXPOSE 8080
|
||||||
|
|
||||||
|
CMD [ "/opt/./website" ]
|
14
Dockerfile
14
Dockerfile
|
@ -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" ]
|
|
46
README.md
46
README.md
|
@ -1,62 +1,32 @@
|
||||||
# Installation
|
# Installation
|
||||||
|
|
||||||
|
|
||||||
## Setting up the environment
|
## Setting up the environment
|
||||||
|
|
||||||
1. Create a virtual environment:
|
1. Create a virtual environment:
|
||||||
|
```bash
|
||||||
```sh
|
|
||||||
python3 -m venv .venv
|
python3 -m venv .venv
|
||||||
```
|
```
|
||||||
|
|
||||||
2. Activate the virtual environment:
|
2. Activate the virtual environment:
|
||||||
|
```bash
|
||||||
```sh
|
|
||||||
. .venv/bin/activate
|
. .venv/bin/activate
|
||||||
```
|
```
|
||||||
|
|
||||||
3. Install dependencies:
|
3. Install dependencies:
|
||||||
|
```bash
|
||||||
```sh
|
|
||||||
pip install requirements.txt
|
pip install requirements.txt
|
||||||
```
|
```
|
||||||
|
|
||||||
4. Set the environment variables:
|
|
||||||
|
|
||||||
```sh
|
|
||||||
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
|
|
||||||
```
|
|
||||||
|
|
||||||
# Docker
|
|
||||||
|
|
||||||
## Building the container
|
## Building the container
|
||||||
|
|
||||||
```sh
|
|
||||||
docker build -t adrianux:latest .
|
|
||||||
```
|
```
|
||||||
|
# <runtime> build -t adrianux:<tag> .
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
## Running the container
|
## Running the container
|
||||||
|
|
||||||
```sh
|
|
||||||
docker run adrianux:latest
|
|
||||||
```
|
```
|
||||||
# Docker Compose
|
# <runtime> run adrianux:<tag>
|
||||||
|
|
||||||
```sh
|
|
||||||
docker compose up adrianux
|
|
||||||
```
|
```
|
||||||
|
|
22
app.py
22
app.py
|
@ -1,22 +0,0 @@
|
||||||
#!/usr/bin/env python3
|
|
||||||
from flask import Flask, render_template, url_for
|
|
||||||
import os
|
|
||||||
|
|
||||||
|
|
||||||
app = Flask(__name__)
|
|
||||||
|
|
||||||
@app.route("/imprint")
|
|
||||||
def root():
|
|
||||||
return render_template("imprint.j2")
|
|
||||||
|
|
||||||
@app.route("/about")
|
|
||||||
def about():
|
|
||||||
return render_template("about.j2")
|
|
||||||
|
|
||||||
@app.route("/")
|
|
||||||
def homepage():
|
|
||||||
return render_template("homepage.j2")
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
app.run(debug=os.environ['DEBUG_MODE'])
|
|
|
@ -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"
|
|
|
@ -1,3 +0,0 @@
|
||||||
flask
|
|
||||||
waitress
|
|
||||||
requests
|
|
|
@ -1,4 +1,4 @@
|
||||||
{% extends "base.j2" %}
|
{% extends "base.html" %}
|
||||||
{% block title %}About{% endblock %}
|
{% block title %}About{% endblock %}
|
||||||
{% block head %}
|
{% block head %}
|
||||||
{{ super() }}
|
{{ super() }}
|
||||||
|
@ -10,7 +10,7 @@
|
||||||
<p>Languages: German, English</p>
|
<p>Languages: German, English</p>
|
||||||
<p>Programming languages: Python, Bash, POSIX Shell, Powershell</p>
|
<p>Programming languages: Python, Bash, POSIX Shell, Powershell</p>
|
||||||
<p>Markup languages: HTML, MD</p>
|
<p>Markup languages: HTML, MD</p>
|
||||||
<p>Structure languages: JSON, XML, YAML, TOML, Jinja2</p>
|
<p>Structure languages: JSON, XML, YAML, TOML</p>
|
||||||
<p>Query languages: SQL(MariaDB, SQLite3)</p>
|
<p>Query languages: SQL(MariaDB, SQLite3)</p>
|
||||||
<p>Services managed: SSH, DNS, DHCP, AD, PF, UFW, NF-Tables,
|
<p>Services managed: SSH, DNS, DHCP, AD, PF, UFW, NF-Tables,
|
||||||
RDP(XRDP, Microsoft RDP), Webserver(Apache24, Nginx, OpenBSD-httpd,
|
RDP(XRDP, Microsoft RDP), Webserver(Apache24, Nginx, OpenBSD-httpd,
|
|
@ -1,5 +1,5 @@
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="en" data-theme="light">
|
<html lang="en">
|
||||||
<head>
|
<head>
|
||||||
{% block head %}
|
{% block head %}
|
||||||
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
|
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
|
||||||
|
@ -14,9 +14,8 @@
|
||||||
<li><a href="/">Homepage</a></li>
|
<li><a href="/">Homepage</a></li>
|
||||||
<li><a href="imprint">Imprint</a></li>
|
<li><a href="imprint">Imprint</a></li>
|
||||||
<li><a href="about">About</a></li>
|
<li><a href="about">About</a></li>
|
||||||
<li><a href="https://cloud.adrianux.net">Monitoring</a></li>
|
<li><a href="monitoring">Monitoring</a></li>
|
||||||
<li><a href="https://git.adrianux.net/explore/repos">Git</a></li>
|
<li><a href="https://git.adrianux.net/ahoemann">Git</a></li>
|
||||||
<li><a href="https://bin.adrianux.net">Bin</a></li>
|
|
||||||
</ul>
|
</ul>
|
||||||
</nav>
|
</nav>
|
||||||
<body>
|
<body>
|
|
@ -1,9 +1,9 @@
|
||||||
{% extends "base.j2" %}
|
{% extends "base.html" %}
|
||||||
{% block title %}Homepage{% endblock %}
|
{% block title %}Homepage{% endblock %}
|
||||||
{% block head %}
|
{% block head %}
|
||||||
{{ super() }}
|
{{ super() }}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<p>This is Adrian's homepage, checkout his running services and their state <a href="https://cloud.adrianux.net">here</a></p>
|
<p>This is Adrian's homepage, checkout his running services and their state <a href="monitoring">here</a></p>
|
||||||
<p>Yes, Adrian is refering to himself in the third person.</p>
|
<p>Yes, Adrian is refering to himself in the third person.</p>
|
||||||
{% endblock %}
|
{% endblock %}
|
|
@ -1,4 +1,4 @@
|
||||||
{% extends "base.j2" %}
|
{% extends "base.html" %}
|
||||||
{% block title %}Imprint{% endblock %}
|
{% block title %}Imprint{% endblock %}
|
||||||
{% block head %}
|
{% block head %}
|
||||||
{{ super() }}
|
{{ super() }}
|
9
templates/monitoring.html
Normal file
9
templates/monitoring.html
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
{% extends "base.html" %}
|
||||||
|
{% block title %}Monitoring{% endblock %}
|
||||||
|
{% block head %}
|
||||||
|
{{ super() }}
|
||||||
|
{% endblock %}
|
||||||
|
{% block content %}
|
||||||
|
<p>Git status: {{ git_status }}</p>
|
||||||
|
<p>Website status: {{ website_status }}</p>
|
||||||
|
{% endblock %}
|
69
website.go
Executable file
69
website.go
Executable file
|
@ -0,0 +1,69 @@
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"net/http"
|
||||||
|
"os"
|
||||||
|
"html/template"
|
||||||
|
"log"
|
||||||
|
)
|
||||||
|
|
||||||
|
var templates = template.Must(template.ParseGlob("*.html"))
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
mode := os.Getenv("DEBUG_MODE")
|
||||||
|
if mode == "true" {
|
||||||
|
log.Println("Debug mode is on")
|
||||||
|
}
|
||||||
|
http.HandleFunc("/imprint", imprint)
|
||||||
|
http.HandleFunc("/about", about)
|
||||||
|
http.HandleFunc("/", homepage)
|
||||||
|
http.HandleFunc("/monitoring", monitoring)
|
||||||
|
log.Fatal(http.ListenAndServe(":8080", nil))
|
||||||
|
}
|
||||||
|
|
||||||
|
func imprint(w http.ResponseWriter, r *http.Request) {
|
||||||
|
renderTemplate(w, "imprint.html")
|
||||||
|
}
|
||||||
|
|
||||||
|
func about(w http.ResponseWriter, r *http.Request) {
|
||||||
|
renderTemplate(w, "about.html")
|
||||||
|
}
|
||||||
|
|
||||||
|
func homepage(w http.ResponseWriter, r *http.Request) {
|
||||||
|
renderTemplate(w, "homepage.html")
|
||||||
|
}
|
||||||
|
|
||||||
|
func monitoring(w http.ResponseWriter, r *http.Request) {
|
||||||
|
gitURL := os.Getenv("GIT_URL")
|
||||||
|
websiteURL := os.Getenv("WEBSITE_URL")
|
||||||
|
gitStatus := getStatus(gitURL)
|
||||||
|
websiteStatus := getStatus(websiteURL)
|
||||||
|
data := struct {
|
||||||
|
GitStatus string
|
||||||
|
WebsiteStatus string
|
||||||
|
}{
|
||||||
|
GitStatus: gitStatus,
|
||||||
|
WebsiteStatus: websiteStatus,
|
||||||
|
}
|
||||||
|
renderTemplate(w, "monitoring.html", data)
|
||||||
|
}
|
||||||
|
|
||||||
|
func renderTemplate(w http.ResponseWriter, tmpl string, data ...interface{}) {
|
||||||
|
err := templates.ExecuteTemplate(w, tmpl, data)
|
||||||
|
if err != nil {
|
||||||
|
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func getStatus(link string) string {
|
||||||
|
resp, err := http.Get(link)
|
||||||
|
if err != nil {
|
||||||
|
return "OFFLINE"
|
||||||
|
}
|
||||||
|
defer resp.Body.Close()
|
||||||
|
if resp.StatusCode == 200 {
|
||||||
|
return "ONLINE"
|
||||||
|
}
|
||||||
|
return "ERROR"
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue