From 50a98d960a59b30aba359b324ff0126b2c856b4b Mon Sep 17 00:00:00 2001 From: Felddy Date: Fri, 24 May 2024 19:11:53 -0400 Subject: [PATCH 01/29] Bump _version.py from 4.10.2 to 5.0.2 --- src/_version.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/_version.py b/src/_version.py index cf44e2fd..3a223dde 100644 --- a/src/_version.py +++ b/src/_version.py @@ -1 +1 @@ -__version__ = "4.10.2" +__version__ = "5.0.2" From 938ea701bf8e7faa9b21727827d2dd6f8eecf1ec Mon Sep 17 00:00:00 2001 From: Felddy Date: Fri, 24 May 2024 19:12:38 -0400 Subject: [PATCH 02/29] Bump Python version requirement to 3.12 --- setup.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/setup.py b/setup.py index 4ca2ba48..1ce285f7 100644 --- a/setup.py +++ b/setup.py @@ -53,11 +53,7 @@ def package_vars(version_file): "Natural Language :: English", "Operating System :: OS Independent", "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.6", - "Programming Language :: Python :: 3.7", - "Programming Language :: Python :: 3.8", - "Programming Language :: Python :: 3.9", - "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.12", "Topic :: Scientific/Engineering :: Atmospheric Science", ], python_requires=">=3.6", From 24c7cdc6ba81bb978e64fd90be123e1db694d633 Mon Sep 17 00:00:00 2001 From: Felddy Date: Fri, 24 May 2024 19:13:21 -0400 Subject: [PATCH 03/29] Remove paho-mqtt This should be installed via an extension going forward --- setup.py | 1 - 1 file changed, 1 deletion(-) diff --git a/setup.py b/setup.py index 1ce285f7..758f9640 100644 --- a/setup.py +++ b/setup.py @@ -64,7 +64,6 @@ def package_vars(version_file): py_modules=[splitext(basename(path))[0] for path in glob("src/*.py")], install_requires=[ "configobj == 5.0.9", - "paho-mqtt == 2.1.0", "pyserial == 3.5", "pyusb == 1.2.1", "semver == 3.0.2", From 86b85ffc81b3f9d65ecf95a9b3263a14d2d0cf3d Mon Sep 17 00:00:00 2001 From: Felddy Date: Fri, 24 May 2024 19:13:36 -0400 Subject: [PATCH 04/29] Update setup.py with weewx dependency --- setup.py | 1 + 1 file changed, 1 insertion(+) diff --git a/setup.py b/setup.py index 758f9640..e91cdcd7 100644 --- a/setup.py +++ b/setup.py @@ -68,6 +68,7 @@ def package_vars(version_file): "pyusb == 1.2.1", "semver == 3.0.2", "setuptools == 75.6.0", + "weewx == 5.1.0", "wheel == 0.45.1", ], extras_require={ From 0154010c61eef5397189447e3ec7a0d4f2d05a91 Mon Sep 17 00:00:00 2001 From: Felddy Date: Fri, 24 May 2024 19:14:40 -0400 Subject: [PATCH 05/29] Update Dockerfile to support new availability of weewx in pip --- Dockerfile | 22 +++------------------- 1 file changed, 3 insertions(+), 19 deletions(-) diff --git a/Dockerfile b/Dockerfile index 820d7bab..9cfdf21b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -17,9 +17,6 @@ RUN apt-get update && apt-get install -y clang lld ARG TARGETPLATFORM RUN xx-apt install -y libc6-dev -# RUN apk --no-cache add cargo gcc libffi-dev make musl-dev openssl-dev python3-dev tar -RUN apt-get install -y wget - WORKDIR /tmp RUN \ --mount=type=cache,mode=0777,target=/var/cache/apt \ @@ -30,18 +27,9 @@ pip install --upgrade virtualenv virtualenv /opt/venv EOF -COPY src/hashes README.md requirements.txt setup.py ./ +COPY README.md requirements.txt setup.py ./ COPY src/_version.py ./src/_version.py -# Download sources and verify hashes -RUN wget -O "${ARCHIVE}" "https://weewx.com/downloads/released_versions/${ARCHIVE}" -RUN wget -O weewx-mqtt.zip https://github.com/matthewwall/weewx-mqtt/archive/master.zip -RUN wget -O weewx-interceptor.zip https://github.com/matthewwall/weewx-interceptor/archive/master.zip -RUN sha256sum -c < hashes - -# WeeWX setup -RUN tar --extract --gunzip --directory /root --strip-components=1 --file "${ARCHIVE}" - # Python setup RUN python -m venv /opt/venv ENV PATH="/opt/venv/bin:$PATH" @@ -49,8 +37,6 @@ RUN pip install --no-cache --requirement requirements.txt WORKDIR /root -# RUN bin/wee_extension --install /tmp/weewx-mqtt.zip -# RUN bin/wee_extension --install /tmp/weewx-interceptor.zip COPY src/entrypoint.sh src/_version.py ./ FROM python:${PYTHON_VERSION}-slim AS final-stage @@ -76,12 +62,10 @@ WORKDIR ${WEEWX_HOME} COPY --from=build-stage /opt/venv /opt/venv COPY --from=build-stage /root ${WEEWX_HOME} -RUN mkdir /data && \ - cp weewx.conf /data && \ - chown -R weewx:weewx ${WEEWX_HOME} +RUN mkdir /data \ + && chown -R weewx:weewx /data VOLUME ["/data"] ENV PATH="/opt/venv/bin:$PATH" ENTRYPOINT ["./entrypoint.sh"] -CMD ["/data/weewx.conf"] From 9550c7cec818f971d97674221ed736c906513042 Mon Sep 17 00:00:00 2001 From: Felddy Date: Fri, 24 May 2024 19:16:57 -0400 Subject: [PATCH 06/29] Clean up docker-compose file --- docker-compose.yml | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 31763625..28542a64 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,17 +1,12 @@ --- -version: "3.8" +name: "weewx" volumes: data: services: weewx: - build: - context: . - dockerfile: Dockerfile - image: felddy/weewx:4.8.0 - init: true - restart: "no" + image: felddy/weewx:5.0.2 # devices: # - "/dev/ttyUSB0:/dev/ttyUSB0" volumes: From dbb0d0fff35f9c08b82667e64859fed4aa1bb35d Mon Sep 17 00:00:00 2001 From: Felddy Date: Fri, 24 May 2024 19:19:28 -0400 Subject: [PATCH 07/29] Convert entrypoint to support weewx v5 --- src/entrypoint.sh | 49 ++++++++++++++--------------------------------- 1 file changed, 14 insertions(+), 35 deletions(-) diff --git a/src/entrypoint.sh b/src/entrypoint.sh index 1fe7c278..72f96c4b 100755 --- a/src/entrypoint.sh +++ b/src/entrypoint.sh @@ -4,11 +4,12 @@ set -o nounset set -o errexit set -o pipefail -CONF_FILE="/data/weewx.conf" +WEEWX_ROOT="/data" +CONF_FILE="${WEEWX_ROOT}/weewx.conf" # echo version before starting syslog so we don't confound our tests -if [ "$1" = "--version" ]; then - gosu weewx:weewx ./bin/weewxd --version +if [ $# -gt 0 ] && [ "$1" = "--version" ]; then + gosu weewx:weewx weewxd --version exit 0 fi @@ -25,39 +26,17 @@ if [ "$(id -u)" = 0 ]; then fi fi -copy_default_config() { - # create a default configuration on the data volume - echo "Creating a configration file on the container data volume." - cp weewx.conf "${CONF_FILE}" - echo "The default configuration has been copied." - # Change the default location of the SQLITE database to the volume - echo "Setting SQLITE_ROOT to the container volume." - sed "s/SQLITE_ROOT =.*/SQLITE_ROOT = \/data/g" "${CONF_FILE}" > /tmp/weewx.conf - mv /tmp/weewx.conf "${CONF_FILE}" -} - -if [ "$1" = "--gen-test-config" ]; then - copy_default_config - echo "Generating a test configuration." - ./bin/wee_config --reconfigure --no-prompt "${CONF_FILE}" - exit 0 +if [ ! -f "${CONF_FILE}" ]; then + weectl station create --no-prompt ${WEEWX_ROOT} + echo "A new set of configurations was created." + echo "Please edit ${CONF_FILE} and restart the container." fi -if [ "$1" = "--shell" ]; then - /bin/sh - exit $? -fi +# if we have any parameters we'll send them to weectl -if [ "$1" = "--upgrade" ]; then - ./bin/wee_config --upgrade --no-prompt --dist-config weewx.conf "${CONF_FILE}" - exit $? -fi - -if [ ! -f "${CONF_FILE}" ]; then - copy_default_config - echo "Running configuration tool." - ./bin/wee_config --reconfigure "${CONF_FILE}" - exit 1 +if [ $# -gt 0 ]; then + weectl "$@" --config ${CONF_FILE} + exit 0 +else + weewxd --config ${CONF_FILE} fi - -./bin/weewxd "$@" From 4bbdff1ff72724fcf2c5bc23a6a75c5cfda05bb9 Mon Sep 17 00:00:00 2001 From: Felddy Date: Sat, 22 Jun 2024 18:22:57 -0400 Subject: [PATCH 08/29] Bump WEEWX_VERSION from 4.10.2 to 5.0.2 --- Dockerfile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 9cfdf21b..335aee86 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,7 +2,7 @@ ARG PYTHON_VERSION=3.13.0 ARG WEEWX_UID=421 -ARG WEEWX_VERSION=4.10.2 +ARG WEEWX_VERSION=5.0.2 ARG WEEWX_HOME="/home/weewx" FROM --platform=$BUILDPLATFORM tonistiigi/xx AS xx @@ -44,6 +44,7 @@ FROM python:${PYTHON_VERSION}-slim AS final-stage ARG TARGETPLATFORM ARG WEEWX_HOME ARG WEEWX_UID +ARG WEEWX_VERSION # For a list of pre-defined annotation keys and value types see: # https://github.com/opencontainers/image-spec/blob/master/annotations.md From e5ceab29ce164fc4372f95fb9915c7cfc186c1e6 Mon Sep 17 00:00:00 2001 From: Felddy Date: Sat, 23 Nov 2024 16:03:54 -0500 Subject: [PATCH 09/29] Bump WeeWX version to 5.1 --- Dockerfile | 5 ----- README.md | 4 ++-- docker-compose.yml | 2 +- src/_version.py | 2 +- 4 files changed, 4 insertions(+), 9 deletions(-) diff --git a/Dockerfile b/Dockerfile index 335aee86..c2ce7018 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,16 +2,12 @@ ARG PYTHON_VERSION=3.13.0 ARG WEEWX_UID=421 -ARG WEEWX_VERSION=5.0.2 ARG WEEWX_HOME="/home/weewx" FROM --platform=$BUILDPLATFORM tonistiigi/xx AS xx FROM --platform=$BUILDPLATFORM python:${PYTHON_VERSION} AS build-stage -ARG WEEWX_VERSION -ARG ARCHIVE="weewx-${WEEWX_VERSION}.tar.gz" - COPY --from=xx / / RUN apt-get update && apt-get install -y clang lld ARG TARGETPLATFORM @@ -44,7 +40,6 @@ FROM python:${PYTHON_VERSION}-slim AS final-stage ARG TARGETPLATFORM ARG WEEWX_HOME ARG WEEWX_UID -ARG WEEWX_VERSION # For a list of pre-defined annotation keys and value types see: # https://github.com/opencontainers/image-spec/blob/master/annotations.md diff --git a/README.md b/README.md index ebd21355..ac062baf 100644 --- a/README.md +++ b/README.md @@ -136,7 +136,7 @@ Build the image locally using this git repository as the [build context](https:/ ```console docker build \ - --tag felddy/weewx:4.8.0 \ + --tag felddy/weewx:5.1.0 \ https://github.com/felddy/weewx-docker.git#develop ``` @@ -160,7 +160,7 @@ Docker: docker buildx build \ --platform linux/amd64 \ --output type=docker \ - --tag felddy/weewx:4.8.0 . + --tag felddy/weewx:5.1.0 . ``` ## Debugging ## diff --git a/docker-compose.yml b/docker-compose.yml index 28542a64..8169d374 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -6,7 +6,7 @@ volumes: services: weewx: - image: felddy/weewx:5.0.2 + image: felddy/weewx:5.1.0 # devices: # - "/dev/ttyUSB0:/dev/ttyUSB0" volumes: diff --git a/src/_version.py b/src/_version.py index 3a223dde..0d72820f 100644 --- a/src/_version.py +++ b/src/_version.py @@ -1 +1 @@ -__version__ = "5.0.2" +__version__ = "5.1.0" From 159f8a7b0c8e29ddaae6cc389e6e8e15eadf00f6 Mon Sep 17 00:00:00 2001 From: Felddy Date: Sat, 23 Nov 2024 16:23:29 -0500 Subject: [PATCH 10/29] Update example docker compose config --- README.md | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index ac062baf..bfff3425 100644 --- a/README.md +++ b/README.md @@ -40,16 +40,14 @@ Modify any paths or devices as needed: ```yaml --- -version: "3.8" +name: "weewx" volumes: data: services: weewx: - image: felddy/weewx - init: true - restart: "yes" + image: felddy/weewx:5.1.0 volumes: - type: bind source: ./data From 3694342c3f210137c1e1a9ea30ce85ee86288e1d Mon Sep 17 00:00:00 2001 From: Felddy Date: Sat, 23 Nov 2024 16:24:24 -0500 Subject: [PATCH 11/29] Document how to add extensions --- README.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/README.md b/README.md index bfff3425..689c9992 100644 --- a/README.md +++ b/README.md @@ -128,6 +128,14 @@ services: | `WEEWX_UID` | `uid` the daemon will be run under | `weewx` | | `WEEWX_GID` | `gid` the deamon will be run under | `weewx` | +## Installing WeeWX Extensions ## + +```console +docker compose run weewx \ + extension install \ + https://github.com/matthewwall/weewx-windy/archive/master.zip +``` + ## Building from source ## Build the image locally using this git repository as the [build context](https://docs.docker.com/engine/reference/commandline/build/#git-repositories): From 9db3a96f79e076426e8101987d595db2e277204a Mon Sep 17 00:00:00 2001 From: Felddy Date: Sat, 23 Nov 2024 16:27:06 -0500 Subject: [PATCH 12/29] Update Python version requirement to 3.13 --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index e91cdcd7..b4510856 100644 --- a/setup.py +++ b/setup.py @@ -53,7 +53,7 @@ def package_vars(version_file): "Natural Language :: English", "Operating System :: OS Independent", "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: 3.13", "Topic :: Scientific/Engineering :: Atmospheric Science", ], python_requires=">=3.6", From 75ae335137cbc573e815020facddaef15e4af6d1 Mon Sep 17 00:00:00 2001 From: Felddy Date: Mon, 25 Nov 2024 17:24:33 -0500 Subject: [PATCH 13/29] Add missing version declaration --- .github/dependabot.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 56ca480e..c81863d3 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -5,6 +5,7 @@ # these updates when the pull request(s) in the appropriate skeleton are merged # and Lineage processes these changes. +version: 2 updates: - directory: / package-ecosystem: docker From 602276b067d7052f3a1534c8610ceab6f44bd756 Mon Sep 17 00:00:00 2001 From: Felddy Date: Mon, 25 Nov 2024 17:53:53 -0500 Subject: [PATCH 14/29] Add PYTHONPATH to data volume --- Dockerfile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Dockerfile b/Dockerfile index c2ce7018..c0fee657 100644 --- a/Dockerfile +++ b/Dockerfile @@ -64,4 +64,6 @@ RUN mkdir /data \ VOLUME ["/data"] ENV PATH="/opt/venv/bin:$PATH" +ENV PIP_TARGET="/data/lib/python/site-packages" +ENV PYTHONPATH="/data/lib/python/site-packages" ENTRYPOINT ["./entrypoint.sh"] From dd251295789e39aada70842539b70c063b8ca8c5 Mon Sep 17 00:00:00 2001 From: Felddy Date: Mon, 25 Nov 2024 17:54:18 -0500 Subject: [PATCH 15/29] Remove unused file from v4 implementation --- src/hashes | 3 --- 1 file changed, 3 deletions(-) delete mode 100644 src/hashes diff --git a/src/hashes b/src/hashes deleted file mode 100644 index 0a389c97..00000000 --- a/src/hashes +++ /dev/null @@ -1,3 +0,0 @@ -d7f445560ac5be6424d4b81995109dcf05bd564a3b2fce201bf58ab46dda43fc weewx-4.10.2.tar.gz -89f1fff4e86582befb8190e823537df0c8b89fd962a3f7ece72f33998c769504 weewx-mqtt.zip -9bf17503313023860fd30f49b4146ffb6cd5186e81ead257b1bb8571158434a7 weewx-interceptor.zip From 5f6561d922bdfa25f91648c01489754a4b37c330 Mon Sep 17 00:00:00 2001 From: Felddy Date: Mon, 25 Nov 2024 17:55:45 -0500 Subject: [PATCH 16/29] Update documentation with new procedures --- README.md | 35 +++++++++++++++++++++-------------- 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index 689c9992..903e04b5 100644 --- a/README.md +++ b/README.md @@ -13,11 +13,6 @@ This docker container can be used to quickly get a [WeeWX](http://weewx.com) instance up and running. -This container has the following WeeWX extensions pre-installed: - -- [interceptor](https://github.com/matthewwall/weewx-interceptor) -- [mqtt](https://github.com/weewx/weewx/wiki/mqtt) - ## Running ## ### Running with Docker ### @@ -100,7 +95,7 @@ services: 1. Update your configuration file (a backup will be created): ```console - docker compose run weewx --upgrade + docker compose run weewx station upgrade ``` 1. Read through the new configuration and verify. @@ -114,6 +109,26 @@ services: docker compose up -d ``` +## Installing WeeWX Extensions ## + +```console +docker compose run weewx \ + extension install \ + https://github.com/matthewwall/weewx-windy/archive/master.zip +``` + +```console +docker compose run weewx \ + extension install \ + https://github.com/matthewwall/weewx-mqtt/archive/master.zip +``` + +## Installing Additional Python Packages ## + +```console +docker compose run --entrypoint pip weewx install paho_mqtt +``` + ## Volumes ## | Mount point | Purpose | @@ -128,14 +143,6 @@ services: | `WEEWX_UID` | `uid` the daemon will be run under | `weewx` | | `WEEWX_GID` | `gid` the deamon will be run under | `weewx` | -## Installing WeeWX Extensions ## - -```console -docker compose run weewx \ - extension install \ - https://github.com/matthewwall/weewx-windy/archive/master.zip -``` - ## Building from source ## Build the image locally using this git repository as the [build context](https://docs.docker.com/engine/reference/commandline/build/#git-repositories): From 55c0fa4d117e86f98c8ded1e939adea1f469994e Mon Sep 17 00:00:00 2001 From: Felddy Date: Mon, 25 Nov 2024 17:56:13 -0500 Subject: [PATCH 17/29] Remove duplicate diagnostics job --- .github/workflows/codeql-analysis.yml | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 25c47ea9..56885331 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -27,27 +27,8 @@ permissions: contents: read jobs: - diagnostics: - name: Run diagnostics - runs-on: ubuntu-latest - steps: - # Note that a duplicate of this step must be added at the top of - # each job. - - id: harden-runner - name: Harden the runner - uses: step-security/harden-runner@v2 - with: - egress-policy: audit - - id: github-status - name: Check GitHub status - uses: crazy-max/ghaction-github-status@v4 - - id: dump-context - name: Dump context - uses: crazy-max/ghaction-dump-context@v2 analyze: name: Analyze - needs: - - diagnostics runs-on: ubuntu-latest permissions: actions: read From 395d84096b733f10c67cfc27874a2eb297aa1be4 Mon Sep 17 00:00:00 2001 From: Felddy Date: Wed, 4 Dec 2024 13:30:02 -0500 Subject: [PATCH 18/29] Simplify user permissions By properly configuring the logging options of WeeWX to send to the console, we can remove all the code that was required to run as root and the drop to a different user. --- Dockerfile | 5 +++-- README.md | 39 ++++++++++++++++++++------------------- docker-compose.yml | 4 ---- src/entrypoint.sh | 31 +++++++++++++++---------------- 4 files changed, 38 insertions(+), 41 deletions(-) diff --git a/Dockerfile b/Dockerfile index c0fee657..66115d47 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,7 @@ # syntax=docker/dockerfile:1 ARG PYTHON_VERSION=3.13.0 -ARG WEEWX_UID=421 +ARG WEEWX_UID=1000 ARG WEEWX_HOME="/home/weewx" FROM --platform=$BUILDPLATFORM tonistiigi/xx AS xx @@ -51,7 +51,7 @@ LABEL org.opencontainers.image.vendor="Geekpad" RUN addgroup --system --gid ${WEEWX_UID} weewx \ && adduser --system --uid ${WEEWX_UID} --ingroup weewx weewx -RUN apt-get update && apt-get install -y libusb-1.0-0 gosu busybox-syslogd tzdata +RUN apt-get update && apt-get install -y libusb-1.0-0 WORKDIR ${WEEWX_HOME} @@ -66,4 +66,5 @@ VOLUME ["/data"] ENV PATH="/opt/venv/bin:$PATH" ENV PIP_TARGET="/data/lib/python/site-packages" ENV PYTHONPATH="/data/lib/python/site-packages" +USER weewx ENTRYPOINT ["./entrypoint.sh"] diff --git a/README.md b/README.md index 903e04b5..de22d60e 100644 --- a/README.md +++ b/README.md @@ -47,10 +47,6 @@ services: - type: bind source: ./data target: /data - environment: - - TIMEZONE=UTC - - WEEWX_UID=weewx - - WEEWX_GID=dialout devices: - "/dev/ttyUSB0:/dev/ttyUSB0" ``` @@ -65,7 +61,7 @@ services: the container and generate a configuration file: ```console - docker compose run weewx + docker compose run --rm weewx ``` 1. The configuration file will be created in the `data` directory. You should @@ -95,7 +91,7 @@ services: 1. Update your configuration file (a backup will be created): ```console - docker compose run weewx station upgrade + docker compose run --rm weewx station upgrade ``` 1. Read through the new configuration and verify. @@ -112,21 +108,34 @@ services: ## Installing WeeWX Extensions ## ```console -docker compose run weewx \ - extension install \ +docker compose run --rm weewx \ + extension install --yes \ https://github.com/matthewwall/weewx-windy/archive/master.zip ``` ```console -docker compose run weewx \ - extension install \ +docker compose run --rm weewx \ + extension install --yes \ https://github.com/matthewwall/weewx-mqtt/archive/master.zip ``` ## Installing Additional Python Packages ## ```console -docker compose run --entrypoint pip weewx install paho_mqtt +docker compose run --rm --entrypoint pip weewx install paho_mqtt +``` + +## Migrating ## + +If you are migrating from a non-containerized WeeWX installation, you will need to +configure the logger to write to the console. Adding the following your `weewx.conf` +will allow you to see the log output: + +```ini +[Logging] + [[root]] + level = INFO + handlers = console, ``` ## Volumes ## @@ -135,14 +144,6 @@ docker compose run --entrypoint pip weewx install paho_mqtt |-------------|----------------| | `/data` | configuration file and sqlite database storage | -## Environment Variables ## - -| Variable | Purpose | Default | -|----------------|---------|---------| -| `TIMEZONE` | Container [TZ database name](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones#List) | `UTC` | -| `WEEWX_UID` | `uid` the daemon will be run under | `weewx` | -| `WEEWX_GID` | `gid` the deamon will be run under | `weewx` | - ## Building from source ## Build the image locally using this git repository as the [build context](https://docs.docker.com/engine/reference/commandline/build/#git-repositories): diff --git a/docker-compose.yml b/docker-compose.yml index 8169d374..ed584168 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -13,7 +13,3 @@ services: - type: bind source: ./data target: /data - environment: - - TIMEZONE=UTC - - WEEWX_UID=weewx - - WEEWX_GID=dialout diff --git a/src/entrypoint.sh b/src/entrypoint.sh index 72f96c4b..e42c0269 100755 --- a/src/entrypoint.sh +++ b/src/entrypoint.sh @@ -7,29 +7,28 @@ set -o pipefail WEEWX_ROOT="/data" CONF_FILE="${WEEWX_ROOT}/weewx.conf" -# echo version before starting syslog so we don't confound our tests +# echo version if [ $# -gt 0 ] && [ "$1" = "--version" ]; then - gosu weewx:weewx weewxd --version + weewxd --version exit 0 fi -if [ "$(id -u)" = 0 ]; then - # set timezone using environment - ln -snf /usr/share/zoneinfo/"${TIMEZONE:-UTC}" /etc/localtime - # start the syslog daemon as root - /sbin/syslogd -n -S -O - & - if [ "${WEEWX_UID:-weewx}" != 0 ]; then - # drop privileges and restart this script - echo "Switching uid:gid to ${WEEWX_UID:-weewx}:${WEEWX_GID:-weewx}" - gosu "${WEEWX_UID:-weewx}:${WEEWX_GID:-weewx}" "$(readlink -f "$0")" "$@" - exit 0 - fi -fi - if [ ! -f "${CONF_FILE}" ]; then weectl station create --no-prompt ${WEEWX_ROOT} echo "A new set of configurations was created." - echo "Please edit ${CONF_FILE} and restart the container." + + # Append the logging configuration to the generated weewx.conf + cat << EOF >> "${CONF_FILE}" + +[Logging] + [[root]] + level = INFO + handlers = console, +EOF + + echo "Console logging configuration has been appended to ${CONF_FILE}." + echo "Please review and update ${CONF_FILE} as needed, then restart the container." + exit 0 fi # if we have any parameters we'll send them to weectl From 93e1d0934ea17154db312370e87303c0e246697e Mon Sep 17 00:00:00 2001 From: Felddy Date: Wed, 4 Dec 2024 13:57:17 -0500 Subject: [PATCH 19/29] Migrate setup.py to pyproject.toml --- Dockerfile | 2 +- pyproject.toml | 44 ++++++++++++++++++++++++++ setup.py | 84 -------------------------------------------------- 3 files changed, 45 insertions(+), 85 deletions(-) create mode 100644 pyproject.toml delete mode 100644 setup.py diff --git a/Dockerfile b/Dockerfile index 66115d47..edf1143a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -23,7 +23,7 @@ pip install --upgrade virtualenv virtualenv /opt/venv EOF -COPY README.md requirements.txt setup.py ./ +COPY pyproject.toml README.md requirements.txt ./ COPY src/_version.py ./src/_version.py # Python setup diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 00000000..cb797756 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,44 @@ +[build-system] +build-backend = "setuptools.build_meta" +requires = ["setuptools", "wheel"] + +[project] +authors = [{ name = "Mark Feldhousen", email = "markf@geekpad.com" }] +classifiers = [ + "Development Status :: 5 - Production/Stable", + "Environment :: Web Environment", + "Intended Audience :: System Administrators", + "License :: OSI Approved :: MIT License", + "Natural Language :: English", + "Operating System :: OS Independent", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.13", + "Topic :: Scientific/Engineering :: Atmospheric Science", +] +dependencies = ["pyserial", "pyusb", "setuptools", "weewx == 5.1.0"] +description = "Containerized WeeWX" +dynamic = ["version"] +keywords = ["container", "docker", "weewx"] +license = { file = "LICENSE" } +name = "weewx-docker" +readme = "README.md" +requires-python = ">=3.13" + +[project.urls] +homepage = "https://github.com/felddy" +issues = "https://github.com/felddy/weewx-docker/issues" +source = "https://github.com/felddy/weewx-docker" + +[project.optional-dependencies] +test = [ + "coverage", + "coveralls", + "docker", + "pre-commit", + "pytest", + "pytest-cov", + "semver", +] + +[tool.setuptools.dynamic] +version = { attr = "_version.__version__" } diff --git a/setup.py b/setup.py deleted file mode 100644 index b4510856..00000000 --- a/setup.py +++ /dev/null @@ -1,84 +0,0 @@ -""" -This is the setup module for the weewx docker project. - -Based on: - -- https://packaging.python.org/distributing/ -- https://github.com/pypa/sampleproject/blob/master/setup.py -- https://blog.ionelmc.ro/2014/05/25/python-packaging/#the-structure -""" - -# Standard Python Libraries -from glob import glob -from os.path import basename, splitext - -# Third-Party Libraries -from setuptools import find_packages, setup - - -def readme(): - """Read in and return the contents of the project's README.md file.""" - with open("README.md", encoding="utf-8") as f: - return f.read() - - -def package_vars(version_file): - """Read in and return the variables defined by the version_file.""" - pkg_vars = {} - with open(version_file) as f: - exec(f.read(), pkg_vars) # nosec - return pkg_vars - - -setup( - name="weewx_docker", - # Versions should comply with PEP440 - version=package_vars("src/_version.py")["__version__"], - description="weewx_docker python library", - long_description=readme(), - long_description_content_type="text/markdown", - url="https://github.com/felddy", - # The project's main homepage - download_url="https://github.com/felddy/weewx-docker", - # Author details - author="Mark Feldhousen", - author_email="markf@geekpad.com", - license="License :: OSI Approved :: MIT License", - # See https://pypi.python.org/pypi?%3Aaction=list_classifiers - classifiers=[ - "Development Status :: 5 - Production/Stable", - "Environment :: Web Environment", - "Intended Audience :: System Administrators", - "License :: OSI Approved :: MIT License", - "Natural Language :: English", - "Operating System :: OS Independent", - "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.13", - "Topic :: Scientific/Engineering :: Atmospheric Science", - ], - python_requires=">=3.6", - # What does your project relate to? - keywords="weewx", - packages=find_packages(where="src"), - package_dir={"": "src"}, - py_modules=[splitext(basename(path))[0] for path in glob("src/*.py")], - install_requires=[ - "configobj == 5.0.9", - "pyserial == 3.5", - "pyusb == 1.2.1", - "semver == 3.0.2", - "setuptools == 75.6.0", - "weewx == 5.1.0", - "wheel == 0.45.1", - ], - extras_require={ - "test": [ - "coverage", - "coveralls", - "docker", - "pre-commit", - "pytest", - "pytest-cov", - ] - }, -) From 0a49eddb4c5606f0ceafcd8573cee807de67a7f4 Mon Sep 17 00:00:00 2001 From: Felddy Date: Wed, 4 Dec 2024 14:03:12 -0500 Subject: [PATCH 20/29] Align documentation with reality --- README.md | 51 ++++++++++++++------------------------------------- 1 file changed, 14 insertions(+), 37 deletions(-) diff --git a/README.md b/README.md index de22d60e..06351406 100644 --- a/README.md +++ b/README.md @@ -15,21 +15,10 @@ This docker container can be used to quickly get a ## Running ## -### Running with Docker ### - -Pull `felddy/weewx` from the Docker repository: - -```console -docker pull felddy/weewx -``` - -### Run ### - The easiest way to start the container is to create a `docker-compose.yml` similar to the following. If you use a serial port to connect to your weather station, make sure the -container has permissions to access the port. The uid/gid can -be set using the environment variables below. +container has permissions to access the port. Modify any paths or devices as needed: @@ -105,6 +94,19 @@ services: docker compose up -d ``` +## Migrating ## + +If you are migrating from a non-containerized WeeWX installation, you will need to +configure the logger to write to the console. Adding the following your `weewx.conf` +will allow you to see the log output: + +```ini +[Logging] + [[root]] + level = INFO + handlers = console, +``` + ## Installing WeeWX Extensions ## ```console @@ -125,19 +127,6 @@ docker compose run --rm weewx \ docker compose run --rm --entrypoint pip weewx install paho_mqtt ``` -## Migrating ## - -If you are migrating from a non-containerized WeeWX installation, you will need to -configure the logger to write to the console. Adding the following your `weewx.conf` -will allow you to see the log output: - -```ini -[Logging] - [[root]] - level = INFO - handlers = console, -``` - ## Volumes ## | Mount point | Purpose | @@ -177,18 +166,6 @@ Docker: --tag felddy/weewx:5.1.0 . ``` -## Debugging ## - -There are a few helper arguments that can be used to diagnose container issues -in your environment. - -| Purpose | Command | -|---------|---------| -| Generate the default configuration | `docker compose run weewx` | -| Upgrade a previous configuration | `docker compose run weewx --upgrade` | -| Generate a test (simulator) configuration | `docker compose run weewx --gen-test-config` | -| Drop into a shell in the container | `docker compose run weewx --shell` | - ## Contributing ## We welcome contributions! Please see [`CONTRIBUTING.md`](CONTRIBUTING.md) for From ff4bc52896e4f368f833d58474274afd2bd3d1eb Mon Sep 17 00:00:00 2001 From: Felddy Date: Wed, 4 Dec 2024 14:08:48 -0500 Subject: [PATCH 21/29] Loosen Python restriction for linter workflow --- pyproject.toml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index cb797756..7186cb4c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -12,6 +12,9 @@ classifiers = [ "Natural Language :: English", "Operating System :: OS Independent", "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", "Programming Language :: Python :: 3.13", "Topic :: Scientific/Engineering :: Atmospheric Science", ] @@ -22,7 +25,7 @@ keywords = ["container", "docker", "weewx"] license = { file = "LICENSE" } name = "weewx-docker" readme = "README.md" -requires-python = ">=3.13" +requires-python = ">=3.10" [project.urls] homepage = "https://github.com/felddy" From 7cb9886e746290148d410aaf53bda907c7f78848 Mon Sep 17 00:00:00 2001 From: Felddy Date: Fri, 27 Dec 2024 13:54:17 -0500 Subject: [PATCH 22/29] Remove unnecessary volume declaration --- README.md | 3 --- 1 file changed, 3 deletions(-) diff --git a/README.md b/README.md index 06351406..2f727e15 100644 --- a/README.md +++ b/README.md @@ -26,9 +26,6 @@ Modify any paths or devices as needed: --- name: "weewx" -volumes: - data: - services: weewx: image: felddy/weewx:5.1.0 From 27fecb6f018e41d2f7b82cd023e3cffbc50c72b0 Mon Sep 17 00:00:00 2001 From: Felddy Date: Fri, 27 Dec 2024 13:55:33 -0500 Subject: [PATCH 23/29] Fix indentation in logging configuration --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 2f727e15..597bf52e 100644 --- a/README.md +++ b/README.md @@ -100,8 +100,8 @@ will allow you to see the log output: ```ini [Logging] [[root]] - level = INFO - handlers = console, + level = INFO + handlers = console, ``` ## Installing WeeWX Extensions ## From 5dc6dac5d713e5c39df2b0b757e79df769c15cec Mon Sep 17 00:00:00 2001 From: Felddy Date: Fri, 27 Dec 2024 13:56:22 -0500 Subject: [PATCH 24/29] Add 'ephem' to dependencies Closes #290 --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 7186cb4c..e8068bc0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -18,7 +18,7 @@ classifiers = [ "Programming Language :: Python :: 3.13", "Topic :: Scientific/Engineering :: Atmospheric Science", ] -dependencies = ["pyserial", "pyusb", "setuptools", "weewx == 5.1.0"] +dependencies = ["ephem", "pyserial", "pyusb", "setuptools", "weewx == 5.1.0"] description = "Containerized WeeWX" dynamic = ["version"] keywords = ["container", "docker", "weewx"] From 7fa642fa5e87c945475064486692f6231595846c Mon Sep 17 00:00:00 2001 From: Felddy Date: Fri, 27 Dec 2024 13:58:02 -0500 Subject: [PATCH 25/29] Use full length CLI flags --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 597bf52e..1be8df4e 100644 --- a/README.md +++ b/README.md @@ -88,7 +88,7 @@ services: 1. Start the container up with the new image version: ```console - docker compose up -d + docker compose up --detach ``` ## Migrating ## From 8476cae2d2b705d64914734f1aad923f4446754b Mon Sep 17 00:00:00 2001 From: Felddy Date: Fri, 27 Dec 2024 18:37:43 -0500 Subject: [PATCH 26/29] Update README to include image tagging information and usage recommendations --- README.md | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 1be8df4e..58ca523e 100644 --- a/README.md +++ b/README.md @@ -124,11 +124,32 @@ docker compose run --rm weewx \ docker compose run --rm --entrypoint pip weewx install paho_mqtt ``` +## Image tags ## + +The images of this container are tagged with [semantic +versions](https://semver.org) that align with the [version and build of +WeeWX](https://weewx.com/docs.html) that they support. + +> [!TIP] +> It is recommended that users use the major version tag: `:5` Using the major +> tag will ensure that you receive the most recent version of the software that +> is compatible with your saved data, and prevents inadvertent upgrades to a new +> major version. + +| Image:tag | Description | +|-----------|-------------| +|`felddy/weewx:5`| The most recent image matching the major version number. Most users will use this tag. | +|`felddy/weewx:5.1`| The most recent image matching the major and minor version numbers. | +|`felddy/weewx:5.1.0`| An exact image version. | + +See the [tags tab](https://hub.docker.com/r/felddy/weewx/tags) on Docker +Hub for a list of all the supported tags. + ## Volumes ## | Mount point | Purpose | |-------------|----------------| -| `/data` | configuration file and sqlite database storage | +| `/data` | [WeeWX root](https://weewx.com/docs/5.1/usersguide/where/#location-of-weewx-components) directory | ## Building from source ## From 0fa8b924add23240e7ebe052700737c246140de0 Mon Sep 17 00:00:00 2001 From: Felddy Date: Sat, 28 Dec 2024 16:47:35 -0500 Subject: [PATCH 27/29] Add git installation to Dockerfile dependencies --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index edf1143a..399ba415 100644 --- a/Dockerfile +++ b/Dockerfile @@ -51,7 +51,7 @@ LABEL org.opencontainers.image.vendor="Geekpad" RUN addgroup --system --gid ${WEEWX_UID} weewx \ && adduser --system --uid ${WEEWX_UID} --ingroup weewx weewx -RUN apt-get update && apt-get install -y libusb-1.0-0 +RUN apt-get update && apt-get install -y git libusb-1.0-0 WORKDIR ${WEEWX_HOME} From 416e0f735f81f0bc9b697b55f8f749e7d1dbcb21 Mon Sep 17 00:00:00 2001 From: Felddy Date: Sat, 28 Dec 2024 16:48:06 -0500 Subject: [PATCH 28/29] Update README to clarify migration steps and installation of Python packages --- README.md | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 58ca523e..8018609c 100644 --- a/README.md +++ b/README.md @@ -93,9 +93,9 @@ services: ## Migrating ## -If you are migrating from a non-containerized WeeWX installation, you will need to -configure the logger to write to the console. Adding the following your `weewx.conf` -will allow you to see the log output: +If you are migrating a WeeWX installation, you need to configure the logger to +write to the console. Add the following to your `weewx.conf` file to see the log +output in the container logs: ```ini [Logging] @@ -106,6 +106,10 @@ will allow you to see the log output: ## Installing WeeWX Extensions ## +If arguments are passed to the container, they are forwarded on to the +[`weectl`](https://weewx.com/docs/5.1/utilities/weectl-about/) command. This +can be used to install extensions: + ```console docker compose run --rm weewx \ extension install --yes \ @@ -118,10 +122,14 @@ docker compose run --rm weewx \ https://github.com/matthewwall/weewx-mqtt/archive/master.zip ``` -## Installing Additional Python Packages ## +## Installing Python Packages ## + +To install and persist Python packages, use the `pip` command. The libraries +will be installed into the `data` volume, ensuring they persist between +container restarts. ```console -docker compose run --rm --entrypoint pip weewx install paho_mqtt +docker compose run --rm --entrypoint pip weewx install git+https://github.com/felddy/weewx-home-assistant@v1.0.0 ``` ## Image tags ## From a961f0f04322be5b46800496d6c994df675e2293 Mon Sep 17 00:00:00 2001 From: Felddy Date: Sat, 28 Dec 2024 18:27:05 -0500 Subject: [PATCH 29/29] Format command for better readability --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 8018609c..d0bbe642 100644 --- a/README.md +++ b/README.md @@ -129,7 +129,8 @@ will be installed into the `data` volume, ensuring they persist between container restarts. ```console -docker compose run --rm --entrypoint pip weewx install git+https://github.com/felddy/weewx-home-assistant@v1.0.0 +docker compose run --rm --entrypoint pip weewx \ + install git+https://github.com/felddy/weewx-home-assistant@v1.0.0 ``` ## Image tags ##