From ec5d88f295ee9180f5d1726f7919139dedf70adf Mon Sep 17 00:00:00 2001
From: jiriks74 <jiri@stefka.eu>
Date: Thu, 18 Jan 2024 15:01:25 +0100
Subject: [PATCH 01/17] fix(bz2-php): Missing PHP bz2 module in upstream image
 fixes `This instance is missing some recommended PHP modules. For improved
 performance and better compatibility it is highly recommended to install
 them: bz2`

---
 Dockerfile | 3 ++-
 README.md  | 1 +
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/Dockerfile b/Dockerfile
index e3b50ac..20d9ee6 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -1,5 +1,6 @@
 FROM nextcloud:28.0.1
 LABEL maintainer="Jiří Štefka <jiri@stefka.eu>"
 
-RUN apt update && apt upgrade -y --no-install-recommends && apt install ffmpeg aria2 youtube-dl libmagickcore-dev -y --no-install-recommends
+RUN apt update && apt upgrade -y --no-install-recommends && apt install ffmpeg aria2 youtube-dl libmagickcore-dev libbz2-dev -y --no-install-recommends
+RUN docker-php-ext-install bz2
 RUN apt clean && rm -rf /var/lib/apt/lists/*
diff --git a/README.md b/README.md
index 0088823..3cb71e9 100644
--- a/README.md
+++ b/README.md
@@ -14,6 +14,7 @@ Nextcloud's docker image with extra utilities
 - `ffmpeg` - Used by [Video converter](https://github.com/PaulLereverend/NextcloudVideo_Converter) app
 - `aria2` and `youtube-dl` - Used by [NCDownloader](https://github.com/shiningw/ncdownloader) app
 - `libmagickcore-dev` - To fix `Module php-imagick in this instance has no SVG support` error
+- `libbz2-dev` PHP module - To fix `This instance is missing some recommended PHP modules. For improved performance and better compatibility it is highly recommended to install them: bz2`
 
 ## Tips
 

From a19597d4ec057c0e67536bee29972c222c4261e6 Mon Sep 17 00:00:00 2001
From: jiriks74 <jiri@stefka.eu>
Date: Wed, 28 Feb 2024 19:00:33 +0100
Subject: [PATCH 02/17] fix: Remove unneeded dependency bz2

---
 Dockerfile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Dockerfile b/Dockerfile
index 20d9ee6..761f5f0 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -1,6 +1,6 @@
 FROM nextcloud:28.0.1
 LABEL maintainer="Jiří Štefka <jiri@stefka.eu>"
 
-RUN apt update && apt upgrade -y --no-install-recommends && apt install ffmpeg aria2 youtube-dl libmagickcore-dev libbz2-dev -y --no-install-recommends
+RUN apt update && apt upgrade -y --no-install-recommends && apt install ffmpeg aria2 youtube-dl libmagickcore-dev -y --no-install-recommends
 RUN docker-php-ext-install bz2
 RUN apt clean && rm -rf /var/lib/apt/lists/*

From eb9f2f5c8b9e495a6198db65dbda6b03cb2356d6 Mon Sep 17 00:00:00 2001
From: jiriks74 <jiri@stefka.eu>
Date: Wed, 28 Feb 2024 19:01:24 +0100
Subject: [PATCH 03/17] chore: Update to 28.0.2

---
 Dockerfile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Dockerfile b/Dockerfile
index 761f5f0..8ec887d 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -1,4 +1,4 @@
-FROM nextcloud:28.0.1
+FROM nextcloud:28.0.2
 LABEL maintainer="Jiří Štefka <jiri@stefka.eu>"
 
 RUN apt update && apt upgrade -y --no-install-recommends && apt install ffmpeg aria2 youtube-dl libmagickcore-dev -y --no-install-recommends

From 813cbf46ff69c20f5e44448f1c2f701fb96f6caa Mon Sep 17 00:00:00 2001
From: jiriks74 <jiri@stefka.eu>
Date: Wed, 28 Feb 2024 19:22:53 +0100
Subject: [PATCH 04/17] fix: Remove youtube-dl as it currently breaks build
 Once I figure out how to do to deal with it I'll add it back

---
 Dockerfile | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/Dockerfile b/Dockerfile
index 8ec887d..319ae58 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -1,6 +1,7 @@
 FROM nextcloud:28.0.2
 LABEL maintainer="Jiří Štefka <jiri@stefka.eu>"
 
-RUN apt update && apt upgrade -y --no-install-recommends && apt install ffmpeg aria2 youtube-dl libmagickcore-dev -y --no-install-recommends
+# RUN apt update && apt upgrade -y --no-install-recommends && apt install ffmpeg aria2 youtube-dl libmagickcore-dev -y --no-install-recommends
+RUN apt update && apt upgrade -y --no-install-recommends && apt install ffmpeg aria2 libmagickcore-dev -y --no-install-recommends
 RUN docker-php-ext-install bz2
 RUN apt clean && rm -rf /var/lib/apt/lists/*

From 7d43abc9132b89016b1eb9b02641add87ee6f147 Mon Sep 17 00:00:00 2001
From: jiriks74 <jiri@stefka.eu>
Date: Fri, 1 Mar 2024 10:59:44 +0100
Subject: [PATCH 05/17] feat: Add gnupg2 for encryption support in SnappyMail

---
 Dockerfile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Dockerfile b/Dockerfile
index 319ae58..ff6911b 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -2,6 +2,6 @@ FROM nextcloud:28.0.2
 LABEL maintainer="Jiří Štefka <jiri@stefka.eu>"
 
 # RUN apt update && apt upgrade -y --no-install-recommends && apt install ffmpeg aria2 youtube-dl libmagickcore-dev -y --no-install-recommends
-RUN apt update && apt upgrade -y --no-install-recommends && apt install ffmpeg aria2 libmagickcore-dev -y --no-install-recommends
+RUN apt update && apt upgrade -y --no-install-recommends && apt install gnupg2 ffmpeg aria2 libmagickcore-dev -y --no-install-recommends
 RUN docker-php-ext-install bz2
 RUN apt clean && rm -rf /var/lib/apt/lists/*

From af2397d6373d7ef83956ee23d172341d516405cb Mon Sep 17 00:00:00 2001
From: jiriks74 <jiri@stefka.eu>
Date: Tue, 5 Mar 2024 23:22:36 +0100
Subject: [PATCH 06/17] chore: update to v28.0.3

---
 Dockerfile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Dockerfile b/Dockerfile
index ff6911b..f1445f6 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -1,4 +1,4 @@
-FROM nextcloud:28.0.2
+FROM nextcloud:28.0.3
 LABEL maintainer="Jiří Štefka <jiri@stefka.eu>"
 
 # RUN apt update && apt upgrade -y --no-install-recommends && apt install ffmpeg aria2 youtube-dl libmagickcore-dev -y --no-install-recommends

From 4f74598419561c33d3274e1e2603c3f43ef26488 Mon Sep 17 00:00:00 2001
From: jiriks74 <jiri@stefka.eu>
Date: Tue, 2 Apr 2024 18:09:27 +0200
Subject: [PATCH 07/17] chore: Update to 28.0.4

---
 Dockerfile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Dockerfile b/Dockerfile
index f1445f6..3e98916 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -1,4 +1,4 @@
-FROM nextcloud:28.0.3
+FROM nextcloud:28.0.4
 LABEL maintainer="Jiří Štefka <jiri@stefka.eu>"
 
 # RUN apt update && apt upgrade -y --no-install-recommends && apt install ffmpeg aria2 youtube-dl libmagickcore-dev -y --no-install-recommends

From 4b986b40b525ea6f7b03f5f08bafda3c6167cea3 Mon Sep 17 00:00:00 2001
From: jiriks74 <jiri@stefka.eu>
Date: Fri, 19 Apr 2024 05:43:39 +0200
Subject: [PATCH 08/17] feat(ci/cd): Automatic builds based on latest image
 (#1)

Reviewed-on: https://gitea.stefka.eu/jiriks74/docker-nextcloud-extended/pulls/1
Co-authored-by: jiriks74 <jiri@stefka.eu>
Co-committed-by: jiriks74 <jiri@stefka.eu>
---
 .gitea/workflows/build.yml | 58 ++++++++++++++++++--------------------
 .gitignore                 |  5 ++++
 Dockerfile                 |  2 +-
 3 files changed, 34 insertions(+), 31 deletions(-)
 create mode 100644 .gitignore

diff --git a/.gitea/workflows/build.yml b/.gitea/workflows/build.yml
index bdfa286..e7f70e8 100644
--- a/.gitea/workflows/build.yml
+++ b/.gitea/workflows/build.yml
@@ -1,61 +1,59 @@
 name: Build
 
 on:
+  schedule:
+    - cron: "0 0 * * 1"
   push:
     tags:        
-      - 'v*'
+      - 'manual_build'
 
 jobs:
   build:
+    runs-on: ubuntu-latest
     steps:
-      - name: Checkout
-        uses: actions/checkout@v2
-
       - name: Extract Version Tag
         id: extract-version
-        run: echo "docker_tag=$(grep -oP '(?<=FROM nextcloud:)[0-9]+\.[0-9]+\.[0-9]+' Dockerfile)" >> $GITHUB_OUTPUT
-        shell: bash
-      
-      - name: Install Docker
         run: |
-          apt-get update
-          apt-get install docker.io -y
+          export DIGEST=$(curl -s "https://registry.hub.docker.com/v2/repositories/library/nextcloud/tags/?page_size=100" | jq -r '.results[] | select(.name=="latest") .digest')
+          export VERSION=$(curl -s "https://registry.hub.docker.com/v2/repositories/library/nextcloud/tags/?page_size=1000" | jq -r ".results[] | select(.name | test(\"^([0-9]+\\\.)+([0-9]+\\\.)+[0-9]+$\")) | select(.digest==\"$DIGEST\").name")
+          echo "Latest version: $VERSION"
+          echo "version=${VERSION}" >> $GITHUB_OUTPUT
+        shell: bash
+      - name: Check if the image was already built
+        id: check-build-status
+        run: |
+          if curl --silent -f -lSL "https://hub.docker.com/v2/repositories/jiriks74/nextcloud-extended/tags/$(echo ${{steps.extract-version.outputs.version}})" 2> /dev/null; then echo "Built already!" && exit 1; else echo "This version isn't built yet."; fi
+
+      - name: Update repositories
+        run: sudo apt update
+      - name: Install Docker
+        uses: awalsh128/cache-apt-pkgs-action@latest
+        with:
+          packages: docker.io
 
       - name: Login to DockerHub
-        uses: docker/login-action@v1
+        uses: docker/login-action@v3
         with:
           username: ${{ secrets.DOCKERHUB_USERNAME }}
           password: ${{ secrets.DOCKERHUB_TOKEN }}
 
       - name: Set up QEMU
-        uses: docker/setup-qemu-action@v2
+        uses: docker/setup-qemu-action@v3
       - name: Set up Docker Buildx
-        uses: docker/setup-buildx-action@v1
+        uses: docker/setup-buildx-action@v3
         with:
-          driver-opts: network=host
+          # driver-opts: network=host
           platforms: linux/amd64,linux/arm64
 
+      - name: Checkout
+        uses: actions/checkout@v4
+
       - name: Build image
         uses: docker/build-push-action@v2
         with:
           push: true
-          tags: jiriks74/nextcloud-extended:${{ steps.extract-version.outputs.docker_tag }},jiriks74/nextcloud-extended:latest
+          tags: jiriks74/nextcloud-extended:${{ steps.extract-version.outputs.version }},jiriks74/nextcloud-extended:latest
           platforms: linux/amd64,linux/arm64
           context: .
           file: ./Dockerfile
 
-      # - name: Build image
-      #   uses: docker/build-push-action@v2
-      #   with:
-      #     push: true
-      #     tags:
-      #       jiriks74/nextcloud-extended:latest
-      #     platforms: linux/amd64,linux/arm64
-      #     context: .
-      #     file: ./Dockerfile
-
-      # - name: Tag latest
-      #   run: |
-      #     docker image ls
-          # docker tag nextcloud-extended:${{ steps.extract-version.outputs.docker_tag }} nextcloud-extended:latest
-          # docker push nextcloud-extended:latest
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..d239eb6
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,5 @@
+# Direnv
+.direnv
+
+# ACT runner
+.env
diff --git a/Dockerfile b/Dockerfile
index 3e98916..c4570d1 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -1,4 +1,4 @@
-FROM nextcloud:28.0.4
+FROM nextcloud:latest
 LABEL maintainer="Jiří Štefka <jiri@stefka.eu>"
 
 # RUN apt update && apt upgrade -y --no-install-recommends && apt install ffmpeg aria2 youtube-dl libmagickcore-dev -y --no-install-recommends

From e85ce368728accc9029bf4ddb3ad617530331fdf Mon Sep 17 00:00:00 2001
From: jiriks74 <jiri@stefka.eu>
Date: Fri, 19 Apr 2024 05:47:23 +0200
Subject: [PATCH 09/17] feat(nix): Add basic Nix environment setup

---
 .envrc      |  1 +
 default.nix | 11 +++++++++++
 2 files changed, 12 insertions(+)
 create mode 100644 .envrc
 create mode 100644 default.nix

diff --git a/.envrc b/.envrc
new file mode 100644
index 0000000..1d953f4
--- /dev/null
+++ b/.envrc
@@ -0,0 +1 @@
+use nix
diff --git a/default.nix b/default.nix
new file mode 100644
index 0000000..5226177
--- /dev/null
+++ b/default.nix
@@ -0,0 +1,11 @@
+{ pkgs ? (import <nixpkgs> { 
+    config.allowUnfree = true;
+}),
+}:
+pkgs.mkShell {
+  pure = true;
+  packages = with pkgs; [
+    # Choose the build tools that you need
+    act
+  ];
+}

From 57630aff983e07799782f5f9731df55c0e86a90b Mon Sep 17 00:00:00 2001
From: jiriks74 <jiri@stefka.eu>
Date: Fri, 19 Apr 2024 12:41:15 +0200
Subject: [PATCH 10/17] fix(Dockerfile): Remove obsolete bz2 setup

---
 Dockerfile | 1 -
 1 file changed, 1 deletion(-)

diff --git a/Dockerfile b/Dockerfile
index c4570d1..2549cc1 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -3,5 +3,4 @@ LABEL maintainer="Jiří Štefka <jiri@stefka.eu>"
 
 # RUN apt update && apt upgrade -y --no-install-recommends && apt install ffmpeg aria2 youtube-dl libmagickcore-dev -y --no-install-recommends
 RUN apt update && apt upgrade -y --no-install-recommends && apt install gnupg2 ffmpeg aria2 libmagickcore-dev -y --no-install-recommends
-RUN docker-php-ext-install bz2
 RUN apt clean && rm -rf /var/lib/apt/lists/*

From 7fdf7d0f5cab5f99e0160ed06c7209caaaea506d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ji=C5=99=C3=AD=20=C5=A0tefka?= <jiri@stefka.eu>
Date: Fri, 19 Apr 2024 13:49:26 +0200
Subject: [PATCH 11/17] Update README.md

---
 README.md | 1 -
 1 file changed, 1 deletion(-)

diff --git a/README.md b/README.md
index 3cb71e9..0088823 100644
--- a/README.md
+++ b/README.md
@@ -14,7 +14,6 @@ Nextcloud's docker image with extra utilities
 - `ffmpeg` - Used by [Video converter](https://github.com/PaulLereverend/NextcloudVideo_Converter) app
 - `aria2` and `youtube-dl` - Used by [NCDownloader](https://github.com/shiningw/ncdownloader) app
 - `libmagickcore-dev` - To fix `Module php-imagick in this instance has no SVG support` error
-- `libbz2-dev` PHP module - To fix `This instance is missing some recommended PHP modules. For improved performance and better compatibility it is highly recommended to install them: bz2`
 
 ## Tips
 

From 7251cf6bf3f0e72c6cd68ee4d4cc543883500b4d Mon Sep 17 00:00:00 2001
From: jiriks74 <jiri@stefka.eu>
Date: Sun, 28 Apr 2024 00:36:47 +0200
Subject: [PATCH 12/17] feat(ci/cd): Add image based on stable tag

---
 .../workflows/{build.yml => build_latest.yml} |  2 +-
 .gitea/workflows/build_stable.yml             | 62 ++++++++++++++
 README.md                                     | 83 +++++++++++++++++--
 3 files changed, 141 insertions(+), 6 deletions(-)
 rename .gitea/workflows/{build.yml => build_latest.yml} (99%)
 create mode 100644 .gitea/workflows/build_stable.yml

diff --git a/.gitea/workflows/build.yml b/.gitea/workflows/build_latest.yml
similarity index 99%
rename from .gitea/workflows/build.yml
rename to .gitea/workflows/build_latest.yml
index e7f70e8..ac6d4a0 100644
--- a/.gitea/workflows/build.yml
+++ b/.gitea/workflows/build_latest.yml
@@ -8,7 +8,7 @@ on:
       - 'manual_build'
 
 jobs:
-  build:
+  build-latest:
     runs-on: ubuntu-latest
     steps:
       - name: Extract Version Tag
diff --git a/.gitea/workflows/build_stable.yml b/.gitea/workflows/build_stable.yml
new file mode 100644
index 0000000..806d289
--- /dev/null
+++ b/.gitea/workflows/build_stable.yml
@@ -0,0 +1,62 @@
+name: Build
+
+on:
+  schedule:
+    - cron: "0 0 * * 1"
+  push:
+    tags:        
+      - 'manual_build'
+
+jobs:
+  build-stable:
+    runs-on: ubuntu-latest
+    steps:
+      - name: Extract Version Tag
+        id: extract-version
+        run: |
+          export DIGEST=$(curl -s "https://registry.hub.docker.com/v2/repositories/library/nextcloud/tags/?page_size=100" | jq -r '.results[] | select(.name=="stable") .digest')
+          export VERSION=$(curl -s "https://registry.hub.docker.com/v2/repositories/library/nextcloud/tags/?page_size=1000" | jq -r ".results[] | select(.name | test(\"^([0-9]+\\\.)+[0-9]+$\")) | select(.digest==\"$DIGEST\").name")
+          export VERSION_MAJOR=$(curl -s "https://registry.hub.docker.com/v2/repositories/library/nextcloud/tags/?page_size=1000" | jq -r ".results[] | select(.name | test(\"^[0-9]{1,2}$\")) | select(.digest==\"$DIGEST\").name")
+          echo "Latest version: $VERSION"
+          echo "Major version: $VERSION_MAJOR"
+          echo "version=${VERSION}" >> $GITHUB_OUTPUT
+          echo "version-major=${VERSION_MAJOR}" >> $GITHUB_OUTPUT
+        shell: bash
+      - name: Check if the image was already built
+        id: check-build-status
+        run: |
+          if curl --silent -f -lSL "https://hub.docker.com/v2/repositories/jiriks74/nextcloud-extended/tags/$(echo ${{steps.extract-version.outputs.version}})" 2> /dev/null; then echo "Built already!" && exit 1; else echo "This version isn't built yet."; fi
+
+      - name: Update repositories
+        run: sudo apt update
+      - name: Install Docker
+        uses: awalsh128/cache-apt-pkgs-action@latest
+        with:
+          packages: docker.io
+
+      - name: Login to DockerHub
+        uses: docker/login-action@v3
+        with:
+          username: ${{ secrets.DOCKERHUB_USERNAME }}
+          password: ${{ secrets.DOCKERHUB_TOKEN }}
+
+      - name: Set up QEMU
+        uses: docker/setup-qemu-action@v3
+      - name: Set up Docker Buildx
+        uses: docker/setup-buildx-action@v3
+        with:
+          # driver-opts: network=host
+          platforms: linux/amd64,linux/arm64
+
+      - name: Checkout
+        uses: actions/checkout@v4
+
+      - name: Build image
+        uses: docker/build-push-action@v2
+        with:
+          push: true
+          tags: jiriks74/nextcloud-extended:${{ steps.extract-version.outputs.version }},jiriks74/nextcloud-extended:${{ steps.extract-version.outputs.version-major }},jiriks74/nextcloud-extended:stable
+          platforms: linux/amd64,linux/arm64
+          context: .
+          file: ./Dockerfile
+
diff --git a/README.md b/README.md
index 0088823..062ebc5 100644
--- a/README.md
+++ b/README.md
@@ -4,19 +4,90 @@
 [![Docker Stars](https://img.shields.io/docker/stars/jiriks74/nextcloud-extended.svg?color=94398d&labelColor=555555&logoColor=ffffff&style=for-the-badge&label=stars&logo=docker)](https://hub.docker.com/r/jiriks74/nextcloud-extended)
 [![Docker Size](https://img.shields.io/docker/image-size/jiriks74/nextcloud-extended/latest.svg?color=94398d&labelColor=555555&logoColor=ffffff&style=for-the-badge&label=Size&logo=docker)](https://hub.docker.com/r/jiriks74/nextcloud-extended)
 
-
 Nextcloud's docker image with extra utilities
 
-## Image availabe on [DockerHub](https://hub.docker.com/repository/docker/jiriks74/nextcloud-extended/general)
+## This image is availabe on [DockerHub](https://hub.docker.com/repository/docker/jiriks74/nextcloud-extended/general)
 
 ## Utilities added
 
+- `gnupg2` - Used by [Snappymail](https://github.com/the-djmaze/snappymail) to encrypt and sign emails
 - `ffmpeg` - Used by [Video converter](https://github.com/PaulLereverend/NextcloudVideo_Converter) app
 - `aria2` and `youtube-dl` - Used by [NCDownloader](https://github.com/shiningw/ncdownloader) app
 - `libmagickcore-dev` - To fix `Module php-imagick in this instance has no SVG support` error
 
-## Tips
+## Setup
 
+I recommend using `docker compose` to set up Nextcloud as it's easier to manage than palin Docker.
+
+<details>
+<summary>Basic <code>docker-compose.yml</code></summary>
+
+> [!Important]
+> 
+> Don't forget to change the passwords (similar to `<password>`) and if you'd like to change the database name and user too.
+
+```yml
+services:
+  db:
+    image: mariadb
+    restart: always
+    command: --transaction-isolation=READ-COMMITTED --binlog-format=ROW
+    volumes:
+      - ./db:/var/lib/mysql
+    environment:
+      - MYSQL_ROOT_PASSWORD=<db_root_password>
+      - MYSQL_PASSWORD=<db_password>
+      - MYSQL_DATABASE=nextcloud
+      - MYSQL_USER=nextcloud
+    healthcheck:
+      test: mariadb-admin ping -h 127.0.0.1 -u $$MYSQL_USER --password=$$MYSQL_PASSWORD
+      start_period: 5s
+      interval: 5s
+      timeout: 5s
+      retries: 55
+
+  app:
+    image: jiriks74/nextcloud-extended:stable
+    restart: always
+    ports:
+      - 80:80
+    links:
+      - db
+      - redis
+    depends_on:
+      redis:
+        condition: service_healthy
+      db:
+        condition: service_healthy
+    volumes:
+      - ./nextcloud:/var/www/html
+      - ./data:/var/www/html/data
+    environment:
+      - MYSQL_PASSWORD=<db_password>
+      - MYSQL_DATABASE=nextcloud
+      - MYSQL_USER=nextcloud
+      - MYSQL_HOST=db
+      - REDIS_HOST=redis
+      - REDIS_HOST_PASSWORD=<redis_password>
+    healthcheck:
+      test: curl -sSf 'http://localhost/status.php' | grep '"installed":true' | grep '"maintenance":false' | grep '"needsDbUpgrade":false' || exit 1
+      interval: 10s
+      timeout: 5s
+      retries: 10
+
+  redis:
+    image: redis
+    restart: always
+    command: redis-server --requirepass <redis_password>
+    volumes:
+      - ./redis:/data
+    healthcheck:
+      test: [ "CMD", "redis-cli", "--raw", "incr", "ping" ]
+```
+
+</details>
+
+## Tips
 ### Cron job
 
 If you're getting error simmilar to `Last job execution ran a day ago. Something seems wrong.`
@@ -26,5 +97,7 @@ try to add this to your cron tab (`sudo crontab -e`):
 0,5,10,15,20,25,30,35,40,45,50,55 * * * * docker exec -u www-data <container_name> php -f /var/www/html/cron.php
 ```
 
-- *Of course don't forget to change the `<container_name>` to your nextcloud's container name
-(eg. `docker-nextcloud_app`)*
+> [!Important]
+> 
+> *Don't forget to change the `<container_name>` to your Nextcloud's container name
+> (eg. `docker-nextcloud_app`)*

From 0c5862b32fc609d41303acb263e2df3961648b43 Mon Sep 17 00:00:00 2001
From: jiriks74 <jiri@stefka.eu>
Date: Sun, 28 Apr 2024 02:10:56 +0200
Subject: [PATCH 13/17] feat(README): Add Gitea badges

---
 README.md | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/README.md b/README.md
index 062ebc5..c0c923e 100644
--- a/README.md
+++ b/README.md
@@ -1,5 +1,9 @@
 # docker-nextcloud-extended
 
+![Open issues](https://img.shields.io/gitea/issues/open-raw/jiriks74/docker-nextcloud-extended?gitea_url=https%3A%2F%2Fgitea.stefka.eu%2F&label=Open%20issues%3A)
+![Closed issues](https://img.shields.io/gitea/issues/closed-raw/jiriks74/docker-nextcloud-extended?gitea_url=https%3A%2F%2Fgitea.stefka.eu%2F&label=Closed%20issues%3A)
+![Last Commit](https://img.shields.io/gitea/last-commit/jiriks74/docker-nextcloud-extended?gitea_url=https%3A%2F%2Fgitea.stefka.eu%2F)
+
 [![Docker Pulls](https://img.shields.io/docker/pulls/jiriks74/nextcloud-extended.svg?color=94398d&labelColor=555555&logoColor=ffffff&style=for-the-badge&label=pulls&logo=docker)](https://hub.docker.com/r/jiriks74/nextcloud-extended)
 [![Docker Stars](https://img.shields.io/docker/stars/jiriks74/nextcloud-extended.svg?color=94398d&labelColor=555555&logoColor=ffffff&style=for-the-badge&label=stars&logo=docker)](https://hub.docker.com/r/jiriks74/nextcloud-extended)
 [![Docker Size](https://img.shields.io/docker/image-size/jiriks74/nextcloud-extended/latest.svg?color=94398d&labelColor=555555&logoColor=ffffff&style=for-the-badge&label=Size&logo=docker)](https://hub.docker.com/r/jiriks74/nextcloud-extended)

From d02997b086d2e95e98277ef262e4bb903ab02d2a Mon Sep 17 00:00:00 2001
From: jiriks74 <jiri@stefka.eu>
Date: Sun, 28 Apr 2024 02:40:51 +0200
Subject: [PATCH 14/17] fix(Dockerfile): Remove useless comment

---
 Dockerfile | 1 -
 1 file changed, 1 deletion(-)

diff --git a/Dockerfile b/Dockerfile
index 2549cc1..b62d671 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -1,6 +1,5 @@
 FROM nextcloud:latest
 LABEL maintainer="Jiří Štefka <jiri@stefka.eu>"
 
-# RUN apt update && apt upgrade -y --no-install-recommends && apt install ffmpeg aria2 youtube-dl libmagickcore-dev -y --no-install-recommends
 RUN apt update && apt upgrade -y --no-install-recommends && apt install gnupg2 ffmpeg aria2 libmagickcore-dev -y --no-install-recommends
 RUN apt clean && rm -rf /var/lib/apt/lists/*

From 37c52c6887d818ab7dfd3724cdbfa70a9b79503a Mon Sep 17 00:00:00 2001
From: jiriks74 <jiri@stefka.eu>
Date: Sun, 28 Apr 2024 04:10:19 +0200
Subject: [PATCH 15/17] feat: Update images weekly to receive apt update
 Receive updates from apt so that there is no need to rebuild the image to
 receive security updates.

Better safe than sorry.
---
 .gitea/workflows/build_latest.yml |  8 ++++----
 .gitea/workflows/build_stable.yml |  8 ++++----
 README.md                         | 12 ++++++++++++
 3 files changed, 20 insertions(+), 8 deletions(-)

diff --git a/.gitea/workflows/build_latest.yml b/.gitea/workflows/build_latest.yml
index ac6d4a0..8e0d7be 100644
--- a/.gitea/workflows/build_latest.yml
+++ b/.gitea/workflows/build_latest.yml
@@ -19,10 +19,10 @@ jobs:
           echo "Latest version: $VERSION"
           echo "version=${VERSION}" >> $GITHUB_OUTPUT
         shell: bash
-      - name: Check if the image was already built
-        id: check-build-status
-        run: |
-          if curl --silent -f -lSL "https://hub.docker.com/v2/repositories/jiriks74/nextcloud-extended/tags/$(echo ${{steps.extract-version.outputs.version}})" 2> /dev/null; then echo "Built already!" && exit 1; else echo "This version isn't built yet."; fi
+      # - name: Check if the image was already built
+      #   id: check-build-status
+      #   run: |
+      #     if curl --silent -f -lSL "https://hub.docker.com/v2/repositories/jiriks74/nextcloud-extended/tags/$(echo ${{steps.extract-version.outputs.version}})" 2> /dev/null; then echo "Built already!" && exit 1; else echo "This version isn't built yet."; fi
 
       - name: Update repositories
         run: sudo apt update
diff --git a/.gitea/workflows/build_stable.yml b/.gitea/workflows/build_stable.yml
index 806d289..4befa62 100644
--- a/.gitea/workflows/build_stable.yml
+++ b/.gitea/workflows/build_stable.yml
@@ -22,10 +22,10 @@ jobs:
           echo "version=${VERSION}" >> $GITHUB_OUTPUT
           echo "version-major=${VERSION_MAJOR}" >> $GITHUB_OUTPUT
         shell: bash
-      - name: Check if the image was already built
-        id: check-build-status
-        run: |
-          if curl --silent -f -lSL "https://hub.docker.com/v2/repositories/jiriks74/nextcloud-extended/tags/$(echo ${{steps.extract-version.outputs.version}})" 2> /dev/null; then echo "Built already!" && exit 1; else echo "This version isn't built yet."; fi
+      # - name: Check if the image was already built
+      #   id: check-build-status
+      #   run: |
+      #     if curl --silent -f -lSL "https://hub.docker.com/v2/repositories/jiriks74/nextcloud-extended/tags/$(echo ${{steps.extract-version.outputs.version}})" 2> /dev/null; then echo "Built already!" && exit 1; else echo "This version isn't built yet."; fi
 
       - name: Update repositories
         run: sudo apt update
diff --git a/README.md b/README.md
index c0c923e..d520b75 100644
--- a/README.md
+++ b/README.md
@@ -10,6 +10,18 @@
 
 Nextcloud's docker image with extra utilities
 
+> [!Note]
+> The images with tags `latest` and `stable` are being rebuilt every week even if
+> there isn't a Nextcloud update to get security updates form `apt`.
+
+> [!Important]
+> I do not recommend automatically pulling the `latest` and `stable` tags as they track
+> upstream image and they can update you to the next major version without you intending to do so.
+>
+> If you'd like to receive the weekly updates tag your images with the major version like
+> `jiriks74/nextcloud-extended:28`. Keep in mind that these version tags are not automatically
+> updated when new major version is out for the `stable` tag upstream.
+
 ## This image is availabe on [DockerHub](https://hub.docker.com/repository/docker/jiriks74/nextcloud-extended/general)
 
 ## Utilities added

From f3ac33ae5f84c769aa37f7cd5f000ed46c28b1c3 Mon Sep 17 00:00:00 2001
From: jiriks74 <jiri@stefka.eu>
Date: Mon, 29 Apr 2024 02:58:38 +0200
Subject: [PATCH 16/17] fix(ci/cd): Stable imagage used latest as a base

---
 .gitea/workflows/build_latest.yml | 7 ++++---
 .gitea/workflows/build_stable.yml | 7 ++++---
 Dockerfile                        | 3 ++-
 3 files changed, 10 insertions(+), 7 deletions(-)

diff --git a/.gitea/workflows/build_latest.yml b/.gitea/workflows/build_latest.yml
index 8e0d7be..a1bf1f8 100644
--- a/.gitea/workflows/build_latest.yml
+++ b/.gitea/workflows/build_latest.yml
@@ -52,8 +52,9 @@ jobs:
         uses: docker/build-push-action@v2
         with:
           push: true
-          tags: jiriks74/nextcloud-extended:${{ steps.extract-version.outputs.version }},jiriks74/nextcloud-extended:latest
-          platforms: linux/amd64,linux/arm64
-          context: .
           file: ./Dockerfile
+          context: .
+          build-args: NEXTCLOUD_VERSION=${{ steps.extract-version.outputs.version }}
+          platforms: linux/amd64,linux/arm64
+          tags: jiriks74/nextcloud-extended:${{ steps.extract-version.outputs.version }},jiriks74/nextcloud-extended:latest
 
diff --git a/.gitea/workflows/build_stable.yml b/.gitea/workflows/build_stable.yml
index 4befa62..34318b5 100644
--- a/.gitea/workflows/build_stable.yml
+++ b/.gitea/workflows/build_stable.yml
@@ -55,8 +55,9 @@ jobs:
         uses: docker/build-push-action@v2
         with:
           push: true
-          tags: jiriks74/nextcloud-extended:${{ steps.extract-version.outputs.version }},jiriks74/nextcloud-extended:${{ steps.extract-version.outputs.version-major }},jiriks74/nextcloud-extended:stable
-          platforms: linux/amd64,linux/arm64
-          context: .
           file: ./Dockerfile
+          context: .
+          build-args: NEXTCLOUD_VERSION=${{ steps.extract-version.outputs.version }}
+          platforms: linux/amd64,linux/arm64
+          tags: jiriks74/nextcloud-extended:${{ steps.extract-version.outputs.version }},jiriks74/nextcloud-extended:${{ steps.extract-version.outputs.version-major }},jiriks74/nextcloud-extended:stable
 
diff --git a/Dockerfile b/Dockerfile
index b62d671..c4b3852 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -1,4 +1,5 @@
-FROM nextcloud:latest
+ARG NEXTCLOUD_VERSION
+FROM nextcloud:${NEXTCLOUD_VERSION}
 LABEL maintainer="Jiří Štefka <jiri@stefka.eu>"
 
 RUN apt update && apt upgrade -y --no-install-recommends && apt install gnupg2 ffmpeg aria2 libmagickcore-dev -y --no-install-recommends

From ee9813e4b54746a9289fb44499e2054057f19ce2 Mon Sep 17 00:00:00 2001
From: jiriks74 <jiri@stefka.eu>
Date: Thu, 9 May 2024 02:04:28 +0200
Subject: [PATCH 17/17] fix(stable): Extracted 2 version tags

The command extracted `28.0.5 28.0` instead of `28.0`.
Fixed to use `28.0.5` instead.
---
 .gitea/workflows/build_stable.yml | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/.gitea/workflows/build_stable.yml b/.gitea/workflows/build_stable.yml
index 34318b5..7b59013 100644
--- a/.gitea/workflows/build_stable.yml
+++ b/.gitea/workflows/build_stable.yml
@@ -15,12 +15,12 @@ jobs:
         id: extract-version
         run: |
           export DIGEST=$(curl -s "https://registry.hub.docker.com/v2/repositories/library/nextcloud/tags/?page_size=100" | jq -r '.results[] | select(.name=="stable") .digest')
-          export VERSION=$(curl -s "https://registry.hub.docker.com/v2/repositories/library/nextcloud/tags/?page_size=1000" | jq -r ".results[] | select(.name | test(\"^([0-9]+\\\.)+[0-9]+$\")) | select(.digest==\"$DIGEST\").name")
+          export VERSION=$(curl -s "https://registry.hub.docker.com/v2/repositories/library/nextcloud/tags/?page_size=1000" | jq -r '.results[] | select(.name | test("^[0-9]+\\.[0-9]+\\.[0-9]+$")) | select(.digest=="'$DIGEST'").name')
           export VERSION_MAJOR=$(curl -s "https://registry.hub.docker.com/v2/repositories/library/nextcloud/tags/?page_size=1000" | jq -r ".results[] | select(.name | test(\"^[0-9]{1,2}$\")) | select(.digest==\"$DIGEST\").name")
           echo "Latest version: $VERSION"
           echo "Major version: $VERSION_MAJOR"
           echo "version=${VERSION}" >> $GITHUB_OUTPUT
-          echo "version-major=${VERSION_MAJOR}" >> $GITHUB_OUTPUT
+          echo "version_major=${VERSION_MAJOR}" >> $GITHUB_OUTPUT
         shell: bash
       # - name: Check if the image was already built
       #   id: check-build-status
@@ -59,5 +59,5 @@ jobs:
           context: .
           build-args: NEXTCLOUD_VERSION=${{ steps.extract-version.outputs.version }}
           platforms: linux/amd64,linux/arm64
-          tags: jiriks74/nextcloud-extended:${{ steps.extract-version.outputs.version }},jiriks74/nextcloud-extended:${{ steps.extract-version.outputs.version-major }},jiriks74/nextcloud-extended:stable
+          tags: jiriks74/nextcloud-extended:${{ steps.extract-version.outputs.version }},jiriks74/nextcloud-extended:${{ steps.extract-version.outputs.version_major }},jiriks74/nextcloud-extended:stable