diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 00000000..d51ed1ec --- /dev/null +++ b/.dockerignore @@ -0,0 +1,10 @@ +# Git +.git +.gitignore + +# GitHub actions +.github/ + +# Documentation +LICENSE +README.md diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 00000000..f51aac16 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,32 @@ +version: 2 +updates: + # Enable version updates for Python/pip + - package-ecosystem: "pip" + directory: "/" + schedule: + interval: "weekly" + open-pull-requests-limit: 10 + # Apply specific labels to pull requests + labels: + - "dependencies" + - "python" + + # Enable version updates for Docker + - package-ecosystem: "docker" + directory: "/" + schedule: + interval: "weekly" + open-pull-requests-limit: 10 + labels: + - "dependencies" + - "docker" + + # Keep GitHub Actions up to date + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "weekly" + open-pull-requests-limit: 10 + labels: + - "dependencies" + - "github-actions" \ No newline at end of file diff --git a/.github/workflows/auto-merge-dependabot.yml b/.github/workflows/auto-merge-dependabot.yml new file mode 100644 index 00000000..93d9ee11 --- /dev/null +++ b/.github/workflows/auto-merge-dependabot.yml @@ -0,0 +1,30 @@ +name: Auto-merge Dependabot PRs + +on: + pull_request_target: + branches: [ master ] + types: [opened, synchronize] + +jobs: + auto-merge: + runs-on: ubuntu-latest + if: github.actor == 'dependabot[bot]' + permissions: + pull-requests: write + contents: write + steps: + - name: Checkout code + uses: actions/checkout@v6 + + - name: Dependabot metadata + id: metadata + uses: dependabot/fetch-metadata@v3 + with: + github-token: "${{ secrets.GITHUB_TOKEN }}" + + - name: Auto-merge minor and patch updates + if: steps.metadata.outputs.update-type == 'version-update:semver-minor' || steps.metadata.outputs.update-type == 'version-update:semver-patch' + run: gh pr merge --auto --merge "$PR_URL" + env: + PR_URL: ${{github.event.pull_request.html_url}} + GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} \ No newline at end of file diff --git a/.github/workflows/build-docker-image.yml b/.github/workflows/build-docker-image.yml new file mode 100644 index 00000000..31c9110b --- /dev/null +++ b/.github/workflows/build-docker-image.yml @@ -0,0 +1,37 @@ +name: Build and Push Docker Image + +on: + push: + branches: [ master ] + +jobs: + build-and-push: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v6 + + - name: Set up QEMU + uses: docker/setup-qemu-action@v4 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v4 + + - name: Login to DockerHub + uses: docker/login-action@v4 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Build and push Docker image + uses: docker/build-push-action@v7 + with: + push: true + context: . + platforms: linux/amd64,linux/arm64 + tags: | + lvthillo/python-flask-docker:latest + lvthillo/python-flask-docker:${{ github.sha }} + cache-from: type=gha + cache-to: type=gha,mode=max \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 56ca36f6..00627b0d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM python:3.11-alpine +FROM python:3.14-alpine LABEL maintainer="lorenz.vanthillo@gmail.com" COPY . /app WORKDIR /app diff --git a/requirements.txt b/requirements.txt index 19acec61..79d75936 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1 +1 @@ -flask==2.3.2 \ No newline at end of file +flask==3.1.3 \ No newline at end of file diff --git a/src/app.py b/src/app.py index 12cd6ba5..c59abfc5 100644 --- a/src/app.py +++ b/src/app.py @@ -1,17 +1,18 @@ -from flask import Flask,render_template +from flask import Flask, render_template import socket app = Flask(__name__) + @app.route("/") def index(): try: host_name = socket.gethostname() host_ip = socket.gethostbyname(host_name) - return render_template('index.html', hostname=host_name, ip=host_ip) + return render_template("index.html", hostname=host_name, ip=host_ip) except: - return render_template('error.html') + return render_template("error.html") if __name__ == "__main__": - app.run(host='0.0.0.0', port=8080) + app.run(host="0.0.0.0", port=8080)