diff options
author | Christian Segundo | 2024-02-11 14:35:54 +0100 |
---|---|---|
committer | Christian Segundo | 2024-02-11 14:35:54 +0100 |
commit | d1174938fa6feb0e1798fe33b231d32c6ead9575 (patch) | |
tree | 7680e5bdbd6329c9cc94b53fe5d8ba4ac7a5644d | |
parent | 5665d64844964b23bd4190824f248adf337ed271 (diff) | |
download | ledger-fava-d1174938fa6feb0e1798fe33b231d32c6ead9575.tar.gz |
bootstrap project
-rw-r--r-- | Dockerfile | 31 | ||||
-rw-r--r-- | goss.yaml | 0 | ||||
-rw-r--r-- | src/.ledger2beancount.yaml | 6 | ||||
-rw-r--r-- | src/init.sh | 42 | ||||
-rw-r--r-- | tests/command.yaml | 19 |
5 files changed, 98 insertions, 0 deletions
diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..2264a95 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,31 @@ +# hadolint ignore=DL3007 +FROM debian:latest + +WORKDIR /home/fava + +# hadolint ignore=DL3008,DL3013 +RUN \ + export DEBIAN_FRONTEND=noninteractive && \ + groupadd -g 1000 fava && \ + adduser \ + --uid 1000 \ + --gid 1000 \ + --home /home/fava \ + --no-create-home fava && \ + chown -R fava:fava /home/fava && \ + apt-get update && \ + apt-get install --no-install-recommends -y \ + beancount \ + ledger \ + ledger2beancount \ + python3-pip && \ + rm -rf /var/lib/apt/lists/* && \ + pip3 install \ + --break-system-packages \ + --no-cache-dir \ + fava + +COPY --chown=fava src/init.sh /home/fava/init.sh +COPY --chown=fava src/.ledger2beancount.yaml /home/fava/.ledger2beancount.yaml +USER fava +ENTRYPOINT [ "bash", "/home/fava/init.sh" ] diff --git a/goss.yaml b/goss.yaml new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/goss.yaml diff --git a/src/.ledger2beancount.yaml b/src/.ledger2beancount.yaml new file mode 100644 index 0000000..853809b --- /dev/null +++ b/src/.ledger2beancount.yaml @@ -0,0 +1,6 @@ +--- +date_format: "%d/%m/%Y" +decimal_comma: true +automatic_declarations: false +convert_virtual: false +ignore_marker: NoL2B diff --git a/src/init.sh b/src/init.sh new file mode 100644 index 0000000..32aa300 --- /dev/null +++ b/src/init.sh @@ -0,0 +1,42 @@ +#!/bin/bash +set -eufCo pipefail +export SHELLOPTS +IFS=$'\t\n' + +PORT=${PORT:-5000} +LEDGER_ROOT=${LEDGER_ROOT:-/ledger} +LEDGER2BEANCOUNT_CONFIG=${LEDGER2BEANCOUNT_CONFIG:-$(cat ~/.ledger2beancount.yaml)} +ADDITIONAL_CONFIG=${ADDITIONAL_CONFIG:-$( + cat <<EOF +option "operating_currency" "EUR" +2016-04-14 custom "fava-option" "language" "en" +2016-04-14 custom "fava-option" "invert-income-liabilities-equity" "true" +EOF +)} + +echo "${LEDGER2BEANCOUNT_CONFIG}" >|~/.ledger2beancount.yaml + +echo "LEDGER2BEANCOUNT_CONFIG" +cat ~/.ledger2beancount.yaml +echo +echo "ADDITIONAL_CONFIG" +echo "$ADDITIONAL_CONFIG" +echo + +tmp_file=$(mktemp) + +while read -r ledger_file; do + echo "Processing ${ledger_file}" + ledger2beancount -c ~/.ledger2beancount.yaml "$(realpath "${ledger_file}")" >>"${tmp_file}" +done < <(find "${LEDGER_ROOT}" -type f -name '*.ledger') + +bean-check "${tmp_file}" + +echo "${ADDITIONAL_CONFIG}" >>"${tmp_file}" + +fava \ + --host 0.0.0.0 \ + --port "${PORT}" \ + --read-only \ + "${tmp_file}" +rm "${tmp_file}" diff --git a/tests/command.yaml b/tests/command.yaml new file mode 100644 index 0000000..5367caa --- /dev/null +++ b/tests/command.yaml @@ -0,0 +1,19 @@ +--- +command: + 'fava --version': + exit-status: 0 + stderr: [] + stdout: + - fava + + 'ledger2beancount --version': + exit-status: 0 + stderr: [] + stdout: + - ledger2beancount + + 'bean-check --version': + exit-status: 0 + stderr: [] + stdout: + - Beancount |