From dc4990ab9073c3b5444717c8a17fc039cb1293d4 Mon Sep 17 00:00:00 2001 From: Aaron Fiore Date: Mon, 16 Sep 2024 21:46:11 -0700 Subject: [PATCH] client: docker: complete build overhaul, optimize This commit brings a complete overhaul of the build system: - Creates a separation of concerns for 'local' and 'remote' building * 'local' is built locally via the docker-finance `build` command * 'remote' is built *outside* of the docker-finance `build` command (pushed to a remote registry and then pulled by the 'local' build) * Related refactoring - Dockerfiles - `lib_gen` - Adds remote image 'hledger-suite' * Provides the latest versions of all `hledger` related binaries * No longer relies on package maintainers / out-dated packages - Adds remote image 'docker-finance' * Provides base image for 'finance' and 'dev-tools' images - tags 'archlinux' | 'ubuntu' | 'dev-tools' - Removes previous `hledger` related build modules * Removes building any `hledger` related binaries locally - Removes 'experimental' build * End-user can use local custom Dockerfile and/or custom tag instead - Updates the 'default' | 'slim' | 'tiny' | 'micro' build types * Refactors build type requirements into separate build modules - Adds 'fetch' module - Adds 'track' module - Adds 'user' module * creates container user *after* base and all other modules * allows for quick re-building across multiple local users - Updates 'root' module * `lib_docker` - Updates usage help - Adds build modules per build type - Huge optimizations * Vastly improves build times - ~60% faster w/ a fresh build - ~60%-90% faster rebuild (depending on image type) * Vastly improves image sizes - e.g., 'default' Arch Linux image size is ~50% smaller --- .gitignore | 7 +- .../finance/Dockerfile.archlinux.in | 98 ------------ .../Dockerfiles/finance/Dockerfile.ubuntu.in | 103 ------------- .../archlinux/Dockerfile.hledger-flow.bin.in | 30 ---- .../ubuntu/Dockerfile.hledger-flow.bin.in | 33 ----- .../experimental/Dockerfile.hledger.src.in | 41 ----- .../ubuntu/experimental/Dockerfile.root.in | 75 ---------- .../local/dev-tools/Dockerfile.dev-tools.in | 21 +++ .../dev-tools/docker-compose.yml.dev-tools.in | 0 .../dev-tools/ubuntu/Dockerfile.user.in} | 23 +-- .../local/finance/Dockerfile.archlinux.in | 21 +++ .../local/finance/Dockerfile.ubuntu.in | 21 +++ .../finance/archlinux/Dockerfile.fetch.in} | 27 ++-- .../finance/archlinux/Dockerfile.root.in | 2 +- .../finance/archlinux/Dockerfile.track.in} | 17 +-- .../finance/archlinux/Dockerfile.user.in | 30 ++++ .../finance/docker-compose.yml.archlinux.in | 0 .../finance/docker-compose.yml.ubuntu.in | 0 .../{ => local}/finance/entrypoint.bash | 0 .../finance/ubuntu/Dockerfile.fetch.in} | 27 ++-- .../finance/ubuntu/Dockerfile.root.in | 8 +- .../finance/ubuntu/Dockerfile.track.in} | 18 +-- .../local/finance/ubuntu/Dockerfile.user.in | 33 +++++ .../dev-tools/Dockerfile.dev-tools} | 68 +++------ .../dev-tools/docker-compose.yml} | 29 +--- .../docker-finance}/dev-tools/entrypoint.bash | 0 .../finance/Dockerfile.archlinux | 53 +++++++ .../docker-finance/finance/Dockerfile.ubuntu | 56 +++++++ .../docker-finance/finance/docker-compose.yml | 31 ++++ .../docker-finance/finance/entrypoint.bash | 41 +++++ .../remote/hledger-suite/Dockerfile | 57 +++++++ .../remote/hledger-suite/docker-compose.yml | 24 +++ .../src/docker/lib/internal/lib_docker.bash | 140 ++++++++++-------- client/src/docker/lib/internal/lib_gen.bash | 2 +- 34 files changed, 554 insertions(+), 582 deletions(-) delete mode 100644 client/Dockerfiles/finance/Dockerfile.archlinux.in delete mode 100644 client/Dockerfiles/finance/Dockerfile.ubuntu.in delete mode 100644 client/Dockerfiles/finance/archlinux/Dockerfile.hledger-flow.bin.in delete mode 100644 client/Dockerfiles/finance/ubuntu/Dockerfile.hledger-flow.bin.in delete mode 100644 client/Dockerfiles/finance/ubuntu/experimental/Dockerfile.hledger.src.in delete mode 100644 client/Dockerfiles/finance/ubuntu/experimental/Dockerfile.root.in create mode 100644 client/Dockerfiles/local/dev-tools/Dockerfile.dev-tools.in rename client/Dockerfiles/{ => local}/dev-tools/docker-compose.yml.dev-tools.in (100%) rename client/Dockerfiles/{finance/archlinux/experimental/Dockerfile.root.in => local/dev-tools/ubuntu/Dockerfile.user.in} (68%) create mode 100644 client/Dockerfiles/local/finance/Dockerfile.archlinux.in create mode 100644 client/Dockerfiles/local/finance/Dockerfile.ubuntu.in rename client/Dockerfiles/{finance/archlinux/Dockerfile.hledger-flow.src.in => local/finance/archlinux/Dockerfile.fetch.in} (64%) rename client/Dockerfiles/{ => local}/finance/archlinux/Dockerfile.root.in (95%) rename client/Dockerfiles/{finance/archlinux/experimental/Dockerfile.hledger-flow.src.in => local/finance/archlinux/Dockerfile.track.in} (74%) create mode 100644 client/Dockerfiles/local/finance/archlinux/Dockerfile.user.in rename client/Dockerfiles/{ => local}/finance/docker-compose.yml.archlinux.in (100%) rename client/Dockerfiles/{ => local}/finance/docker-compose.yml.ubuntu.in (100%) rename client/Dockerfiles/{ => local}/finance/entrypoint.bash (100%) rename client/Dockerfiles/{finance/ubuntu/Dockerfile.hledger-flow.src.in => local/finance/ubuntu/Dockerfile.fetch.in} (69%) rename client/Dockerfiles/{ => local}/finance/ubuntu/Dockerfile.root.in (88%) rename client/Dockerfiles/{finance/ubuntu/experimental/Dockerfile.hledger-flow.src.in => local/finance/ubuntu/Dockerfile.track.in} (72%) create mode 100644 client/Dockerfiles/local/finance/ubuntu/Dockerfile.user.in rename client/Dockerfiles/{dev-tools/Dockerfile.dev-tools.in => remote/docker-finance/dev-tools/Dockerfile.dev-tools} (53%) rename client/Dockerfiles/{finance/archlinux/experimental/Dockerfile.hledger.src.in => remote/docker-finance/dev-tools/docker-compose.yml} (63%) rename client/Dockerfiles/{ => remote/docker-finance}/dev-tools/entrypoint.bash (100%) create mode 100644 client/Dockerfiles/remote/docker-finance/finance/Dockerfile.archlinux create mode 100644 client/Dockerfiles/remote/docker-finance/finance/Dockerfile.ubuntu create mode 100644 client/Dockerfiles/remote/docker-finance/finance/docker-compose.yml create mode 100755 client/Dockerfiles/remote/docker-finance/finance/entrypoint.bash create mode 100644 client/Dockerfiles/remote/hledger-suite/Dockerfile create mode 100644 client/Dockerfiles/remote/hledger-suite/docker-compose.yml diff --git a/.gitignore b/.gitignore index 1bb6aa3..9304d33 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,7 @@ -**/Dockerfile -**/docker-compose.yml +client/Dockerfiles/local/dev-tools/Dockerfile +client/Dockerfiles/local/dev-tools/docker-compose.yml +client/Dockerfiles/local/finance/Dockerfile +client/Dockerfiles/local/finance/docker-compose.yml +client/Dockerfiles/remote/build-push.bash client/Doxygen/html gitea-merge.bash diff --git a/client/Dockerfiles/finance/Dockerfile.archlinux.in b/client/Dockerfiles/finance/Dockerfile.archlinux.in deleted file mode 100644 index 6652625..0000000 --- a/client/Dockerfiles/finance/Dockerfile.archlinux.in +++ /dev/null @@ -1,98 +0,0 @@ -# docker-finance | modern accounting for the power-user -# -# Copyright (C) 2021-2024 Aaron Fiore (Founder, Evergreen Crypto LLC) -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -# https://hub.docker.com/_/archlinux -FROM archlinux:base-devel - -# -# System preparation -# - -# Add system-level user for building (won't pollute user-level UID space) -RUN useradd -m -s /bin/bash -r builder -RUN gpasswd -a builder wheel - -# Prepare for non-package dependencies -RUN chown root:wheel /usr/local/* && chmod g+rwx /usr/local/* - -# -# Package dependencies -# - -RUN pacman -Syu \ - csvkit \ - git \ - hledger \ - hledger-iadd \ - hledger-ui \ - hledger-web \ - timew \ - vim \ - visidata \ - xsv \ - yq \ - --noconfirm --disable-download-timeout - -# -# `fetch` APIs -# - -USER root - -RUN pacman -Syu \ - bc \ - composer \ - proxychains-ng \ - --noconfirm --disable-download-timeout - -RUN sed -i \ - -e 's:^;extension=bcmath:extension=bcmath:' \ - -e 's:^;extension=gmp:extension=gmp:' \ - -e 's:^;extension=iconv:extension=iconv:' \ - /etc/php/php.ini - -USER builder -WORKDIR /usr/local/lib/php -# NOTE: Coinbase Pro has been "sunsetted" -#RUN composer require mocking-magician/coinbase-pro-sdk -RUN composer require ozdemirburak/json-csv -RUN composer require ccxt/ccxt - -# -# Shell environment -# - -# Add `finance` user -USER root -RUN useradd -m -s /bin/bash @DOCKER_FINANCE_USER@ -u @DOCKER_FINANCE_UID@ - -USER @DOCKER_FINANCE_USER@ -RUN echo "source \"\${DOCKER_FINANCE_CONTAINER_CONF}/shell/superscript.bash\"" | tee -a ~/.bashrc -RUN echo "source \"\${DOCKER_FINANCE_CONTAINER_REPO}/src/finance/completion.bash\"" | tee -a ~/.bashrc - -# -# Entrypoint -# - -USER root -COPY ./entrypoint.bash /entrypoint.bash -RUN chmod a+rx /entrypoint.bash - -USER @DOCKER_FINANCE_USER@ -ENTRYPOINT ["/entrypoint.bash"] - -# vim: sw=2 sts=2 si ai et diff --git a/client/Dockerfiles/finance/Dockerfile.ubuntu.in b/client/Dockerfiles/finance/Dockerfile.ubuntu.in deleted file mode 100644 index d30fd1a..0000000 --- a/client/Dockerfiles/finance/Dockerfile.ubuntu.in +++ /dev/null @@ -1,103 +0,0 @@ -# docker-finance | modern accounting for the power-user -# -# Copyright (C) 2021-2024 Aaron Fiore (Founder, Evergreen Crypto LLC) -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -FROM ubuntu:rolling - -# -# System preparation -# - -RUN groupadd -r wheel - -# Remove default `ubuntu` user which may conflict with host user's UID/GID (1000:1000) -RUN userdel -r ubuntu - -# Add system-level user for building (won't pollute user-level UID space) -RUN useradd -m -s /bin/bash -r builder -RUN gpasswd -a builder wheel - -# Prepare for non-package dependencies -RUN chown root:wheel /usr/local/* && chmod g+rwx /usr/local/* - -# -# Package dependencies -# - -RUN apt-get update -y - -RUN apt-get install -y \ - csvkit \ - gawk \ - git \ - hledger \ - hledger-ui \ - hledger-web \ - timewarrior \ - vim \ - visidata \ - yq \ - zlib1g-dev - -RUN apt-get install -y cargo -RUN cargo install xsv --root /usr - -# -# `fetch` APIs -# - -USER root -RUN apt-get install -y \ - bc \ - composer \ - php \ - php-bcmath \ - php-curl \ - php-gmp \ - proxychains4 - -USER builder -WORKDIR /usr/local/lib/php -# NOTE: Coinbase Pro has been "sunsetted" -#RUN composer require mocking-magician/coinbase-pro-sdk -RUN composer require ozdemirburak/json-csv -RUN composer require ccxt/ccxt - -# -# Shell environment -# - -# Add `finance` user -RUN useradd -m -s /bin/bash @DOCKER_FINANCE_USER@ -u @DOCKER_FINANCE_UID@ - -USER @DOCKER_FINANCE_USER@ -RUN echo "source \"\${DOCKER_FINANCE_CONTAINER_CONF}/shell/superscript.bash\"" | tee -a ~/.bash_aliases -RUN echo "source \"\${DOCKER_FINANCE_CONTAINER_REPO}/src/finance/completion.bash\"" | tee -a ~/.bash_aliases - -# -# Entrypoint -# - -USER root -COPY ./entrypoint.bash /entrypoint.bash -RUN chmod a+rx /entrypoint.bash - -USER @DOCKER_FINANCE_USER@ -WORKDIR /home/@DOCKER_FINANCE_USER@ - -ENTRYPOINT ["/entrypoint.bash"] - -# vim: sw=2 sts=2 si ai et diff --git a/client/Dockerfiles/finance/archlinux/Dockerfile.hledger-flow.bin.in b/client/Dockerfiles/finance/archlinux/Dockerfile.hledger-flow.bin.in deleted file mode 100644 index 3f7b77e..0000000 --- a/client/Dockerfiles/finance/archlinux/Dockerfile.hledger-flow.bin.in +++ /dev/null @@ -1,30 +0,0 @@ -# docker-finance | modern accounting for the power-user -# -# Copyright (C) 2021-2024 Aaron Fiore (Founder, Evergreen Crypto LLC) -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -# -# hledger-flow (binary) -# - -USER builder -WORKDIR /usr/local/src -RUN curl --location -O "https://github.com/apauley/hledger-flow/releases/download/v0.15.0/hledger-flow_Linux_x86_64_v0.15.0_2b025fe.tar.gz" -RUN tar xvzf "hledger-flow_Linux_x86_64_v0.15.0_2b025fe.tar.gz" -WORKDIR /usr/local/src/hledger-flow_Linux_x86_64_v0.15.0_2b025fe -RUN sha256sum -c "sha256-hledger-flow_Linux_x86_64_v0.15.0_2b025fe.txt" -RUN mv hledger-flow /usr/local/bin/ - -# vim: sw=2 sts=2 si ai et diff --git a/client/Dockerfiles/finance/ubuntu/Dockerfile.hledger-flow.bin.in b/client/Dockerfiles/finance/ubuntu/Dockerfile.hledger-flow.bin.in deleted file mode 100644 index 0a78167..0000000 --- a/client/Dockerfiles/finance/ubuntu/Dockerfile.hledger-flow.bin.in +++ /dev/null @@ -1,33 +0,0 @@ -# docker-finance | modern accounting for the power-user -# -# Copyright (C) 2021-2024 Aaron Fiore (Founder, Evergreen Crypto LLC) -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -# -# hledger-flow (binary) -# - -USER root -RUN apt-get install -y curl - -USER builder -WORKDIR /usr/local/src -RUN curl --location -O "https://github.com/apauley/hledger-flow/releases/download/v0.15.0/hledger-flow_Linux_x86_64_v0.15.0_2b025fe.tar.gz" -RUN tar xvzf "hledger-flow_Linux_x86_64_v0.15.0_2b025fe.tar.gz" -WORKDIR /usr/local/src/hledger-flow_Linux_x86_64_v0.15.0_2b025fe -RUN sha256sum -c "sha256-hledger-flow_Linux_x86_64_v0.15.0_2b025fe.txt" -RUN mv hledger-flow /usr/local/bin/ - -# vim: sw=2 sts=2 si ai et diff --git a/client/Dockerfiles/finance/ubuntu/experimental/Dockerfile.hledger.src.in b/client/Dockerfiles/finance/ubuntu/experimental/Dockerfile.hledger.src.in deleted file mode 100644 index 499ba3f..0000000 --- a/client/Dockerfiles/finance/ubuntu/experimental/Dockerfile.hledger.src.in +++ /dev/null @@ -1,41 +0,0 @@ -# docker-finance | modern accounting for the power-user -# -# Copyright (C) 2024 Aaron Fiore (Evergreen Crypto LLC) -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -# -# hledger (source) -# - -USER root - -# Remove pre-existing -RUN apt-get autoremove --purge -y \ - hledger \ - hledger-ui \ - hledger-web - -RUN apt-get install -y \ - haskell-stack - -USER builder -WORKDIR /usr/local/src -RUN git clone https://github.com/simonmichael/hledger -b master - -WORKDIR /usr/local/src/hledger -RUN stack update -RUN stack install --resolver="lts-22.28" --install-ghc --local-bin-path=/usr/local/bin - -# vim: sw=2 sts=2 si ai et diff --git a/client/Dockerfiles/finance/ubuntu/experimental/Dockerfile.root.in b/client/Dockerfiles/finance/ubuntu/experimental/Dockerfile.root.in deleted file mode 100644 index 297fa15..0000000 --- a/client/Dockerfiles/finance/ubuntu/experimental/Dockerfile.root.in +++ /dev/null @@ -1,75 +0,0 @@ -# docker-finance | modern accounting for the power-user -# -# Copyright (C) 2021-2024 Aaron Fiore (Founder, Evergreen Crypto LLC) -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -# -# ROOT.cern (and docker-finance requirements) -# - -USER root - -# ROOT.cern dependencies (regardless of building or not) -RUN apt-get install -y \ - binutils \ - cmake \ - dpkg-dev \ - g++ \ - gcc \ - libssl-dev \ - libtbb-dev \ - libx11-dev \ - libxext-dev \ - libxft-dev \ - libxpm-dev \ - python3 - -# ROOT.cern pre-compiled installation -RUN apt-get install -y curl -USER builder -WORKDIR /usr/local/src -RUN curl --location -O "https://root.cern/download/root_v6.32.02.Linux-ubuntu24.04-x86_64-gcc13.2.tar.gz" -RUN tar xvzf "root_v6.32.02.Linux-ubuntu24.04-x86_64-gcc13.2.tar.gz" - -# ROOT.cern environment -# -# bash_aliases notes: -# -# - *MUST* source thisroot.sh (from any directory) -# -# - For `docker-finance version` command: -# -# - To avoid thisroot.sh error, pushd/popd is required (per thisroot.sh) -# -# - Although $ROOTSYS will be available during normal operation, it won't -# be avaialble to `docker-finance version`- so add binary to PATH here. -USER @DOCKER_FINANCE_USER@ -RUN echo "pushd /usr/local/src/root/bin 1>/dev/null && source \"/usr/local/src/root/bin/thisroot.sh\" && popd 1>/dev/null" | tee -a ~/.bash_aliases -RUN echo "export PATH=\"\$PATH::/usr/local/src/root/bin\"" | tee -a ~/.bash_aliases - -# docker-finance -USER root -RUN apt-get install -y \ - googletest \ - libbenchmark-dev \ - libbotan-2-dev \ - libcrypto++-dev \ - libsodium-dev - -# docker-finance (experimental / testing) -RUN apt-get install -y \ - libunuran-dev - -# vim: sw=2 sts=2 si ai et diff --git a/client/Dockerfiles/local/dev-tools/Dockerfile.dev-tools.in b/client/Dockerfiles/local/dev-tools/Dockerfile.dev-tools.in new file mode 100644 index 0000000..eb27e09 --- /dev/null +++ b/client/Dockerfiles/local/dev-tools/Dockerfile.dev-tools.in @@ -0,0 +1,21 @@ +# docker-finance | modern accounting for the power-user +# +# Copyright (C) 2021-2024 Aaron Fiore (Founder, Evergreen Crypto LLC) +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# https://hub.docker.com/evergreencrypto/docker-finance +FROM evergreencrypto/docker-finance:dev-tools + +# vim: sw=2 sts=2 si ai et diff --git a/client/Dockerfiles/dev-tools/docker-compose.yml.dev-tools.in b/client/Dockerfiles/local/dev-tools/docker-compose.yml.dev-tools.in similarity index 100% rename from client/Dockerfiles/dev-tools/docker-compose.yml.dev-tools.in rename to client/Dockerfiles/local/dev-tools/docker-compose.yml.dev-tools.in diff --git a/client/Dockerfiles/finance/archlinux/experimental/Dockerfile.root.in b/client/Dockerfiles/local/dev-tools/ubuntu/Dockerfile.user.in similarity index 68% rename from client/Dockerfiles/finance/archlinux/experimental/Dockerfile.root.in rename to client/Dockerfiles/local/dev-tools/ubuntu/Dockerfile.user.in index faaac1e..5a02b30 100644 --- a/client/Dockerfiles/finance/archlinux/experimental/Dockerfile.root.in +++ b/client/Dockerfiles/local/dev-tools/ubuntu/Dockerfile.user.in @@ -16,28 +16,15 @@ # along with this program. If not, see . # -# ROOT.cern (and docker-finance requirements) +# 'user' module # USER root -# ROOT.cern -RUN pacman -Syu \ - root \ - --noconfirm --disable-download-timeout +# Remove default 'ubuntu' user which may conflict with host user's UID/GID (1000:1000) +RUN userdel -r ubuntu -# docker-finance -RUN pacman -Syu \ - benchmark \ - botan2 \ - crypto++ \ - gtest \ - libsodium \ - --noconfirm --disable-download-timeout - -# docker-finance (experimental / testing) -RUN pacman -Syu \ - unuran \ - --noconfirm --disable-download-timeout +# Add 'dev-tools' user +RUN useradd -m -s /bin/bash @DOCKER_FINANCE_USER@ -u @DOCKER_FINANCE_UID@ # vim: sw=2 sts=2 si ai et diff --git a/client/Dockerfiles/local/finance/Dockerfile.archlinux.in b/client/Dockerfiles/local/finance/Dockerfile.archlinux.in new file mode 100644 index 0000000..a19635a --- /dev/null +++ b/client/Dockerfiles/local/finance/Dockerfile.archlinux.in @@ -0,0 +1,21 @@ +# docker-finance | modern accounting for the power-user +# +# Copyright (C) 2021-2024 Aaron Fiore (Founder, Evergreen Crypto LLC) +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# https://hub.docker.com/evergreencrypto/docker-finance +FROM evergreencrypto/docker-finance:archlinux + +# vim: sw=2 sts=2 si ai et diff --git a/client/Dockerfiles/local/finance/Dockerfile.ubuntu.in b/client/Dockerfiles/local/finance/Dockerfile.ubuntu.in new file mode 100644 index 0000000..271b6ab --- /dev/null +++ b/client/Dockerfiles/local/finance/Dockerfile.ubuntu.in @@ -0,0 +1,21 @@ +# docker-finance | modern accounting for the power-user +# +# Copyright (C) 2021-2024 Aaron Fiore (Founder, Evergreen Crypto LLC) +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# https://hub.docker.com/evergreencrypto/docker-finance +FROM evergreencrypto/docker-finance:ubuntu + +# vim: sw=2 sts=2 si ai et diff --git a/client/Dockerfiles/finance/archlinux/Dockerfile.hledger-flow.src.in b/client/Dockerfiles/local/finance/archlinux/Dockerfile.fetch.in similarity index 64% rename from client/Dockerfiles/finance/archlinux/Dockerfile.hledger-flow.src.in rename to client/Dockerfiles/local/finance/archlinux/Dockerfile.fetch.in index 31c73fe..3527e05 100644 --- a/client/Dockerfiles/finance/archlinux/Dockerfile.hledger-flow.src.in +++ b/client/Dockerfiles/local/finance/archlinux/Dockerfile.fetch.in @@ -16,24 +16,31 @@ # along with this program. If not, see . # -# hledger-flow (source) +# 'fetch' module # USER root RUN pacman -Syu \ - stack \ + composer \ + proxychains-ng \ --noconfirm --disable-download-timeout -# TODO: upstream-integrate with hledger? packaged somewhere? would like to not have to clone and build here... +RUN sed -i \ + -e 's:^;extension=bcmath:extension=bcmath:' \ + -e 's:^;extension=gmp:extension=gmp:' \ + -e 's:^;extension=iconv:extension=iconv:' \ + /etc/php/php.ini + +# Add builder user for `composer` +RUN useradd -m -s /bin/bash -r builder + USER builder +WORKDIR /usr/local/lib/php -WORKDIR /usr/local/src -RUN git clone --depth=1 https://github.com/apauley/hledger-flow -b v0.15.0 - -WORKDIR /usr/local/src/hledger-flow -RUN stack setup -RUN stack build -RUN stack install --local-bin-path=/usr/local/bin +RUN composer require -n ozdemirburak/json-csv +RUN composer require -n ccxt/ccxt +# "Sunsetted" Coinbase Pro +#RUN composer require mocking-magician/coinbase-pro-sdk # vim: sw=2 sts=2 si ai et diff --git a/client/Dockerfiles/finance/archlinux/Dockerfile.root.in b/client/Dockerfiles/local/finance/archlinux/Dockerfile.root.in similarity index 95% rename from client/Dockerfiles/finance/archlinux/Dockerfile.root.in rename to client/Dockerfiles/local/finance/archlinux/Dockerfile.root.in index 667a30a..adeeee4 100644 --- a/client/Dockerfiles/finance/archlinux/Dockerfile.root.in +++ b/client/Dockerfiles/local/finance/archlinux/Dockerfile.root.in @@ -16,7 +16,7 @@ # along with this program. If not, see . # -# ROOT.cern (and docker-finance requirements) +# 'root' module # USER root diff --git a/client/Dockerfiles/finance/archlinux/experimental/Dockerfile.hledger-flow.src.in b/client/Dockerfiles/local/finance/archlinux/Dockerfile.track.in similarity index 74% rename from client/Dockerfiles/finance/archlinux/experimental/Dockerfile.hledger-flow.src.in rename to client/Dockerfiles/local/finance/archlinux/Dockerfile.track.in index 8d52384..816238d 100644 --- a/client/Dockerfiles/finance/archlinux/experimental/Dockerfile.hledger-flow.src.in +++ b/client/Dockerfiles/local/finance/archlinux/Dockerfile.track.in @@ -16,24 +16,15 @@ # along with this program. If not, see . # -# hledger-flow (source) +# 'track' module # USER root RUN pacman -Syu \ - stack \ + git \ + timew \ + visidata \ --noconfirm --disable-download-timeout -USER builder - -WORKDIR /usr/local/src -RUN git clone https://github.com/apauley/hledger-flow -b master - -WORKDIR /usr/local/src/hledger-flow -RUN stack setup -RUN stack build -RUN stack test --interleaved-output --pedantic -RUN stack install --local-bin-path=/usr/local/bin - # vim: sw=2 sts=2 si ai et diff --git a/client/Dockerfiles/local/finance/archlinux/Dockerfile.user.in b/client/Dockerfiles/local/finance/archlinux/Dockerfile.user.in new file mode 100644 index 0000000..f0db1b5 --- /dev/null +++ b/client/Dockerfiles/local/finance/archlinux/Dockerfile.user.in @@ -0,0 +1,30 @@ +# docker-finance | modern accounting for the power-user +# +# Copyright (C) 2021-2024 Aaron Fiore (Founder, Evergreen Crypto LLC) +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# +# 'user' module +# + +# Add 'finance' user +USER root +RUN useradd -m -s /bin/bash @DOCKER_FINANCE_USER@ -u @DOCKER_FINANCE_UID@ + +USER @DOCKER_FINANCE_USER@ +RUN echo "source \"\${DOCKER_FINANCE_CONTAINER_CONF}/shell/superscript.bash\"" >>~/.bashrc +RUN echo "source \"\${DOCKER_FINANCE_CONTAINER_REPO}/src/finance/completion.bash\"" >>~/.bashrc + +# vim: sw=2 sts=2 si ai et diff --git a/client/Dockerfiles/finance/docker-compose.yml.archlinux.in b/client/Dockerfiles/local/finance/docker-compose.yml.archlinux.in similarity index 100% rename from client/Dockerfiles/finance/docker-compose.yml.archlinux.in rename to client/Dockerfiles/local/finance/docker-compose.yml.archlinux.in diff --git a/client/Dockerfiles/finance/docker-compose.yml.ubuntu.in b/client/Dockerfiles/local/finance/docker-compose.yml.ubuntu.in similarity index 100% rename from client/Dockerfiles/finance/docker-compose.yml.ubuntu.in rename to client/Dockerfiles/local/finance/docker-compose.yml.ubuntu.in diff --git a/client/Dockerfiles/finance/entrypoint.bash b/client/Dockerfiles/local/finance/entrypoint.bash similarity index 100% rename from client/Dockerfiles/finance/entrypoint.bash rename to client/Dockerfiles/local/finance/entrypoint.bash diff --git a/client/Dockerfiles/finance/ubuntu/Dockerfile.hledger-flow.src.in b/client/Dockerfiles/local/finance/ubuntu/Dockerfile.fetch.in similarity index 69% rename from client/Dockerfiles/finance/ubuntu/Dockerfile.hledger-flow.src.in rename to client/Dockerfiles/local/finance/ubuntu/Dockerfile.fetch.in index 16de2af..4fda03b 100644 --- a/client/Dockerfiles/finance/ubuntu/Dockerfile.hledger-flow.src.in +++ b/client/Dockerfiles/local/finance/ubuntu/Dockerfile.fetch.in @@ -16,24 +16,29 @@ # along with this program. If not, see . # -# hledger-flow (source) +# 'fetch' module # USER root RUN apt-get install -y \ - g++ \ - haskell-stack + composer \ + curl \ + php \ + php-bcmath \ + php-curl \ + php-gmp \ + proxychains4 + +# Add builder user for `composer` +RUN useradd -m -s /bin/bash -r builder -# TODO: upstream-integrate with hledger? packaged somewhere? would like to not have to clone and build here... USER builder +WORKDIR /usr/local/lib/php -WORKDIR /usr/local/src -RUN git clone --depth=1 https://github.com/apauley/hledger-flow -b v0.15.0 - -WORKDIR /usr/local/src/hledger-flow -RUN stack setup -RUN stack build -RUN stack install --local-bin-path=/usr/local/bin +RUN composer require ozdemirburak/json-csv +RUN composer require ccxt/ccxt +# "Sunsetted" Coinbase Pro +#RUN composer require mocking-magician/coinbase-pro-sdk # vim: sw=2 sts=2 si ai et diff --git a/client/Dockerfiles/finance/ubuntu/Dockerfile.root.in b/client/Dockerfiles/local/finance/ubuntu/Dockerfile.root.in similarity index 88% rename from client/Dockerfiles/finance/ubuntu/Dockerfile.root.in rename to client/Dockerfiles/local/finance/ubuntu/Dockerfile.root.in index 1fcefe1..2774054 100644 --- a/client/Dockerfiles/finance/ubuntu/Dockerfile.root.in +++ b/client/Dockerfiles/local/finance/ubuntu/Dockerfile.root.in @@ -16,7 +16,7 @@ # along with this program. If not, see . # -# ROOT.cern (and docker-finance requirements) +# 'root' module # USER root @@ -38,7 +38,6 @@ RUN apt-get install -y \ # ROOT.cern pre-compiled installation RUN apt-get install -y curl -USER builder WORKDIR /usr/local/src RUN curl --location -O "https://root.cern/download/root_v6.32.02.Linux-ubuntu24.04-x86_64-gcc13.2.tar.gz" RUN tar xvzf "root_v6.32.02.Linux-ubuntu24.04-x86_64-gcc13.2.tar.gz" @@ -55,9 +54,8 @@ RUN tar xvzf "root_v6.32.02.Linux-ubuntu24.04-x86_64-gcc13.2.tar.gz" # # - Although $ROOTSYS will be available during normal operation, it won't # be avaialble to `docker-finance version`- so add binary to PATH here. -USER @DOCKER_FINANCE_USER@ -RUN echo "pushd /usr/local/src/root/bin 1>/dev/null && source \"/usr/local/src/root/bin/thisroot.sh\" && popd 1>/dev/null" | tee -a ~/.bash_aliases -RUN echo "export PATH=\"\$PATH::/usr/local/src/root/bin\"" | tee -a ~/.bash_aliases +RUN echo "pushd /usr/local/src/root/bin 1>/dev/null && source \"/usr/local/src/root/bin/thisroot.sh\" && popd 1>/dev/null" >>/etc/bash.bashrc +RUN echo "export PATH=\"\$PATH::/usr/local/src/root/bin\"" >>/etc/bash.bashrc # docker-finance USER root diff --git a/client/Dockerfiles/finance/ubuntu/experimental/Dockerfile.hledger-flow.src.in b/client/Dockerfiles/local/finance/ubuntu/Dockerfile.track.in similarity index 72% rename from client/Dockerfiles/finance/ubuntu/experimental/Dockerfile.hledger-flow.src.in rename to client/Dockerfiles/local/finance/ubuntu/Dockerfile.track.in index 0946261..bc286b2 100644 --- a/client/Dockerfiles/finance/ubuntu/experimental/Dockerfile.hledger-flow.src.in +++ b/client/Dockerfiles/local/finance/ubuntu/Dockerfile.track.in @@ -16,24 +16,14 @@ # along with this program. If not, see . # -# hledger-flow (source) +# 'track' module # USER root RUN apt-get install -y \ - g++ \ - haskell-stack - -USER builder - -WORKDIR /usr/local/src -RUN git clone https://github.com/apauley/hledger-flow -b master - -WORKDIR /usr/local/src/hledger-flow -RUN stack setup -RUN stack build -RUN stack test --interleaved-output --pedantic -RUN stack install --local-bin-path=/usr/local/bin + git \ + timewarrior \ + visidata # vim: sw=2 sts=2 si ai et diff --git a/client/Dockerfiles/local/finance/ubuntu/Dockerfile.user.in b/client/Dockerfiles/local/finance/ubuntu/Dockerfile.user.in new file mode 100644 index 0000000..f73cf23 --- /dev/null +++ b/client/Dockerfiles/local/finance/ubuntu/Dockerfile.user.in @@ -0,0 +1,33 @@ +# docker-finance | modern accounting for the power-user +# +# Copyright (C) 2021-2024 Aaron Fiore (Founder, Evergreen Crypto LLC) +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# +# 'user' module +# + +# Remove default 'ubuntu' user which may conflict with host user's UID/GID (1000:1000) +USER root +RUN userdel -r ubuntu + +# Add 'finance' user +RUN useradd -m -s /bin/bash @DOCKER_FINANCE_USER@ -u @DOCKER_FINANCE_UID@ + +USER @DOCKER_FINANCE_USER@ +RUN echo "source \"\${DOCKER_FINANCE_CONTAINER_CONF}/shell/superscript.bash\"" >>~/.bash_aliases +RUN echo "source \"\${DOCKER_FINANCE_CONTAINER_REPO}/src/finance/completion.bash\"" >>~/.bash_aliases + +# vim: sw=2 sts=2 si ai et diff --git a/client/Dockerfiles/dev-tools/Dockerfile.dev-tools.in b/client/Dockerfiles/remote/docker-finance/dev-tools/Dockerfile.dev-tools similarity index 53% rename from client/Dockerfiles/dev-tools/Dockerfile.dev-tools.in rename to client/Dockerfiles/remote/docker-finance/dev-tools/Dockerfile.dev-tools index ddd3f0b..fd2ba08 100644 --- a/client/Dockerfiles/dev-tools/Dockerfile.dev-tools.in +++ b/client/Dockerfiles/remote/docker-finance/dev-tools/Dockerfile.dev-tools @@ -17,27 +17,13 @@ FROM ubuntu:rolling -# -# System -# - -RUN groupadd -r wheel - -# Remove default `ubuntu` user which may conflict with host user's UID/GID (1000:1000) -RUN userdel -r ubuntu - -# Add `dev-tools` user -RUN useradd -m -s /bin/bash @DOCKER_FINANCE_USER@ -u @DOCKER_FINANCE_UID@ -RUN gpasswd -a @DOCKER_FINANCE_USER@ wheel - -# System-level user for building (won't pollute user-level UID space) -RUN useradd -m -s /bin/bash -r builder && gpasswd -a builder wheel -RUN gpasswd -a builder wheel - RUN apt-get update -y +# Add builder user (for `composer` and non-root building) +RUN useradd -m -s /bin/bash -r builder + # -# `dev-tools` Linters +# 'dev-tools' linters # # Bash @@ -49,43 +35,39 @@ RUN apt-get install -y clang-format cppcheck cpplint # PHP RUN apt-get install -y composer -USER @DOCKER_FINANCE_USER@ -WORKDIR /home/@DOCKER_FINANCE_USER@ +USER builder +WORKDIR /usr/local/lib/php -RUN composer global require -n --dev friendsofphp/php-cs-fixer -RUN composer global require -n --dev phpstan/phpstan - -RUN echo "export PATH=\"\${PATH}:\${HOME}/.composer/vendor/bin\"" | tee -a ~/.bash_aliases - -# -# `finance` dependencies (fetch APIs) -# +RUN composer require -n --dev friendsofphp/php-cs-fixer +RUN composer require -n --dev phpstan/phpstan USER root +RUN echo "export PATH=\"\$PATH:/usr/local/lib/php/vendor/bin\"" >>/etc/bash.bashrc + +# +# 'finance' dependencies (`fetch` APIs) +# + RUN apt-get install -y php php-bcmath php-curl php-gmp USER builder WORKDIR /usr/local/lib/php -RUN composer require ozdemirburak/json-csv -RUN composer require ccxt/ccxt + +RUN composer require -n ozdemirburak/json-csv +RUN composer require -n ccxt/ccxt # "Sunsetted" Coinbase Pro -RUN composer require mocking-magician/coinbase-pro-sdk +RUN composer require -n mocking-magician/coinbase-pro-sdk + +# +# 'dev-tools' misc. +# -# Allow real-time editing of libraries (useful for debugging) USER root -RUN chown -R :wheel /usr/local/lib/php && chmod g+rwx /usr/local/lib/php - -# -# `dev-tools` misc. -# # Doxygen RUN apt-get install -y doxygen graphviz -# -# Client-side `version` command -# - +# docker-finance `version` command RUN apt-get install -y yq # @@ -94,10 +76,6 @@ RUN apt-get install -y yq COPY ./entrypoint.bash /entrypoint.bash RUN chmod a+rx /entrypoint.bash - -USER @DOCKER_FINANCE_USER@ -WORKDIR /home/@DOCKER_FINANCE_USER@ - ENTRYPOINT ["/entrypoint.bash"] # vim: sw=2 sts=2 si ai et diff --git a/client/Dockerfiles/finance/archlinux/experimental/Dockerfile.hledger.src.in b/client/Dockerfiles/remote/docker-finance/dev-tools/docker-compose.yml similarity index 63% rename from client/Dockerfiles/finance/archlinux/experimental/Dockerfile.hledger.src.in rename to client/Dockerfiles/remote/docker-finance/dev-tools/docker-compose.yml index decfa31..7420cc7 100644 --- a/client/Dockerfiles/finance/archlinux/experimental/Dockerfile.hledger.src.in +++ b/client/Dockerfiles/remote/docker-finance/dev-tools/docker-compose.yml @@ -1,6 +1,6 @@ # docker-finance | modern accounting for the power-user # -# Copyright (C) 2024 Aaron Fiore (Evergreen Crypto LLC) +# Copyright (C) 2024 Aaron Fiore (Founder, Evergreen Crypto LLC) # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -15,25 +15,12 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -# -# hledger (source) -# - -USER root - -# Remove pre-existing -RUN pacman -Rsc \ - hledger \ - hledger-ui \ - hledger-web \ - --noconfirm - -USER builder -WORKDIR /usr/local/src -RUN git clone https://github.com/simonmichael/hledger -b master - -WORKDIR /usr/local/src/hledger -RUN stack update -RUN stack install --resolver="lts-22.28" --install-ghc --local-bin-path=/usr/local/bin +services: + dev-tools: + image: evergreencrypto/docker-finance:dev-tools + container_name: evergreencrypto_docker-finance_dev-tools + build: + dockerfile: Dockerfile.dev-tools +# TODO: add labels # vim: sw=2 sts=2 si ai et diff --git a/client/Dockerfiles/dev-tools/entrypoint.bash b/client/Dockerfiles/remote/docker-finance/dev-tools/entrypoint.bash similarity index 100% rename from client/Dockerfiles/dev-tools/entrypoint.bash rename to client/Dockerfiles/remote/docker-finance/dev-tools/entrypoint.bash diff --git a/client/Dockerfiles/remote/docker-finance/finance/Dockerfile.archlinux b/client/Dockerfiles/remote/docker-finance/finance/Dockerfile.archlinux new file mode 100644 index 0000000..504af21 --- /dev/null +++ b/client/Dockerfiles/remote/docker-finance/finance/Dockerfile.archlinux @@ -0,0 +1,53 @@ +# docker-finance | modern accounting for the power-user +# +# Copyright (C) 2021-2024 Aaron Fiore (Founder, Evergreen Crypto LLC) +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# +# Base dependencies +# + +# https://hub.docker.com/evergreencrypto/hledger-suite +FROM evergreencrypto/hledger-suite:latest AS hledger-suite + +# https://hub.docker.com/_/archlinux +FROM archlinux:base-devel + +COPY --from=hledger-suite /usr/local/bin/hledger /usr/local/bin/hledger +COPY --from=hledger-suite /usr/local/bin/hledger-ui /usr/local/bin/hledger-ui +COPY --from=hledger-suite /usr/local/bin/hledger-web /usr/local/bin/hledger-web +COPY --from=hledger-suite /usr/local/bin/hledger-iadd /usr/local/bin/hledger-iadd +COPY --from=hledger-suite /usr/local/bin/hledger-flow /usr/local/bin/hledger-flow + +RUN pacman -Syu --noconfirm --disable-download-timeout + +RUN pacman -Syu \ + bc \ + csvkit \ + vim \ + xsv \ + yq \ + --noconfirm --disable-download-timeout + +# +# Entrypoint +# + +USER root +COPY ./entrypoint.bash /entrypoint.bash +RUN chmod a+rx /entrypoint.bash +ENTRYPOINT ["/entrypoint.bash"] + +# vim: sw=2 sts=2 si ai et diff --git a/client/Dockerfiles/remote/docker-finance/finance/Dockerfile.ubuntu b/client/Dockerfiles/remote/docker-finance/finance/Dockerfile.ubuntu new file mode 100644 index 0000000..392f249 --- /dev/null +++ b/client/Dockerfiles/remote/docker-finance/finance/Dockerfile.ubuntu @@ -0,0 +1,56 @@ +# docker-finance | modern accounting for the power-user +# +# Copyright (C) 2021-2024 Aaron Fiore (Founder, Evergreen Crypto LLC) +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# +# Base dependencies +# + +# https://hub.docker.com/evergreencrypto/hledger-suite +FROM evergreencrypto/hledger-suite:latest AS hledger-suite + +# https://hub.docker.com/_/ubuntu/ +FROM ubuntu:rolling + +COPY --from=hledger-suite /usr/local/bin/hledger /usr/local/bin/hledger +COPY --from=hledger-suite /usr/local/bin/hledger-ui /usr/local/bin/hledger-ui +COPY --from=hledger-suite /usr/local/bin/hledger-web /usr/local/bin/hledger-web +COPY --from=hledger-suite /usr/local/bin/hledger-iadd /usr/local/bin/hledger-iadd +COPY --from=hledger-suite /usr/local/bin/hledger-flow /usr/local/bin/hledger-flow + +RUN apt-get update -y + +RUN apt-get install -y \ + bc \ + csvkit \ + gawk \ + vim \ + yq \ + zlib1g-dev + +RUN apt-get install -y cargo +RUN cargo install xsv --root /usr + +# +# Entrypoint +# + +USER root +COPY ./entrypoint.bash /entrypoint.bash +RUN chmod a+rx /entrypoint.bash +ENTRYPOINT ["/entrypoint.bash"] + +# vim: sw=2 sts=2 si ai et diff --git a/client/Dockerfiles/remote/docker-finance/finance/docker-compose.yml b/client/Dockerfiles/remote/docker-finance/finance/docker-compose.yml new file mode 100644 index 0000000..17523f9 --- /dev/null +++ b/client/Dockerfiles/remote/docker-finance/finance/docker-compose.yml @@ -0,0 +1,31 @@ +# docker-finance | modern accounting for the power-user +# +# Copyright (C) 2024 Aaron Fiore (Founder, Evergreen Crypto LLC) +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +services: + archlinux: + image: evergreencrypto/docker-finance:archlinux + container_name: evergreencrypto_docker-finance_archlinux + build: + dockerfile: Dockerfile.archlinux + ubuntu: + image: evergreencrypto/docker-finance:ubuntu + container_name: evergreencrypto_docker-finance_ubuntu + build: + dockerfile: Dockerfile.ubuntu +# TODO: add labels + +# vim: sw=2 sts=2 si ai et diff --git a/client/Dockerfiles/remote/docker-finance/finance/entrypoint.bash b/client/Dockerfiles/remote/docker-finance/finance/entrypoint.bash new file mode 100755 index 0000000..97189ff --- /dev/null +++ b/client/Dockerfiles/remote/docker-finance/finance/entrypoint.bash @@ -0,0 +1,41 @@ +#!/usr/bin/env bash + +# docker-finance | modern accounting for the power-user +# +# Copyright (C) 2021-2024 Aaron Fiore (Founder, Evergreen Crypto LLC) +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# +# *** WARNING: REQUIRES GENERATED CLIENT ENVIRONMENT *** +# + +if [ -z "$DOCKER_FINANCE_CONTAINER_REPO" ]; then + echo "FATAL: DOCKER_FINANCE_CONTAINER_REPO not set" >&2 + exit 1 +fi + +if [ -z "$DOCKER_FINANCE_CONTAINER_FLOW" ]; then + echo "FATAL: DOCKER_FINANCE_CONTAINER_FLOW not set" >&2 + exit 1 +fi + +# Dynamically connect hledger-flow source with end-user hledger-flow structure +# TODO: annoying, find a better way +ln -f -s "${DOCKER_FINANCE_CONTAINER_REPO}/src/hledger-flow" "${DOCKER_FINANCE_CONTAINER_FLOW}/src" + +# Keep container running +tail -f /dev/null + +exec "$@" diff --git a/client/Dockerfiles/remote/hledger-suite/Dockerfile b/client/Dockerfiles/remote/hledger-suite/Dockerfile new file mode 100644 index 0000000..dd819e8 --- /dev/null +++ b/client/Dockerfiles/remote/hledger-suite/Dockerfile @@ -0,0 +1,57 @@ +# docker-finance | modern accounting for the power-user +# +# Copyright (C) 2021-2024 Aaron Fiore (Founder, Evergreen Crypto LLC) +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +FROM haskell:latest + +RUN apt-get update -y +RUN apt-get upgrade -y + +# +# hledger-flow +# + +WORKDIR /usr/local/src +RUN git clone --depth=1 https://github.com/apauley/hledger-flow -b v0.15.0 + +WORKDIR /usr/local/src/hledger-flow +RUN stack setup +RUN stack install --install-ghc --local-bin-path=/usr/local/bin + +# +# hledger-iadd +# + +WORKDIR /usr/local/src +RUN git clone --depth=1 https://github.com/hpdeifel/hledger-iadd -b v1.3.21 + +WORKDIR /usr/local/src/hledger-iadd +RUN sed -i 's/^ - hledger-lib-1\.32\.2/ - hledger-lib-1\.33\.1@sha256\:3920c9b273ecae8be59628b6f6f93fd1b4f3cee03a89fda23b0c4b183d0577f2\,7844/g' stack.yaml +RUN stack setup +RUN stack install --resolver="lts" --install-ghc --local-bin-path=/usr/local/bin hledger-iadd + +# +# hledger / hledger-ui / hledger-web +# + +WORKDIR /usr/local/src +RUN git clone --depth=1 https://github.com/simonmichael/hledger -b 1.40 + +WORKDIR /usr/local/src/hledger +RUN stack setup +RUN stack install --resolver="lts" --install-ghc --local-bin-path=/usr/local/bin + +# vim: sw=2 sts=2 si ai et diff --git a/client/Dockerfiles/remote/hledger-suite/docker-compose.yml b/client/Dockerfiles/remote/hledger-suite/docker-compose.yml new file mode 100644 index 0000000..c208fb9 --- /dev/null +++ b/client/Dockerfiles/remote/hledger-suite/docker-compose.yml @@ -0,0 +1,24 @@ +# docker-finance | modern accounting for the power-user +# +# Copyright (C) 2024 Aaron Fiore (Founder, Evergreen Crypto LLC) +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +services: + hledger-suite: + image: evergreencrypto/hledger-suite:latest + container_name: evergreencrypto_hledger-suite + build: . + +# vim: sw=2 sts=2 si ai et diff --git a/client/src/docker/lib/internal/lib_docker.bash b/client/src/docker/lib/internal/lib_docker.bash index acc2726..d32914f 100644 --- a/client/src/docker/lib/internal/lib_docker.bash +++ b/client/src/docker/lib/internal/lib_docker.bash @@ -101,6 +101,10 @@ function lib_docker::__parse_args_build() [ -z "$global_platform" ] && lib_utils::die_fatal + # Re-seat global usage for tag options + local _global_usage + _global_usage="$(echo $global_usage | cut -d: -f1)" + case "$global_platform" in archlinux | ubuntu) local -r _usage=" @@ -116,29 +120,28 @@ function lib_docker::__parse_args_build() Build type: - type${global_arg_delim_2} - -\e[32mNotes:\e[0m - - - All builds will continue to incorporate custom Dockerfile (see \`edit help\`) - - WARNING: for 'tiny' and 'micro'; use only if you trust pre-compiled assets hosted on GitHub (Microsoft) + type${global_arg_delim_2} \e[32mExamples:\e[0m - \e[37;2m# Build normal 'default' image\e[0m - $ $global_usage type${global_arg_delim_2}default + \e[37;2m# Build the latest 'default' image, tag as 'default'\e[0m + $ $_global_usage:default type${global_arg_delim_2}default - \e[37;2m# Build a smaller 'default' image but *without* ROOT.cern (meta-analysis) support\e[0m - $ $global_usage type${global_arg_delim_2}slim + \e[37;2m# Build the latest 'default' image *without* 'root' module (ROOT.cern), tag as 'slim'\e[0m + $ $_global_usage:slim type${global_arg_delim_2}slim - \e[37;2m# Build an even smaller 'default' image with *pre-built* hledger-flow binary (but *with* ROOT.cern support)\e[0m - $ $global_usage type${global_arg_delim_2}tiny + \e[37;2m# Build the latest 'slim' image *without* 'fetch' module (remote APIs), tag as 'tiny'\e[0m + $ $_global_usage:tiny type${global_arg_delim_2}tiny - \e[37;2m# Build the smallest image possible: the 'tiny' image *without* ROOT.cern support\e[0m - $ $global_usage type${global_arg_delim_2}micro + \e[37;2m# Build the latest 'tiny' image *without* 'track' support (time, metadata), tag as 'micro'\e[0m + $ $_global_usage:micro type${global_arg_delim_2}micro - \e[37;2m# Build experimental image based on 'default' image (WARNING: large image and possibly unstable)\e[0m - $ $global_usage type${global_arg_delim_2}experimental +\e[32mNotes:\e[0m + + - Image tags are not connected to build type + (e.g., you can have an 'experimental' tag with a 'micro' image) + + - All builds will continue to append your custom Dockerfile (see \`edit help\`) " ;; dev-tools) @@ -163,8 +166,8 @@ function lib_docker::__parse_args_build() \e[32mExamples:\e[0m - \e[37;2m# Build normal (default) image\e[0m - $ $global_usage type${global_arg_delim_2}default + \e[37;2m# Build the latest 'default' image, tag as default\e[0m + $ $_global_usage:default type${global_arg_delim_2}default " ;; *) @@ -195,7 +198,7 @@ function lib_docker::__parse_args_build() # Arg: type if [ ! -z "$_arg_type" ]; then - [[ ! "$_arg_type" =~ ^default$|^slim$|^tiny$|^micro$|^experimental$ ]] \ + [[ ! "$_arg_type" =~ ^default$|^slim$|^tiny$|^micro$ ]] \ && lib_utils::die_usage "$_usage" declare -gr global_arg_type="$_arg_type" @@ -228,52 +231,67 @@ function lib_docker::__build() "$_in_file" >"$_final" || return $? # - # Append to Dockerfile according to type + # Append platform build modules according to build type # - if [[ "$global_platform" == "dev-tools" && "$global_arg_type" != "default" ]]; then - lib_utils::print_warning "'${global_arg_type}' is not supported for 'dev-tools', using 'default'" - fi + local _files=() - if [[ "$global_platform" != "dev-tools" ]]; then + case "$global_platform" in + archlinux | ubuntu) + local -r _path="${global_repo_dockerfiles}/${global_platform}" + case "$global_arg_type" in + default) + _files+=("${_path}/Dockerfile.track.in") + _files+=("${_path}/Dockerfile.fetch.in") + _files+=("${_path}/Dockerfile.root.in") + _files+=("${_path}/Dockerfile.user.in") + ;; + slim) + _files+=("${_path}/Dockerfile.track.in") + _files+=("${_path}/Dockerfile.fetch.in") + _files+=("${_path}/Dockerfile.user.in") + lib_utils::print_warning "not building module: 'root'" + ;; + tiny) + _files+=("${_path}/Dockerfile.track.in") + _files+=("${_path}/Dockerfile.user.in") + lib_utils::print_warning "not building module: 'fetch'" + lib_utils::print_warning "not building module: 'root'" + ;; + micro) + _files+=("${_path}/Dockerfile.user.in") + lib_utils::print_warning "not building module: 'track'" + lib_utils::print_warning "not building module: 'fetch'" + lib_utils::print_warning "not building module: 'root'" + ;; + *) + lib_utils::die_fatal "unsupported build" + ;; + esac + ;; + dev-tools) + case "$global_arg_type" in + default) + local -r _path="${global_repo_dockerfiles}/ubuntu" + _files+=("${_path}/Dockerfile.user.in") + ;; + *) + lib_utils::print_warning "'${global_arg_type}' is not supported for 'dev-tools', using 'default'" + ;; + esac + ;; + *) + lib_utils::die_fatal "unsupported platform" + ;; + esac - local _files=() - local _path="${global_repo_dockerfiles}/${global_platform}" - - case "$global_arg_type" in - default) - _files+=("${_path}/Dockerfile.hledger-flow.src.in") - _files+=("${_path}/Dockerfile.root.in") - ;; - slim) - _files+=("${_path}/Dockerfile.hledger-flow.src.in") - ;; - tiny) - _files+=("${_path}/Dockerfile.hledger-flow.bin.in") - _files+=("${_path}/Dockerfile.root.in") - ;; - micro) - _files+=("${_path}/Dockerfile.hledger-flow.bin.in") - ;; - experimental) - _path+="/experimental" - _files+=("${_path}/Dockerfile.hledger-flow.src.in") - _files+=("${_path}/Dockerfile.hledger.src.in") - _files+=("${_path}/Dockerfile.root.in") - ;; - *) - lib_utils::die_fatal "unsupported build" - ;; - esac - - for _file in "${_files[@]}"; do - lib_utils::print_debug "Appending '${_file}' to '${_final}'" - sed \ - -e "s:@DOCKER_FINANCE_USER@:${DOCKER_FINANCE_USER}:g" \ - "$_file" >>"$_final" || return $? - done - - fi + for _file in "${_files[@]}"; do + lib_utils::print_debug "Appending '${_file}' to '${_final}'" + sed \ + -e "s:@DOCKER_FINANCE_UID@:${DOCKER_FINANCE_UID}:g" \ + -e "s:@DOCKER_FINANCE_USER@:${DOCKER_FINANCE_USER}:g" \ + "$_file" >>"$_final" || return $? + done # # Append to Dockerfile end-user's custom Dockerfile diff --git a/client/src/docker/lib/internal/lib_gen.bash b/client/src/docker/lib/internal/lib_gen.bash index f56b0a7..4502581 100644 --- a/client/src/docker/lib/internal/lib_gen.bash +++ b/client/src/docker/lib/internal/lib_gen.bash @@ -203,7 +203,7 @@ function lib_gen::__set_client_globals() lib_utils::print_debug "global_platform_image=${global_platform_image}" # Base location of Docker-related files (.in and final out files) - global_repo_dockerfiles="${DOCKER_FINANCE_CLIENT_REPO}/client/Dockerfiles/${global_platform_image}" + global_repo_dockerfiles="${DOCKER_FINANCE_CLIENT_REPO}/client/Dockerfiles/local/${global_platform_image}" # shellcheck disable=SC2034 # used in lib_docker declare -g global_repo_dockerfiles lib_utils::print_debug "global_repo_dockerfiles=${global_repo_dockerfiles}"