Skip to content

Commit

Permalink
Merge pull request #345 from felddy/release/5.0.2
Browse files Browse the repository at this point in the history
Support version 5.1.0
  • Loading branch information
felddy authored Dec 28, 2024
2 parents 58d22b2 + a961f0f commit ac858a6
Show file tree
Hide file tree
Showing 10 changed files with 156 additions and 248 deletions.
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/[email protected]
```

## 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 = "[email protected]" }]
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

0 comments on commit ac858a6

Please sign in to comment.