diff --git a/.github/workflows/docker-hub.yml b/.github/workflows/docker-hub.yml index 5876474..c4bff9e 100644 --- a/.github/workflows/docker-hub.yml +++ b/.github/workflows/docker-hub.yml @@ -7,11 +7,13 @@ on: branches: - '**' pull_request: + workflow_dispatch: jobs: docker: runs-on: ubuntu-22.04 strategy: + fail-fast: false matrix: image: ['', v, fpm, fpm-alpine, fpm-alpine-nginx, fpm-alpine-nginx-composer, fpm-alpine-nginx-composer-supervisor] include: @@ -31,17 +33,17 @@ jobs: file: fpm-alpine-nginx-composer-supervisor.Dockerfile steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Define tag name id: tag-name run: | if [ "${GITHUB_REF}" == "refs/heads/master" -a "${GITHUB_EVENT_NAME}" != "pull_request" ]; then curl -s https://api.github.com/repos/akaunting/akaunting/releases/latest \ | jq -r .tag_name | sed \ - -e 's/^/::set-output name=tag::/' + -e 's/^/tag=/' >> "$GITHUB_OUTPUT" else - echo -n "::set-output name=tag::" - echo "$GITHUB_REF" | cut -d/ -f3- | tr '/' '_' + echo -n "tag=" >> "$GITHUB_OUTPUT" + echo "$GITHUB_REF" | cut -d/ -f3- | tr '/' '_' >> "$GITHUB_OUTPUT" fi - name: Define images tags id: image-tags @@ -51,38 +53,38 @@ jobs: echo ${{ steps.tag-name.outputs.tag }} | sed \ -e 's/\(\(\([0-9]\+\)\.[0-9]\+\)\.[0-9]\+\)/\1,\2,\3,/' \ -e 's/\([^,]\+\),/akaunting\/akaunting:\1,/g' \ - -e 's/^/::set-output name=tags::/' \ - -e 's/$/akaunting\/akaunting:latest/' + -e 's/^/tags=/' \ + -e 's/$/akaunting\/akaunting:latest/' >> "$GITHUB_OUTPUT" else echo ${{ steps.tag-name.outputs.tag }} | sed \ -e 's/\(\(\([0-9]\+\)\.[0-9]\+\)\.[0-9]\+\)/\1-${{ matrix.image }},\2-${{ matrix.image }},\3-${{ matrix.image }},/' \ -e 's/\([^,]\+\),/akaunting\/akaunting:\1,/g' \ - -e 's/^/::set-output name=tags::/' + -e 's/^/tags=/' >> "$GITHUB_OUTPUT" fi else if [ -z ${{ matrix.image }} ]; then - echo -n "::set-output name=tags::akaunting/akaunting:" - echo "$GITHUB_REF" | cut -d/ -f3- | tr '/' '_' + echo -n "tags=akaunting/akaunting:" >> "$GITHUB_OUTPUT" + echo "$GITHUB_REF" | cut -d/ -f3- | tr '/' '_' >> "$GITHUB_OUTPUT" else - echo -n "::set-output name=tags::akaunting/akaunting:" - echo "$(echo "$GITHUB_REF" | cut -d/ -f3- | tr '/' '_')-${{ matrix.image }}" + echo -n "tags=akaunting/akaunting:" >> "$GITHUB_OUTPUT" + echo "$(echo "$GITHUB_REF" | cut -d/ -f3- | tr '/' '_')-${{ matrix.image }}" >> "$GITHUB_OUTPUT" fi fi - name: Set up QEMU if: matrix.image == '' || matrix.image == 'v' || matrix.image == 'fpm' || matrix.image == 'fpm-alpine' || matrix.image == 'fpm-alpine-nginx' - uses: docker/setup-qemu-action@v2 + uses: docker/setup-qemu-action@v3 - name: Set up Docker Buildx if: matrix.image == '' || matrix.image == 'v' || matrix.image == 'fpm' || matrix.image == 'fpm-alpine' || matrix.image == 'fpm-alpine-nginx' - uses: docker/setup-buildx-action@v2 + uses: docker/setup-buildx-action@v3 - name: Login to DockerHub if: github.event_name != 'pull_request' - uses: docker/login-action@v1 + uses: docker/login-action@v3 with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} - name: Build and push images if: matrix.image == '' || matrix.image == 'v' || matrix.image == 'fpm' || matrix.image == 'fpm-alpine' || matrix.image == 'fpm-alpine-nginx' - uses: docker/build-push-action@v3 + uses: docker/build-push-action@v6 with: context: . file: ./${{ matrix.file }} @@ -91,7 +93,7 @@ jobs: tags: ${{ steps.image-tags.outputs.tags }} - name: Build and push images if: matrix.image == 'fpm-alpine-nginx-composer' || matrix.image == 'fpm-alpine-nginx-composer-supervisor' - uses: docker/build-push-action@v3 + uses: docker/build-push-action@v6 with: context: . file: ./${{ matrix.file }} diff --git a/Dockerfile b/Dockerfile index da86e7e..7454b05 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM php:8.1-apache +FROM php:8.2.35-apache ARG AKAUNTING_DOCKERFILE_VERSION=0.1 ARG SUPPORTED_LOCALES="en_US.UTF-8" diff --git a/README.md b/README.md index e291143..a85503a 100644 --- a/README.md +++ b/README.md @@ -53,6 +53,35 @@ SESSION_DRIVER: "redis" QUEUE_CONNECTION: "redis" ``` +## Upgrading + +The application files live in the `akaunting-data` volume, so pulling a newer image updates PHP and the system packages but **not** Akaunting itself. Upgrade Akaunting from inside the running container instead. + +> Akaunting 3.2 and later require PHP 8.2. Always switch to the new image **before** upgrading Akaunting. Upgrading Akaunting on an old PHP 8.1 image leaves the application unable to start. + +1. Back up your database: + + ```shell + docker exec akaunting-db sh -c 'exec mariadb-dump -u"$MYSQL_USER" -p"$MYSQL_PASSWORD" "$MYSQL_DATABASE"' > akaunting-backup.sql + ``` + +2. Pull the new image and recreate the container: + + ```shell + docker-compose pull + docker-compose up -d + ``` + +3. Upgrade Akaunting and its installed apps: + + ```shell + docker exec -u www-data akaunting php artisan update:all + ``` + + You can also do this step from **Settings > Updates** in the Akaunting web interface. + +Do not just copy the new files over the old ones and run `php artisan migrate`. Some versions also update existing data during the upgrade, and that step only runs through the updater. + ## Extra ways to explore containerized Akaunting! This repository contains extra compose and other files that allows you to run Akaunting in different setups like using FPM and NGINX and here is the most important commands that you may need: diff --git a/fpm-alpine-nginx-composer-supervisor.Dockerfile b/fpm-alpine-nginx-composer-supervisor.Dockerfile index 0d6b38a..07015b0 100644 --- a/fpm-alpine-nginx-composer-supervisor.Dockerfile +++ b/fpm-alpine-nginx-composer-supervisor.Dockerfile @@ -1,4 +1,4 @@ -FROM php:8.1-fpm-alpine3.15 +FROM php:8.2.35-fpm-alpine3.24 # Arguments defined in docker-compose.yml ARG AKAUNTING_DOCKERFILE_VERSION=0.1 @@ -6,8 +6,8 @@ ARG SUPPORTED_LOCALES="en_US.UTF-8" # Add Repositories RUN rm -f /etc/apk/repositories &&\ - echo "http://dl-cdn.alpinelinux.org/alpine/v3.15/main" >> /etc/apk/repositories && \ - echo "http://dl-cdn.alpinelinux.org/alpine/v3.15/community" >> /etc/apk/repositories + echo "http://dl-cdn.alpinelinux.org/alpine/v3.24/main" >> /etc/apk/repositories && \ + echo "http://dl-cdn.alpinelinux.org/alpine/v3.24/community" >> /etc/apk/repositories # Add Dependencies RUN apk add --update --no-cache \ @@ -18,11 +18,15 @@ RUN apk add --update --no-cache \ supervisor \ vim \ bash \ - nodejs \ - npm \ git \ nginx +# Add Node.js 20 (Akaunting requires node >=18 <21 and node-sass does not build on the Node.js 24 shipped by Alpine 3.24) +COPY --from=node:20.20.2-alpine3.23 /usr/local/bin/node /usr/local/bin/node +COPY --from=node:20.20.2-alpine3.23 /usr/local/lib/node_modules /usr/local/lib/node_modules +RUN ln -s ../lib/node_modules/npm/bin/npm-cli.js /usr/local/bin/npm \ + && ln -s ../lib/node_modules/npm/bin/npx-cli.js /usr/local/bin/npx + ADD https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions /usr/local/bin/ # Install PHP Extensions diff --git a/fpm-alpine-nginx-composer.Dockerfile b/fpm-alpine-nginx-composer.Dockerfile index e8462d5..a639b6d 100644 --- a/fpm-alpine-nginx-composer.Dockerfile +++ b/fpm-alpine-nginx-composer.Dockerfile @@ -1,4 +1,4 @@ -FROM php:8.1-fpm-alpine3.15 +FROM php:8.2.35-fpm-alpine3.24 # Arguments defined in docker-compose.yml ARG AKAUNTING_DOCKERFILE_VERSION=0.1 @@ -6,8 +6,8 @@ ARG SUPPORTED_LOCALES="en_US.UTF-8" # Add Repositories RUN rm -f /etc/apk/repositories &&\ - echo "http://dl-cdn.alpinelinux.org/alpine/v3.15/main" >> /etc/apk/repositories && \ - echo "http://dl-cdn.alpinelinux.org/alpine/v3.15/community" >> /etc/apk/repositories + echo "http://dl-cdn.alpinelinux.org/alpine/v3.24/main" >> /etc/apk/repositories && \ + echo "http://dl-cdn.alpinelinux.org/alpine/v3.24/community" >> /etc/apk/repositories # Add Dependencies RUN apk add --update --no-cache \ @@ -17,11 +17,15 @@ RUN apk add --update --no-cache \ python3 \ nano \ bash \ - nodejs \ - npm \ git \ nginx +# Add Node.js 20 (Akaunting requires node >=18 <21 and node-sass does not build on the Node.js 24 shipped by Alpine 3.24) +COPY --from=node:20.20.2-alpine3.23 /usr/local/bin/node /usr/local/bin/node +COPY --from=node:20.20.2-alpine3.23 /usr/local/lib/node_modules /usr/local/lib/node_modules +RUN ln -s ../lib/node_modules/npm/bin/npm-cli.js /usr/local/bin/npm \ + && ln -s ../lib/node_modules/npm/bin/npx-cli.js /usr/local/bin/npx + ADD https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions /usr/local/bin/ # Install PHP Extensions diff --git a/fpm-alpine-nginx.Dockerfile b/fpm-alpine-nginx.Dockerfile index cfd5b11..f76e1cc 100644 --- a/fpm-alpine-nginx.Dockerfile +++ b/fpm-alpine-nginx.Dockerfile @@ -1,4 +1,4 @@ -FROM php:8.1-fpm-alpine3.15 +FROM php:8.2.35-fpm-alpine3.24 # Arguments defined in docker-compose.yml ARG AKAUNTING_DOCKERFILE_VERSION=0.1 @@ -6,8 +6,8 @@ ARG SUPPORTED_LOCALES="en_US.UTF-8" # Add Repositories RUN rm -f /etc/apk/repositories &&\ - echo "http://dl-cdn.alpinelinux.org/alpine/v3.15/main" >> /etc/apk/repositories && \ - echo "http://dl-cdn.alpinelinux.org/alpine/v3.15/community" >> /etc/apk/repositories + echo "http://dl-cdn.alpinelinux.org/alpine/v3.24/main" >> /etc/apk/repositories && \ + echo "http://dl-cdn.alpinelinux.org/alpine/v3.24/community" >> /etc/apk/repositories # Add Dependencies RUN apk add --update --no-cache \ diff --git a/fpm-alpine.Dockerfile b/fpm-alpine.Dockerfile index 67dd88e..c854806 100644 --- a/fpm-alpine.Dockerfile +++ b/fpm-alpine.Dockerfile @@ -1,4 +1,4 @@ -FROM php:8.1-fpm-alpine3.15 +FROM php:8.2.35-fpm-alpine3.24 # Arguments defined in docker-compose.yml ARG AKAUNTING_DOCKERFILE_VERSION=0.1 @@ -6,8 +6,8 @@ ARG SUPPORTED_LOCALES="en_US.UTF-8" # Add Repositories RUN rm -f /etc/apk/repositories &&\ - echo "http://dl-cdn.alpinelinux.org/alpine/v3.15/main" >> /etc/apk/repositories && \ - echo "http://dl-cdn.alpinelinux.org/alpine/v3.15/community" >> /etc/apk/repositories + echo "http://dl-cdn.alpinelinux.org/alpine/v3.24/main" >> /etc/apk/repositories && \ + echo "http://dl-cdn.alpinelinux.org/alpine/v3.24/community" >> /etc/apk/repositories # Add Build Dependencies RUN apk add --no-cache --virtual .build-deps \ diff --git a/fpm.Dockerfile b/fpm.Dockerfile index be59770..0a1796d 100644 --- a/fpm.Dockerfile +++ b/fpm.Dockerfile @@ -1,4 +1,4 @@ -FROM php:8.1-fpm +FROM php:8.2.35-fpm # Arguments defined in docker-compose.yml ARG AKAUNTING_DOCKERFILE_VERSION=0.1 diff --git a/v.Dockerfile b/v.Dockerfile index 1aafc4b..c977e55 100644 --- a/v.Dockerfile +++ b/v.Dockerfile @@ -1,4 +1,4 @@ -FROM php:8.1-apache +FROM php:8.2.35-apache ARG AKAUNTING_DOCKERFILE_VERSION=0.1 ARG SUPPORTED_LOCALES="en_US.UTF-8"