From 593d586e6c732c6c421eed7134e528f322251a1e Mon Sep 17 00:00:00 2001 From: Aaron Fiore Date: Wed, 26 Jun 2024 19:50:50 -0700 Subject: [PATCH 1/6] client: lib_docker: implement `build` options --- client/src/docker/docker.bash | 8 +- .../src/docker/lib/internal/lib_docker.bash | 234 +++++++++++++++++- client/src/docker/lib/lib_docker.bash | 65 +---- 3 files changed, 236 insertions(+), 71 deletions(-) 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 } From 19cbd05a5d6ba3754be2867b26292a0eee6cb845 Mon Sep 17 00:00:00 2001 From: Aaron Fiore Date: Wed, 26 Jun 2024 22:00:56 -0700 Subject: [PATCH 2/6] client: Dockerfiles: refactor for `build` options --- .../finance/Dockerfile.archlinux.in | 91 ++++++++----------- .../Dockerfiles/finance/Dockerfile.ubuntu.in | 73 +++++++-------- .../archlinux/Dockerfile.hledger-flow.bin.in | 30 ++++++ .../archlinux/Dockerfile.hledger-flow.src.in | 41 +++++++++ .../finance/archlinux/Dockerfile.root.in | 38 ++++++++ .../ubuntu/Dockerfile.hledger-flow.bin.in | 33 +++++++ .../ubuntu/Dockerfile.hledger-flow.src.in | 40 ++++++++ .../finance/ubuntu/Dockerfile.root.in | 29 ++++++ 8 files changed, 279 insertions(+), 96 deletions(-) create mode 100644 client/Dockerfiles/finance/archlinux/Dockerfile.hledger-flow.bin.in create mode 100644 client/Dockerfiles/finance/archlinux/Dockerfile.hledger-flow.src.in create mode 100644 client/Dockerfiles/finance/archlinux/Dockerfile.root.in create mode 100644 client/Dockerfiles/finance/ubuntu/Dockerfile.hledger-flow.bin.in create mode 100644 client/Dockerfiles/finance/ubuntu/Dockerfile.hledger-flow.src.in create mode 100644 client/Dockerfiles/finance/ubuntu/Dockerfile.root.in 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..c54d273 --- /dev/null +++ b/client/Dockerfiles/finance/ubuntu/Dockerfile.root.in @@ -0,0 +1,29 @@ +# 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 + +RUN apt install -y botan libcrypto++-dev libsodium-dev googletest libbenchmark-dev + +# TODO: the .deb does not yet exist, install manually +#RUN apt install -y root + +# vim: sw=2 sts=2 si ai et From dffb3e5b1401ea45c1a81af4c3b706e4ae8d1576 Mon Sep 17 00:00:00 2001 From: Aaron Fiore Date: Thu, 27 Jun 2024 18:10:37 -0700 Subject: [PATCH 3/6] client: Dockerfiles: ubuntu: add ROOT.cern support --- .../finance/ubuntu/Dockerfile.root.in | 47 +++++++++++++++++-- 1 file changed, 44 insertions(+), 3 deletions(-) diff --git a/client/Dockerfiles/finance/ubuntu/Dockerfile.root.in b/client/Dockerfiles/finance/ubuntu/Dockerfile.root.in index c54d273..0f37ee5 100644 --- a/client/Dockerfiles/finance/ubuntu/Dockerfile.root.in +++ b/client/Dockerfiles/finance/ubuntu/Dockerfile.root.in @@ -21,9 +21,50 @@ USER root -RUN apt install -y botan libcrypto++-dev libsodium-dev googletest libbenchmark-dev +# 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 -# TODO: the .deb does not yet exist, install manually -#RUN apt install -y root +# 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 From d93d2dd17cb8d86b1a19207e0f9c3803b49d9761 Mon Sep 17 00:00:00 2001 From: Aaron Fiore Date: Thu, 27 Jun 2024 18:11:49 -0700 Subject: [PATCH 4/6] container: lib_finance: call `root` with $ROOTSYS Non-packaged pre-compiled ROOT.cern is not installed to /usr/bin --- container/src/finance/lib/lib_finance.bash | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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 $? } From 20ff0cf745ecb35bc398c9ac4c2f6373903cf4e4 Mon Sep 17 00:00:00 2001 From: Aaron Fiore Date: Thu, 27 Jun 2024 19:27:36 -0700 Subject: [PATCH 5/6] README: add note for `docker-finance build` options --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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. From 185570b52f2e64fc316d578b203f7e4417fba8cb Mon Sep 17 00:00:00 2001 From: Aaron Fiore Date: Thu, 27 Jun 2024 22:49:34 -0700 Subject: [PATCH 6/6] client: update `version` manifest to latest build --- client/docker-finance.yaml | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) 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: