diff --git a/.env.sample b/.env.sample index c663322..9c73c22 100644 --- a/.env.sample +++ b/.env.sample @@ -27,4 +27,8 @@ COMPANY_EMAIL=my@company.com ADMIN_EMAIL=me@company.com SECRET_MYSQL_PASSWORD_VERSION=v1 -SECRET_ADMIN_PASSWORD_VERSION=v1 \ No newline at end of file +SECRET_ADMIN_PASSWORD_VERSION=v1 + +## Enable API Fix to support offline use (without an API key) +# COMPOSE_FILE="$COMPOSE_FILE:compose.api-fix.yml" +# API_FIX=apply \ No newline at end of file diff --git a/abra.sh b/abra.sh index d020851..c91e502 100755 --- a/abra.sh +++ b/abra.sh @@ -1,3 +1,4 @@ # Set any config versions here # Docs: https://docs.coopcloud.tech/maintainers/handbook/#manage-configs export APP_ENTRYPOINT_VERSION=v1 +export API_FIX_VERSION=v1 \ No newline at end of file diff --git a/api-fix.patch b/api-fix.patch new file mode 100644 index 0000000..0299081 --- /dev/null +++ b/api-fix.patch @@ -0,0 +1,63 @@ +From f0bf18d4124aa480a0650eed771c57dfd85b7f6c Mon Sep 17 00:00:00 2001 +From: MIR +Date: Wed, 12 Nov 2025 17:36:37 -0500 +Subject: [PATCH] Fix errors when API key unavailable + +--- + app/Traits/Modules.php | 2 +- + app/Traits/Plans.php | 26 ++++---------------------- + 2 files changed, 5 insertions(+), 23 deletions(-) + +diff --git a/app/Traits/Modules.php b/app/Traits/Modules.php +index 8382b19e6..e91b33b2d 100644 +--- a/app/Traits/Modules.php ++++ b/app/Traits/Modules.php +@@ -26,7 +26,7 @@ trait Modules + + $result = json_decode($response->getBody()); + +- return $result->success ? true : false; ++ return true; + } + + // Get All Modules +diff --git a/app/Traits/Plans.php b/app/Traits/Plans.php +index 02ce4d575..b0501138d 100644 +--- a/app/Traits/Plans.php ++++ b/app/Traits/Plans.php +@@ -58,29 +58,11 @@ trait Plans + + public function getPlanLimitByType($type): object + { +- if (! config('app.installed') || running_in_test()) { +- $limit = new \stdClass(); +- +- $limit->action_status = true; +- $limit->view_status = true; +- $limit->message = "Success"; +- +- return $limit; +- } +- +- if (! $data = $this->getPlanLimits()) { +- $limit = new \stdClass(); +- +- $limit->action_status = false; +- $limit->view_status = false; +- $limit->message = "Not able to create a new $type."; +- +- return $limit; +- } +- +- $limit = $data->$type; ++ $limit = new \stdClass(); + +- $limit->message = str_replace('{company_id}', company_id(), $limit->message); ++ $limit->action_status = true; ++ $limit->view_status = true; ++ $limit->message = "Success"; + + return $limit; + } +-- +2.43.0 diff --git a/compose.api-fix.yml b/compose.api-fix.yml new file mode 100644 index 0000000..63d1cff --- /dev/null +++ b/compose.api-fix.yml @@ -0,0 +1,12 @@ +--- +services: + app: + configs: + - source: api_fix + target: /var/www/html/api-fix.patch + mode: 0644 + +configs: + api_fix: + name: ${STACK_NAME}_api_fix_${API_FIX_VERSION} + file: api-fix.patch \ No newline at end of file diff --git a/compose.yml b/compose.yml index 1f0485c..fb4202f 100644 --- a/compose.yml +++ b/compose.yml @@ -4,6 +4,7 @@ services: image: docker.io/akaunting/akaunting:latest networks: - proxy + - internal environment: - APP_URL=https://${DOMAIN} - DB_HOST=akaunting-db @@ -62,6 +63,8 @@ services: - MYSQL_RANDOM_ROOT_PASSWORD=yes secrets: - mysql_password + networks: + - internal volumes: akaunting-db: @@ -78,8 +81,10 @@ secrets: networks: proxy: external: true + internal: configs: app_entrypoint: name: ${STACK_NAME}_app_entrypoint_${APP_ENTRYPOINT_VERSION} - file: docker-entrypoint.sh \ No newline at end of file + file: docker-entrypoint.sh.tmpl + template_driver: golang \ No newline at end of file diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh deleted file mode 100644 index 07f5dbf..0000000 --- a/docker-entrypoint.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/bash - -export DB_PASSWORD=$(cat /run/secrets/mysql_password) -export ADMIN_PASSWORD=$(cat /run/secrets/admin_password) - -/usr/local/bin/akaunting.sh --start diff --git a/docker-entrypoint.sh.tmpl b/docker-entrypoint.sh.tmpl new file mode 100644 index 0000000..8ccd470 --- /dev/null +++ b/docker-entrypoint.sh.tmpl @@ -0,0 +1,11 @@ +#!/bin/bash + +export DB_PASSWORD=$(cat /run/secrets/mysql_password) +export ADMIN_PASSWORD=$(cat /run/secrets/admin_password) + +{{ if eq (env "API_FIX") "apply" }} +cd /var/www/html +patch --batch --forward -p1 < ./api-fix.patch +{{ end }} + +/usr/local/bin/akaunting.sh --start \ No newline at end of file