From 958cf11be3be236191ad014f68da6b7c51968a41 Mon Sep 17 00:00:00 2001 From: Aaron Fiore Date: Wed, 12 Jun 2024 17:13:47 -0700 Subject: [PATCH 1/2] Dockerfiles: finance/dev-tools: remove timezone mount When running `finance` image's `import` command (but only when container's hledger-flow coinbase/coinbase-pro accounts are imported), the following error is given: ``` IsADirectoryError: [Errno 21] Is a directory: '/etc/timezone' Selector name 'id' does not exist as a named header in the given CSV data. ``` specifically, after enabling verbose printing of `csvjoin` (which is only used within these accounts), the following error is given: ``` File "/home/user/.local/share/pipx/venvs/csvkit/lib/python3.12/site-packages/babel/localtime/_unix.py", line 57, in _get_localzone with open(tzpath, 'rb') as tzfile: ^^^^^^^^^^^^^^^^^^ ``` where all errors prevent the successful import of applicable accounts. The python error appears to have been introduced in csvkit 2.0.0 and appears to be the result of an upstream decision (or bug) to not test whether /etc/timezone is a directory or a file (Arch Linux treats /etc/timezone as a directory). Fortunately, docker-finance's mounting of /etc/localtime appears to satisfy use-case requirements; so, /etc/timezone is no longer needed. Removing /etc/timezone resolves all errors. --- client/Dockerfiles/dev-tools/docker-compose.yml.dev-tools.in | 1 - client/Dockerfiles/finance/docker-compose.yml.archlinux.in | 1 - client/Dockerfiles/finance/docker-compose.yml.ubuntu.in | 1 - 3 files changed, 3 deletions(-) diff --git a/client/Dockerfiles/dev-tools/docker-compose.yml.dev-tools.in b/client/Dockerfiles/dev-tools/docker-compose.yml.dev-tools.in index dc33e82..74ef847 100644 --- a/client/Dockerfiles/dev-tools/docker-compose.yml.dev-tools.in +++ b/client/Dockerfiles/dev-tools/docker-compose.yml.dev-tools.in @@ -30,7 +30,6 @@ services: - ${DOCKER_FINANCE_CLIENT_REPO}/docker-finance.dox:${DOCKER_FINANCE_CLIENT_REPO}/docker-finance.dox - ${DOCKER_FINANCE_CLIENT_REPO}/client:${DOCKER_FINANCE_CLIENT_REPO}/client - ${DOCKER_FINANCE_CLIENT_REPO}/container:${DOCKER_FINANCE_CLIENT_REPO}/container - #- /etc/timezone:/etc/timezone:ro # TODO: will break on Arch hosts - /etc/localtime:/etc/localtime:ro environment: - DOCKER_FINANCE_CLIENT_REPO=${DOCKER_FINANCE_CLIENT_REPO} diff --git a/client/Dockerfiles/finance/docker-compose.yml.archlinux.in b/client/Dockerfiles/finance/docker-compose.yml.archlinux.in index 469bbea..ef70c86 100644 --- a/client/Dockerfiles/finance/docker-compose.yml.archlinux.in +++ b/client/Dockerfiles/finance/docker-compose.yml.archlinux.in @@ -31,7 +31,6 @@ services: - ${DOCKER_FINANCE_CLIENT_SHARED}:${DOCKER_FINANCE_CONTAINER_SHARED} # Needed for when upstream data is localtime instead of UTC # NOTE: although TZ can be used within the container, this *should* be more dynamic - - /etc/timezone:/etc/timezone:ro - /etc/localtime:/etc/localtime:ro environment: - DOCKER_FINANCE_CONTAINER_CMD=${DOCKER_FINANCE_CONTAINER_CMD} diff --git a/client/Dockerfiles/finance/docker-compose.yml.ubuntu.in b/client/Dockerfiles/finance/docker-compose.yml.ubuntu.in index 0a3e847..572ffea 100644 --- a/client/Dockerfiles/finance/docker-compose.yml.ubuntu.in +++ b/client/Dockerfiles/finance/docker-compose.yml.ubuntu.in @@ -31,7 +31,6 @@ services: - ${DOCKER_FINANCE_CLIENT_SHARED}:${DOCKER_FINANCE_CONTAINER_SHARED} # Needed for when upstream data is localtime instead of UTC # NOTE: although TZ can be used within the container, this should be more dynamic - # TODO: for Ubuntu hosts/containers, mount /etc/timezone (not needed w/ Arch) - /etc/localtime:/etc/localtime:ro environment: - DOCKER_FINANCE_CONTAINER_CMD=${DOCKER_FINANCE_CONTAINER_CMD} From 5eaf26187597d66f5172be4e3109d95d75790766 Mon Sep 17 00:00:00 2001 From: Aaron Fiore Date: Wed, 12 Jun 2024 18:22:55 -0700 Subject: [PATCH 2/2] Dockerfiles: finance/dev-tools: remove default 'ubuntu' user For Ubuntu-based images, remove upstream-added default 'ubuntu' user as it may conflict with host's given UID/GID during docker-finance build. --- client/Dockerfiles/dev-tools/Dockerfile.dev-tools.in | 5 ++++- client/Dockerfiles/finance/Dockerfile.ubuntu.in | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/client/Dockerfiles/dev-tools/Dockerfile.dev-tools.in b/client/Dockerfiles/dev-tools/Dockerfile.dev-tools.in index f1a57f5..99b6226 100644 --- a/client/Dockerfiles/dev-tools/Dockerfile.dev-tools.in +++ b/client/Dockerfiles/dev-tools/Dockerfile.dev-tools.in @@ -23,7 +23,10 @@ FROM ubuntu:rolling RUN groupadd -r wheel -# `dev-tools` user +# 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 diff --git a/client/Dockerfiles/finance/Dockerfile.ubuntu.in b/client/Dockerfiles/finance/Dockerfile.ubuntu.in index 1f7b76e..45e9aff 100644 --- a/client/Dockerfiles/finance/Dockerfile.ubuntu.in +++ b/client/Dockerfiles/finance/Dockerfile.ubuntu.in @@ -23,7 +23,10 @@ FROM ubuntu:rolling RUN groupadd -r wheel -# `finance` user +# Remove default `ubuntu` user which may conflict with host user's UID/GID (1000:1000) +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)