Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support version 5.1.0 #345

Merged
merged 29 commits into from
Dec 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
50a98d9
Bump _version.py from 4.10.2 to 5.0.2
felddy May 24, 2024
938ea70
Bump Python version requirement to 3.12
felddy May 24, 2024
24c7cdc
Remove paho-mqtt
felddy May 24, 2024
86b85ff
Update setup.py with weewx dependency
felddy May 24, 2024
0154010
Update Dockerfile to support new availability of weewx in pip
felddy May 24, 2024
9550c7c
Clean up docker-compose file
felddy May 24, 2024
dbb0d0f
Convert entrypoint to support weewx v5
felddy May 24, 2024
4bbdff1
Bump WEEWX_VERSION from 4.10.2 to 5.0.2
felddy Jun 22, 2024
e5ceab2
Bump WeeWX version to 5.1
felddy Nov 23, 2024
159f8a7
Update example docker compose config
felddy Nov 23, 2024
3694342
Document how to add extensions
felddy Nov 23, 2024
9db3a96
Update Python version requirement to 3.13
felddy Nov 23, 2024
75ae335
Add missing version declaration
felddy Nov 25, 2024
602276b
Add PYTHONPATH to data volume
felddy Nov 25, 2024
dd25129
Remove unused file from v4 implementation
felddy Nov 25, 2024
5f6561d
Update documentation with new procedures
felddy Nov 25, 2024
55c0fa4
Remove duplicate diagnostics job
felddy Nov 25, 2024
395d840
Simplify user permissions
felddy Dec 4, 2024
93e1d09
Migrate setup.py to pyproject.toml
felddy Dec 4, 2024
0a49edd
Align documentation with reality
felddy Dec 4, 2024
ff4bc52
Loosen Python restriction for linter workflow
felddy Dec 4, 2024
7cb9886
Remove unnecessary volume declaration
felddy Dec 27, 2024
27fecb6
Fix indentation in logging configuration
felddy Dec 27, 2024
5dc6dac
Add 'ephem' to dependencies
felddy Dec 27, 2024
7fa642f
Use full length CLI flags
felddy Dec 27, 2024
8476cae
Update README to include image tagging information and usage recommen…
felddy Dec 27, 2024
0fa8b92
Add git installation to Dockerfile dependencies
felddy Dec 28, 2024
416e0f7
Update README to clarify migration steps and installation of Python p…
felddy Dec 28, 2024
a961f0f
Format command for better readability
felddy Dec 28, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
19 changes: 0 additions & 19 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
33 changes: 8 additions & 25 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,25 +1,18 @@
# syntax=docker/dockerfile:1

ARG PYTHON_VERSION=3.13.0
ARG WEEWX_UID=421
ARG WEEWX_VERSION=4.10.2
ARG WEEWX_UID=1000
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
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 \
Expand All @@ -30,27 +23,16 @@ pip install --upgrade virtualenv
virtualenv /opt/venv
EOF

COPY src/hashes README.md requirements.txt setup.py ./
COPY pyproject.toml README.md requirements.txt ./
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"
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
Expand All @@ -69,19 +51,20 @@ 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 git libusb-1.0-0

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"
ENV PIP_TARGET="/data/lib/python/site-packages"
ENV PYTHONPATH="/data/lib/python/site-packages"
USER weewx
ENTRYPOINT ["./entrypoint.sh"]
CMD ["/data/weewx.conf"]
126 changes: 72 additions & 54 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,51 +13,26 @@
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 ###

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:

```yaml
---
version: "3.8"

volumes:
data:
name: "weewx"

services:
weewx:
image: felddy/weewx
init: true
restart: "yes"
image: felddy/weewx:5.1.0
volumes:
- type: bind
source: ./data
target: /data
environment:
- TIMEZONE=UTC
- WEEWX_UID=weewx
- WEEWX_GID=dialout
devices:
- "/dev/ttyUSB0:/dev/ttyUSB0"
```
Expand All @@ -72,7 +47,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
Expand Down Expand Up @@ -102,7 +77,7 @@ services:
1. Update your configuration file (a backup will be created):

```console
docker compose run weewx --upgrade
docker compose run --rm weewx station upgrade
```

1. Read through the new configuration and verify.
Expand All @@ -113,30 +88,85 @@ services:
1. Start the container up with the new image version:

```console
docker compose up -d
docker compose up --detach
```

## Migrating ##

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]
[[root]]
level = INFO
handlers = console,
```

## 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 \
https://github.com/matthewwall/weewx-windy/archive/master.zip
```

```console
docker compose run --rm weewx \
extension install --yes \
https://github.com/matthewwall/weewx-mqtt/archive/master.zip
```

## 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 git+https://github.com/felddy/weewx-home-assistant@v1.0.0
```

## 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 |

## 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` |
| `/data` | [WeeWX root](https://weewx.com/docs/5.1/usersguide/where/#location-of-weewx-components) directory |

## 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):

```console
docker build \
--tag felddy/weewx:4.8.0 \
--tag felddy/weewx:5.1.0 \
https://github.com/felddy/weewx-docker.git#develop
```

Expand All @@ -160,21 +190,9 @@ Docker:
docker buildx build \
--platform linux/amd64 \
--output type=docker \
--tag felddy/weewx:4.8.0 .
--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
Expand Down
13 changes: 2 additions & 11 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,24 +1,15 @@
---
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.1.0
# devices:
# - "/dev/ttyUSB0:/dev/ttyUSB0"
volumes:
- type: bind
source: ./data
target: /data
environment:
- TIMEZONE=UTC
- WEEWX_UID=weewx
- WEEWX_GID=dialout
47 changes: 47 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
[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.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Topic :: Scientific/Engineering :: Atmospheric Science",
]
dependencies = ["ephem", "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.10"

[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__" }
Loading
Loading