diff --git a/README.md b/README.md
index ee57ad5..c072cb4 100644
--- a/README.md
+++ b/README.md
@@ -289,8 +289,9 @@ Supported blockchains (independent of wallet type):
6. **Build the image and bring up container**:
```bash
- docker-finance build && docker-finance up
+ docker-finance build type=default && docker-finance up
```
+ > Note: see `docker-finance build help` for build options.
7. **You're inside!** See [How do I use it?](#how-do-i-use-it) for next steps.
diff --git a/client/Dockerfiles/finance/Dockerfile.archlinux.in b/client/Dockerfiles/finance/Dockerfile.archlinux.in
index da2dd7e..c6a75e7 100644
--- a/client/Dockerfiles/finance/Dockerfile.archlinux.in
+++ b/client/Dockerfiles/finance/Dockerfile.archlinux.in
@@ -19,88 +19,69 @@
FROM archlinux:base-devel
#
-# System
+# System preparation
#
-# `finance` user
+# Add `finance` user
RUN useradd -m -s /bin/bash @DOCKER_FINANCE_USER@ -u @DOCKER_FINANCE_UID@
-# System-level user for building (won't pollute user-level UID space)
+# 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/*
#
-# Dependencies
+# Package dependencies
#
-# Minimum requirements
RUN pacman -Syu \
- bc \
- composer \
- ghc \
git \
hledger \
hledger-iadd \
hledger-ui \
hledger-web \
python-pipx \
- stack \
vim \
visidata \
xsv \
--noconfirm --disable-download-timeout
-# ROOT.cern (and docker-finance requirements)
-RUN pacman -Syu \
- benchmark \
- botan2 \
- crypto++ \
- gtest \
- libsodium \
- root \
- --noconfirm --disable-download-timeout
-
-# PHP mandatory requirements
-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
-
-# Give access to builder
-RUN gpasswd -a builder wheel
-RUN chown root:wheel /usr/local/* && chmod g+rwx /usr/local/*
-
-# hledger-flow
-# TODO: upstream-integrate with hledger? packaged somewhere? would like to not have to clone and build here...
-USER builder
-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 test --interleaved-output --pedantic
-RUN stack install --local-bin-path=/usr/local/bin
-
-# Fetch APIs
-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
-USER root
-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
-
-# Minimum requirements (python)
USER @DOCKER_FINANCE_USER@
WORKDIR /home/@DOCKER_FINANCE_USER@
RUN pipx install shyaml
RUN pipx install csvkit
+#
+# `fetch` APIs
+#
+
+USER root
+
+RUN pacman -Syu \
+ bc \
+ composer \
+ --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
+
+#
# Superscript
+#
+
+USER @DOCKER_FINANCE_USER@
RUN echo "source \"\${DOCKER_FINANCE_CONTAINER_CONF}/shell/superscript.bash\"" | tee -a ~/.bashrc
#
diff --git a/client/Dockerfiles/finance/Dockerfile.ubuntu.in b/client/Dockerfiles/finance/Dockerfile.ubuntu.in
index 5683077..0fd38b7 100644
--- a/client/Dockerfiles/finance/Dockerfile.ubuntu.in
+++ b/client/Dockerfiles/finance/Dockerfile.ubuntu.in
@@ -18,7 +18,7 @@
FROM ubuntu:rolling
#
-# System
+# System preparation
#
RUN groupadd -r wheel
@@ -29,72 +29,63 @@ RUN userdel -r ubuntu
# Add `finance` user
RUN useradd -m -s /bin/bash @DOCKER_FINANCE_USER@ -u @DOCKER_FINANCE_UID@
-# System-level user for building (won't pollute user-level UID space)
+# 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/*
#
-# Dependencies
+# Package dependencies
#
RUN apt update -y
-# Minimum requirements
RUN apt install -y \
- bc \
- cargo \
- composer \
gawk \
- ghc \
git \
- haskell-stack \
hledger \
hledger-ui \
hledger-web \
- php \
- php-bcmath \
- php-curl \
- php-gmp \
pipx \
vim \
visidata \
zlib1g-dev
+RUN apt install -y cargo
RUN cargo install xsv --root /usr
-# Optional requirements (ROOT)
-# TODO: the .deb for root does not exist yet
-#RUN apt install -y root
-#RUN apt install -y botan libcrypto++-dev libsodium-dev googletest libbenchmark-dev
-
-# Give access to builder
-RUN gpasswd -a builder wheel
-RUN chown root:wheel /usr/local/* && chmod g+rwx /usr/local/*
-
-# hledger-flow
-# TODO: upstream-integrate with hledger? packaged somewhere? would like to not have to clone and build here...
-USER builder
-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 test --interleaved-output --pedantic
-RUN stack install --local-bin-path=/usr/local/bin
-
-# Fetch APIs
-# NOTE: Coinbase Pro has been "sunsetted"
-WORKDIR /usr/local/lib/php
-#RUN composer require mocking-magician/coinbase-pro-sdk
-RUN composer require ozdemirburak/json-csv
-RUN composer require ccxt/ccxt
-
-# Minimum requirements (python)
USER @DOCKER_FINANCE_USER@
WORKDIR /home/@DOCKER_FINANCE_USER@
RUN pipx install shyaml
RUN pipx install csvkit
+#
+# `fetch` APIs
+#
+
+USER root
+RUN apt install -y \
+ bc \
+ composer \
+ php \
+ php-bcmath \
+ php-curl \
+ php-gmp
+
+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
+
+#
# Superscript
+#
+
+USER @DOCKER_FINANCE_USER@
RUN echo "source \"\${DOCKER_FINANCE_CONTAINER_CONF}/shell/superscript.bash\"" | tee -a ~/.bash_aliases
#
diff --git a/client/Dockerfiles/finance/archlinux/Dockerfile.hledger-flow.bin.in b/client/Dockerfiles/finance/archlinux/Dockerfile.hledger-flow.bin.in
new file mode 100644
index 0000000..3f7b77e
--- /dev/null
+++ b/client/Dockerfiles/finance/archlinux/Dockerfile.hledger-flow.bin.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 .
+
+#
+# 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/archlinux/Dockerfile.hledger-flow.src.in b/client/Dockerfiles/finance/archlinux/Dockerfile.hledger-flow.src.in
new file mode 100644
index 0000000..6f988e8
--- /dev/null
+++ b/client/Dockerfiles/finance/archlinux/Dockerfile.hledger-flow.src.in
@@ -0,0 +1,41 @@
+# 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 (source)
+#
+
+USER root
+
+RUN pacman -Syu \
+ ghc \
+ stack \
+ --noconfirm --disable-download-timeout
+
+# TODO: upstream-integrate with hledger? packaged somewhere? would like to not have to clone and build here...
+USER builder
+
+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 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/finance/archlinux/Dockerfile.root.in b/client/Dockerfiles/finance/archlinux/Dockerfile.root.in
new file mode 100644
index 0000000..667a30a
--- /dev/null
+++ b/client/Dockerfiles/finance/archlinux/Dockerfile.root.in
@@ -0,0 +1,38 @@
+# 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
+RUN pacman -Syu \
+ root \
+ --noconfirm --disable-download-timeout
+
+# docker-finance
+RUN pacman -Syu \
+ benchmark \
+ botan2 \
+ crypto++ \
+ gtest \
+ libsodium \
+ --noconfirm --disable-download-timeout
+
+# 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
new file mode 100644
index 0000000..45a03e6
--- /dev/null
+++ b/client/Dockerfiles/finance/ubuntu/Dockerfile.hledger-flow.bin.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 .
+
+#
+# hledger-flow (binary)
+#
+
+USER root
+RUN apt 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/Dockerfile.hledger-flow.src.in b/client/Dockerfiles/finance/ubuntu/Dockerfile.hledger-flow.src.in
new file mode 100644
index 0000000..e8ca181
--- /dev/null
+++ b/client/Dockerfiles/finance/ubuntu/Dockerfile.hledger-flow.src.in
@@ -0,0 +1,40 @@
+# 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 (source)
+#
+
+USER root
+
+RUN apt install -y \
+ ghc \
+ haskell-stack
+
+# TODO: upstream-integrate with hledger? packaged somewhere? would like to not have to clone and build here...
+USER builder
+
+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 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/finance/ubuntu/Dockerfile.root.in b/client/Dockerfiles/finance/ubuntu/Dockerfile.root.in
new file mode 100644
index 0000000..0f37ee5
--- /dev/null
+++ b/client/Dockerfiles/finance/ubuntu/Dockerfile.root.in
@@ -0,0 +1,70 @@
+# 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 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 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
+RUN apt install -y \
+ botan \
+ googletest \
+ libbenchmark-dev \
+ libcrypto++-dev \
+ libsodium-dev
+
+# vim: sw=2 sts=2 si ai et
diff --git a/client/docker-finance.yaml b/client/docker-finance.yaml
index ee929f5..051f22d 100644
--- a/client/docker-finance.yaml
+++ b/client/docker-finance.yaml
@@ -38,7 +38,6 @@ container:
base:
packages:
- "bc"
- - "composer"
- "ghc"
- "git"
- "hledger-iadd"
@@ -56,6 +55,7 @@ container:
- "shyaml --version"
fetch:
packages:
+ - "composer"
commands:
- "php --version | head -n1"
- "cat /usr/local/lib/php/composer.json"
@@ -81,7 +81,6 @@ container:
packages:
- "bc"
- "cargo"
- - "composer"
- "ghc"
- "git"
- "haskell-stack"
@@ -99,15 +98,29 @@ container:
- "shyaml --version"
fetch:
packages:
+ - "composer"
commands:
- "php --version | head -n1"
- "cat /usr/local/lib/php/composer.json"
+ root:
+ packages:
+ - "botan"
+ - "googletest"
+ - "libbenchmark-dev"
+ - "libcrypto++-dev"
+ - "libsodium-dev"
+ commands:
+ - "root --version"
dev-tools:
system:
packages:
- "coreutils"
- "bash"
commands:
+ base:
+ packages:
+ - "composer"
+ commands:
linters:
packages:
# Bash
@@ -118,9 +131,8 @@ container:
- "clang-format"
- "cppcheck"
- "cpplint"
- # PHP
- - "composer"
commands:
+ # PHP
- "php-cs-fixer --version --no-ansi"
- "phpstan --version --no-ansi"
fetch:
diff --git a/client/src/docker/docker.bash b/client/src/docker/docker.bash
index f55eb04..0d49e56 100755
--- a/client/src/docker/docker.bash
+++ b/client/src/docker/docker.bash
@@ -92,8 +92,8 @@ function main()
\e[37;2m# Setup an alias for latest \e[0m
$ alias docker-finance=\"$0 archlinux${global_arg_delim_1}${USER}:latest\"
- \e[37;2m# Generate environment and build image\e[0m
- $ docker-finance gen && docker-finance build
+ \e[37;2m# Generate environment and build default image\e[0m
+ $ docker-finance gen && docker-finance build type=default
\e[37;2m# Bring up container, open shell (type 'exit' to leave)\e[0m
$ docker-finance up
@@ -124,8 +124,8 @@ function main()
\e[37;2m# Setup an alias for dev-tools\e[0m
$ alias docker-finance_dev-tools=\"$0 dev-tools${global_arg_delim_1}${USER}:latest\"
- \e[37;2m# Generate environment and build image\e[0m
- $ docker-finance_dev-tools gen && docker-finance_dev-tools build
+ \e[37;2m# Generate environment and build default image\e[0m
+ $ docker-finance_dev-tools gen && docker-finance_dev-tools build type=default
\e[37;2m# Spawn a container with given command (removed after command finishes)\e[0m
$ docker-finance_dev-tools run 'shellcheck --version'
diff --git a/client/src/docker/lib/internal/lib_docker.bash b/client/src/docker/lib/internal/lib_docker.bash
index 683ed42..d232150 100644
--- a/client/src/docker/lib/internal/lib_docker.bash
+++ b/client/src/docker/lib/internal/lib_docker.bash
@@ -46,10 +46,44 @@ if [ -z "$EDITOR" ]; then
fi
fi
-#
-# `docker compose`
-#
+# Remaining "constructor" implementation
+function lib_docker::__docker()
+{
+ # Docker-related files
+ [ -z "$DOCKER_FINANCE_CLIENT_REPO" ] && lib_utils::die_fatal
+ declare -g global_repo_dockerfiles="${DOCKER_FINANCE_CLIENT_REPO}/client/Dockerfiles/"
+ case "$global_platform" in
+ archlinux | ubuntu)
+ global_repo_dockerfiles+="finance"
+ ;;
+ dev-tools)
+ global_repo_dockerfiles+="dev-tools"
+ ;;
+ *)
+ lib_utils::die_fatal "platform was not previously checked"
+ ;;
+ esac
+
+ #
+ # Generate docker-compose.yml
+ #
+
+ [ -z "$global_env_file" ] && lib_utils::die_fatal
+ [ -z "$global_shell_file" ] && lib_utils::die_fatal
+ [ -z "$global_repo_dockerfiles" ] && lib_utils::die_fatal
+
+ local _path="${global_repo_dockerfiles}/docker-compose.yml"
+ lib_utils::print_debug "Generating '${_path}'"
+
+ sed \
+ -e "s|@DOCKER_FINANCE_IMAGE@|${global_image}:${global_tag}|g" \
+ -e "s|@DOCKER_FINANCE_CONTAINER@|${global_container}|g" \
+ -e "s|@DOCKER_FINANCE_NETWORK@|${global_network}|g" \
+ "${_path}.${global_platform}.in" >"$_path" || return $?
+}
+
+# `docker compose` wrapper
function lib_docker::__docker_compose()
{
[ -z "$global_env_file" ] && lib_utils::die_fatal
@@ -66,7 +100,199 @@ function lib_docker::__docker_compose()
function lib_docker::__build()
{
- time lib_docker::__docker_compose build --pull docker-finance "$@"
+ [ -z "$global_usage" ] && lib_utils::die_fatal
+ [ -z "$global_arg_delim_1" ] && lib_utils::die_fatal
+ [ -z "$global_arg_delim_2" ] && lib_utils::die_fatal
+ [ -z "$global_arg_delim_3" ] && lib_utils::die_fatal
+
+ [ -z "$global_platform" ] && lib_utils::die_fatal
+
+ case "$global_platform" in
+ archlinux | ubuntu)
+ local -r _usage="
+\e[32mDescription:\e[0m
+
+ Build 'finance' image of given type
+
+\e[32mUsage:\e[0m
+
+ $ $global_usage type${global_arg_delim_2}
+
+\e[32mArguments:\e[0m
+
+ 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)
+
+\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 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 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 smallest image possible: the 'tiny' image *without* ROOT.cern support\e[0m
+ $ $global_usage type${global_arg_delim_2}micro
+"
+ ;;
+ dev-tools)
+ local -r _usage="
+\e[32mDescription:\e[0m
+
+ Build 'dev-tools' image of given type
+
+\e[32mUsage:\e[0m
+
+ $ $global_usage type${global_arg_delim_2}
+
+\e[32mArguments:\e[0m
+
+ Build type:
+
+ type${global_arg_delim_2}
+
+\e[32mNotes:\e[0m
+
+ - All builds will continue to incorporate custom Dockerfile (see \`edit help\`)
+
+\e[32mExamples:\e[0m
+
+ \e[37;2m# Build normal (default) image\e[0m
+ $ $global_usage type${global_arg_delim_2}default
+"
+ ;;
+ *)
+ lib_utils::die_fatal "unsupported platform"
+ ;;
+ esac
+
+ #
+ # Ensure supported arguments
+ #
+
+ [ $# -eq 0 ] && lib_utils::die_usage "$_usage"
+
+ for _arg in "$@"; do
+ [[ ! "$_arg" =~ ^type[s]?${global_arg_delim_2} ]] \
+ && lib_utils::die_usage "$_usage"
+ done
+
+ #
+ # Parse arguments before testing
+ #
+
+ # Parse key for value
+ for _arg in "$@"; do
+
+ local _key="${_arg%${global_arg_delim_2}*}"
+ local _len="$((${#_key} + 1))"
+
+ if [[ "$_key" =~ ^type[s]?$ ]]; then
+ local _arg_type="${_arg:${_len}}"
+ [ -z "$_arg_type" ] && lib_utils::die_usage "$_usage"
+ fi
+ done
+
+ #
+ # Test argument values, set globals
+ #
+
+ IFS="$global_arg_delim_3"
+
+ # Arg: type
+ if [ ! -z "$_arg_type" ]; then
+ [[ ! "$_arg_type" =~ ^default$|^slim$|^tiny$|^micro$ ]] \
+ && lib_utils::die_usage "$_usage"
+ fi
+
+ # TODO: factor out parser
+
+ #
+ # Generate Dockerfile
+ #
+
+ [ -z "$DOCKER_FINANCE_UID" ] && lib_utils::die_fatal
+ [ -z "$DOCKER_FINANCE_GID" ] && lib_utils::die_fatal
+ [ -z "$DOCKER_FINANCE_USER" ] && lib_utils::die_fatal
+
+ [ -z "$global_repo_dockerfiles" ] && lib_utils::die_fatal
+
+ local _final="${global_repo_dockerfiles}/Dockerfile"
+ local _in_file="${global_repo_dockerfiles}/Dockerfile.${global_platform}.in"
+
+ lib_utils::print_debug "Generating '${_final}' from '${_in_file}"
+
+ sed \
+ -e "s:@DOCKER_FINANCE_UID@:${DOCKER_FINANCE_UID}:g" \
+ -e "s:@DOCKER_FINANCE_GID@:${DOCKER_FINANCE_GID}:g" \
+ -e "s:@DOCKER_FINANCE_USER@:${DOCKER_FINANCE_USER}:g" \
+ "$_in_file" >"$_final" || return $?
+
+ #
+ # Append to Dockerfile according to type
+ #
+
+ if [[ "$global_platform" == "dev-tools" && "$_arg_type" != "default" ]]; then
+ lib_utils::print_warning "'${_arg_type}' is not supported for 'dev-tools', using 'default'"
+ fi
+
+ if [[ "$global_platform" != "dev-tools" ]]; then
+
+ local _in_files=()
+
+ case "$_arg_type" in
+ default | slim)
+ _in_files+=("hledger-flow.src")
+ [[ "$_arg_type" == "default" ]] && _in_files+=("root")
+ ;;
+ tiny | micro)
+ _in_files+=("hledger-flow.bin")
+ [[ "$_arg_type" == "tiny" ]] && _in_files+=("root")
+ ;;
+ *)
+ lib_utils::die_fatal "unsupported build"
+ ;;
+ esac
+
+ for _file in "${_in_files[@]}"; do
+ local _path="${global_repo_dockerfiles}/${global_platform}/Dockerfile.${_file}.in"
+ lib_utils::print_debug "Appending '${_path}' to '${_final}'"
+ sed \
+ -e "s:@DOCKER_FINANCE_USER@:${DOCKER_FINANCE_USER}:g" \
+ "$_path" >>"$_final" || return $?
+ done
+
+ fi
+
+ #
+ # Append to Dockerfile end-user's custom Dockerfile
+ #
+
+ [ -z "$global_custom_dockerfile" ] && lib_utils::die_fatal
+
+ if [[ ! -f "$global_custom_dockerfile" ]]; then
+ lib_utils::print_debug "'${global_custom_dockerfile}' not found, skipping"
+ else
+ lib_utils::print_debug "Appending '${global_custom_dockerfile}' to '${_final}'"
+ sed \
+ -e "s:@DOCKER_FINANCE_USER@:${DOCKER_FINANCE_USER}:g" \
+ "$global_custom_dockerfile" >>"$_final" || return $?
+ fi
+
+ #
+ # Execute
+ #
+
+ time lib_docker::__docker_compose build --pull docker-finance
}
function lib_docker::__up()
diff --git a/client/src/docker/lib/lib_docker.bash b/client/src/docker/lib/lib_docker.bash
index 52616bd..ad91bd7 100644
--- a/client/src/docker/lib/lib_docker.bash
+++ b/client/src/docker/lib/lib_docker.bash
@@ -109,69 +109,8 @@ function lib_docker::docker()
# Setup remaining client/container globals
lib_gen::gen || return $?
- # TODO: all following docker related should be internal
-
- # Docker-related files
- [ -z "$global_repo_client" ] && lib_utils::die_fatal
- declare -g global_repo_dockerfiles="${global_repo_client}/Dockerfiles/"
-
- case "$global_platform" in
- archlinux | ubuntu)
- global_repo_dockerfiles+="finance"
- ;;
- dev-tools)
- global_repo_dockerfiles+="dev-tools"
- ;;
- *)
- lib_utils::die_fatal "platform was not previously checked"
- ;;
- esac
-
- #
- # docker-compose
- #
-
- [ -z "$global_env_file" ] && lib_utils::die_fatal
- [ -z "$global_shell_file" ] && lib_utils::die_fatal
-
- local _path="${global_repo_dockerfiles}/docker-compose.yml"
- lib_utils::print_debug "Generating '${_path}'"
-
- sed \
- -e "s|@DOCKER_FINANCE_IMAGE@|${global_image}:${global_tag}|g" \
- -e "s|@DOCKER_FINANCE_CONTAINER@|${global_container}|g" \
- -e "s|@DOCKER_FINANCE_NETWORK@|${global_network}|g" \
- "${_path}.${global_platform}.in" >"$_path" || return $?
-
- #
- # Dockerfile
- #
-
- [ -z "$DOCKER_FINANCE_UID" ] && lib_utils::die_fatal
- [ -z "$DOCKER_FINANCE_GID" ] && lib_utils::die_fatal
- [ -z "$DOCKER_FINANCE_USER" ] && lib_utils::die_fatal
-
- local _path="${global_repo_dockerfiles}/Dockerfile"
- lib_utils::print_debug "Generating '${_path}'"
-
- sed \
- -e "s:@DOCKER_FINANCE_UID@:${DOCKER_FINANCE_UID}:g" \
- -e "s:@DOCKER_FINANCE_GID@:${DOCKER_FINANCE_GID}:g" \
- -e "s:@DOCKER_FINANCE_USER@:${DOCKER_FINANCE_USER}:g" \
- "${_path}.${global_platform}.in" >"$_path" || return $?
-
- # Append end-user's custom Dockerfile to final Dockerfile
- [ -z "$global_custom_dockerfile" ] && lib_utils::die_fatal
-
- if [[ ! -f "$global_custom_dockerfile" ]]; then
- lib_utils::print_debug "'${global_custom_dockerfile}' not found, skipping"
- return 0
- fi
-
- lib_utils::print_debug "Appending '${global_custom_dockerfile}' to '${_path}'"
- sed \
- -e "s:@DOCKER_FINANCE_USER@:${DOCKER_FINANCE_USER}:g" \
- "$global_custom_dockerfile" >>"$_path" || return $?
+ # Remaining "constructor" implementation
+ lib_docker::__docker || return $?
return 0
}
diff --git a/container/src/finance/lib/lib_finance.bash b/container/src/finance/lib/lib_finance.bash
index b144370..022afbc 100644
--- a/container/src/finance/lib/lib_finance.bash
+++ b/container/src/finance/lib/lib_finance.bash
@@ -206,9 +206,11 @@ function lib_finance::reports()
function lib_finance::root()
{
+ [ -z "$ROOTSYS" ] && lib_utils::die_fatal
+
# NOTE: will automatically load rootlogon.C
pushd "${DOCKER_FINANCE_CONTAINER_REPO}/src/root/macro" 1>/dev/null \
- && /usr/bin/root -l
+ && "${ROOTSYS}"/bin/root -l
lib_utils::catch $?
}