Archived
1
0
Fork 0
This repository has been archived on 2024-07-01. You can view files and clone it, but cannot push or open issues or pull requests.
weewx-docker/Dockerfile

123 lines
5.4 KiB
Text
Raw Normal View History

2024-06-29 15:27:26 +00:00
FROM python:3.12.4-slim-bookworm as install
2022-01-30 22:11:34 +00:00
2022-07-15 18:29:23 +00:00
ARG WEEWX_UID=421
2022-01-30 22:11:34 +00:00
ENV WEEWX_HOME="/home/weewx"
2024-06-29 15:27:26 +00:00
ENV WEEWX_VERSION="5.0.2"
2024-06-29 15:30:38 +00:00
ENV ARCHIVE="weewx-${WEEWX_VERSION}.tgz"
2024-06-29 15:27:26 +00:00
ENV WEEWX_WDC_VERSION="v3.5.1"
2022-01-30 22:11:34 +00:00
2022-07-15 18:29:23 +00:00
RUN addgroup --system --gid ${WEEWX_UID} weewx \
2024-06-29 15:34:07 +00:00
&& adduser --system --uid ${WEEWX_UID} --ingroup weewx weewx \
&& mkdir -p ${WEEWX_HOME} && chown -R weewx:weewx ${WEEWX_HOME}
2022-01-30 22:11:34 +00:00
2022-07-15 18:33:08 +00:00
# Install installation dependencies
RUN apt-get update -qq -y &&\
DEBIAN_FRONTEND=noninteractive apt-get install -y \
2022-07-15 18:42:11 +00:00
build-essential \
2022-07-15 18:37:02 +00:00
unzip \
wget \
2022-07-15 19:57:57 +00:00
libjpeg62-turbo-dev \
2022-07-15 19:46:46 +00:00
zlib1g-dev \
2022-07-15 18:37:02 +00:00
-qq -y --no-install-recommends &&\
2022-07-15 18:33:08 +00:00
rm -rf /var/lib/apt/lists/*
2022-01-30 22:11:34 +00:00
WORKDIR /tmp
COPY requirements.txt ./
2022-07-10 17:12:38 +00:00
# Python setup
RUN python -m venv /opt/venv
ENV PATH="/opt/venv/bin:$PATH"
RUN pip install --no-cache-dir --requirement requirements.txt
2022-07-15 18:29:23 +00:00
# Download weewx and plugins
2022-12-22 21:57:53 +00:00
RUN wget -nv -O "${ARCHIVE}" "http://www.weewx.com/downloads/released_versions/${ARCHIVE}" &&\
2023-03-24 22:44:04 +00:00
wget -nv -O weewx-mqtt.zip https://github.com/matthewwall/weewx-mqtt/archive/master.zip &&\
2024-06-29 15:27:26 +00:00
wget -nv -O weewx-MQTTSubscribe.zip https://github.com/bellrichm/WeeWX-MQTTSubscribe/archive/refs/tags/v2.3.1.zip &&\
wget -nv -O weewx-forecast.zip https://github.com/chaunceygardiner/weewx-forecast/releases/download/v3.5/weewx-forecast-3.5.zip &&\
2023-05-22 22:20:06 +00:00
wget -nv -O weewx-GTS.zip https://github.com/roe-dl/weewx-GTS/archive/master.zip &&\
2024-06-29 15:27:26 +00:00
wget -nv -O weewx-purpleair.zip https://github.com/bakerkj/weewx-purpleair/archive/refs/tags/v0.9.zip &&\
2023-01-12 10:18:01 +00:00
wget -nv -O weewx-aqi.zip https://github.com/jonathankoren/weewx-aqi/archive/refs/tags/v1.4.1.zip &&\
2022-12-22 21:57:53 +00:00
wget -nv -O weewx-dwd.zip https://github.com/roe-dl/weewx-DWD/archive/master.zip &&\
2023-05-22 17:53:57 +00:00
wget -nv -O weewx-wdc.zip https://github.com/Daveiano/weewx-wdc/releases/download/${WEEWX_WDC_VERSION}/weewx-wdc-${WEEWX_WDC_VERSION}.zip
2022-01-30 22:11:34 +00:00
2022-07-15 18:29:23 +00:00
# Extract weewx and (some) plugins
RUN tar --extract --gunzip --directory ${WEEWX_HOME} --strip-components=1 --file "${ARCHIVE}" &&\
2022-12-22 21:57:53 +00:00
mkdir weewx-dwd && unzip weewx-dwd.zip -d weewx-dwd &&\
2022-07-15 18:29:23 +00:00
mkdir weewx-wdc && unzip weewx-wdc.zip -d weewx-wdc
2022-01-30 22:11:34 +00:00
2022-12-22 21:57:53 +00:00
# Icons
RUN wget -nv -O icons-dwd.zip "https://www.dwd.de/DE/wetter/warnungen_aktuell/objekt_einbindung/icons/wettericons_zip.zip?__blob=publicationFile&v=3" &&\
wget -nv -O warnicons-dwd.zip "https://www.dwd.de/DE/wetter/warnungen_aktuell/objekt_einbindung/icons/warnicons_nach_stufen_50x50_zip.zip?__blob=publicationFile&v=2" &&\
wget -nv -O icons-carbon.zip "https://public-images-social.s3.eu-west-1.amazonaws.com/weewx-wdc-carbon-icons.zip" &&\
mkdir -p "${WEEWX_HOME}/public_html/dwd/icons" && mkdir -p "${WEEWX_HOME}/public_html/dwd/warn_icons" &&\
unzip /tmp/icons-dwd.zip -d "${WEEWX_HOME}/public_html/dwd/icons" &&\
unzip /tmp/icons-carbon.zip -d "${WEEWX_HOME}/public_html/dwd/icons" &&\
unzip /tmp/warnicons-dwd.zip -d "${WEEWX_HOME}/public_html/dwd/warn_icons"
# Adjust (some) file content and permissions
2022-12-22 22:06:46 +00:00
RUN sed -i -z -e "s|PTH=\"/etc/weewx/skins/Belchertown/dwd\"|PTH=\"/home/weewx/skins/weewx-wdc/dwd\"|g" /tmp/weewx-dwd/weewx-DWD-master/usr/local/bin/wget-dwd &&\
2022-12-22 23:28:24 +00:00
sed -i -z -e "s|SchilderLZ|SchilderEM|g" /tmp/weewx-dwd/weewx-DWD-master/usr/local/bin/wget-dwd &&\
2022-12-22 22:06:46 +00:00
sed -i -z -e "s|config = configobj.ConfigObj(\"/etc/weewx/weewx.conf\")|config = configobj.ConfigObj(\"/data/weewx.conf\")|g" /tmp/weewx-dwd/weewx-DWD-master/usr/local/bin/dwd-warnings &&\
2022-12-22 22:36:24 +00:00
sed -i -z -e "s|#!/usr/bin/python3|#!/usr/bin/env python3|g" /tmp/weewx-dwd/weewx-DWD-master/usr/local/bin/dwd-warnings &&\
sed -i -z -e "s|#!/usr/bin/python3|#!/usr/bin/env python3|g" /tmp/weewx-dwd/weewx-DWD-master/usr/local/bin/dwd-cap-warnings &&\
sed -i -z -e "s|#!/usr/bin/python3|#!/usr/bin/env python3|g" /tmp/weewx-dwd/weewx-DWD-master/usr/local/bin/dwd-mosmix &&\
2022-12-23 00:16:30 +00:00
sed -i -z -e "s|#!/usr/bin/python3|#!/usr/bin/env python3|g" /tmp/weewx-dwd/weewx-DWD-master/usr/local/bin/bbk-warnings &&\
2022-12-22 22:06:46 +00:00
chmod +x /tmp/weewx-dwd/weewx-DWD-master/usr/local/bin/* &&\
2022-12-22 21:57:53 +00:00
chown -R weewx:weewx ${WEEWX_HOME}
2022-07-15 18:29:23 +00:00
# weewx setup
WORKDIR ${WEEWX_HOME}
2024-06-29 15:27:26 +00:00
RUN bin/weectl extension install /tmp/weewx-mqtt.zip &&\
bin/weectl extension install /tmp/weewx-MQTTSubscribe.zip &&\
bin/weectl extension install /tmp/weewx-forecast.zip &&\
bin/weectl extension install /tmp/weewx-GTS.zip &&\
bin/weectl extension install /tmp/weewx-purpleair.zip &&\
bin/weectl extension install /tmp/weewx-aqi.zip &&\
bin/weectl extension install /tmp/weewx-wdc &&\
2022-12-22 22:38:09 +00:00
mkdir "${WEEWX_HOME}/skins/weewx-wdc/dwd"
2022-07-21 20:30:24 +00:00
2022-01-30 22:11:34 +00:00
COPY entrypoint.sh ./
2022-07-21 20:30:24 +00:00
COPY --chown=weewx:weewx user/extensions.py ./bin/user/extensions.py
2022-01-30 22:11:34 +00:00
2022-07-24 20:21:32 +00:00
# Included for debugging
2022-07-21 20:13:47 +00:00
RUN echo 'Default Configuration:' &&\
2022-07-21 20:10:09 +00:00
cat ${WEEWX_HOME}/weewx.conf
2024-06-29 15:27:26 +00:00
FROM python:3.12.4-slim-bookworm as final
2022-01-30 22:11:34 +00:00
2022-07-15 18:29:23 +00:00
ARG WEEWX_UID=421
2022-01-30 22:11:34 +00:00
ENV WEEWX_HOME="/home/weewx"
2022-07-15 18:29:23 +00:00
RUN addgroup --system --gid ${WEEWX_UID} weewx \
&& adduser --system --uid ${WEEWX_UID} --ingroup weewx weewx
2022-01-30 22:11:34 +00:00
2022-07-15 18:29:23 +00:00
# Install runtime dependencies
2022-01-30 22:11:34 +00:00
RUN apt-get update -qq -y &&\
2022-07-15 18:29:23 +00:00
DEBIAN_FRONTEND=noninteractive apt-get install -y \
libusb-1.0-0 \
2022-07-15 19:46:46 +00:00
zlib1g \
2022-07-15 19:57:57 +00:00
libjpeg62-turbo \
2022-12-22 21:57:53 +00:00
cron \
wget \
2022-07-15 18:29:23 +00:00
gosu \
busybox-syslogd \
tzdata \
2022-07-15 18:37:02 +00:00
-qq -y --no-install-recommends &&\
2022-01-30 22:11:34 +00:00
rm -rf /var/lib/apt/lists/*
2022-07-15 18:29:23 +00:00
# Copy installation from install stage
2022-01-30 22:11:34 +00:00
WORKDIR ${WEEWX_HOME}
2022-07-15 18:29:23 +00:00
COPY --from=install /opt/venv /opt/venv
COPY --from=install ${WEEWX_HOME} ${WEEWX_HOME}
2022-12-22 22:06:46 +00:00
COPY --from=install /tmp/weewx-dwd/weewx-DWD-master/usr/local/bin/* /usr/local/bin/
2022-07-27 14:28:39 +00:00
COPY --chown=weewx:weewx defaults/ /defaults
2022-01-30 22:11:34 +00:00
RUN mkdir /data && \
cp weewx.conf /data
VOLUME ["/data"]
ENV PATH="/opt/venv/bin:$PATH"
ENTRYPOINT ["./entrypoint.sh"]
CMD ["/data/weewx.conf"]