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/.gitea/workflows/build.yml b/.gitea/workflows/build.yml deleted file mode 100644 index bdfa286..0000000 --- a/.gitea/workflows/build.yml +++ /dev/null @@ -1,61 +0,0 @@ -name: Build - -on: - push: - tags: - - 'v*' - -jobs: - build: - 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 - - - name: Login to DockerHub - uses: docker/login-action@v1 - with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_TOKEN }} - - - name: Set up QEMU - uses: docker/setup-qemu-action@v2 - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v1 - with: - driver-opts: network=host - platforms: linux/amd64,linux/arm64 - - - 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 - 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/.gitea/workflows/build_latest.yml b/.gitea/workflows/build_latest.yml new file mode 100644 index 0000000..a1bf1f8 --- /dev/null +++ b/.gitea/workflows/build_latest.yml @@ -0,0 +1,60 @@ +name: Build + +on: + schedule: + - cron: "0 0 * * 1" + push: + tags: + - 'manual_build' + +jobs: + build-latest: + 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=="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@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 + 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 new file mode 100644 index 0000000..7b59013 --- /dev/null +++ b/.gitea/workflows/build_stable.yml @@ -0,0 +1,63 @@ +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]+\\.[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 + 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/.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 8ec887d..c4b3852 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,6 @@ -FROM nextcloud:28.0.2 +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 ffmpeg aria2 youtube-dl libmagickcore-dev -y --no-install-recommends -RUN docker-php-ext-install bz2 +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/* diff --git a/README.md b/README.md index 3cb71e9..d520b75 100644 --- a/README.md +++ b/README.md @@ -1,23 +1,109 @@ # docker-nextcloud-extended + + + + [](https://hub.docker.com/r/jiriks74/nextcloud-extended) [](https://hub.docker.com/r/jiriks74/nextcloud-extended) [](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) +> [!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 +- `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 -- `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` + +## 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.` @@ -27,5 +113,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`)* 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 + ]; +}