Smaller Docker image
This commit is contained in:
parent
7b441e66da
commit
51d8102432
3 changed files with 33 additions and 28 deletions
53
Dockerfile
53
Dockerfile
|
@ -1,12 +1,13 @@
|
||||||
FROM python:3 as stage-1
|
FROM python:3.10.5-slim-bullseye as install
|
||||||
|
|
||||||
|
ARG WEEWX_UID=421
|
||||||
ENV WEEWX_HOME="/home/weewx"
|
ENV WEEWX_HOME="/home/weewx"
|
||||||
ENV ARCHIVE="weewx-4.8.0.tar.gz"
|
ENV WEEWX_VERSION="4.8.0"
|
||||||
ENV NEOWX_VERSION="latest"
|
ENV ARCHIVE="weewx-${WEEWX_VERSION}.tar.gz"
|
||||||
ENV WDC_VERSION="v1.3.1"
|
ENV WEEWX_WDC_VERSION="v1.3.1"
|
||||||
|
|
||||||
RUN addgroup --system --gid 421 weewx &&\
|
RUN addgroup --system --gid ${WEEWX_UID} weewx \
|
||||||
adduser --system --uid 421 --ingroup weewx weewx
|
&& adduser --system --uid ${WEEWX_UID} --ingroup weewx weewx
|
||||||
|
|
||||||
WORKDIR /tmp
|
WORKDIR /tmp
|
||||||
COPY requirements.txt ./
|
COPY requirements.txt ./
|
||||||
|
@ -16,42 +17,48 @@ RUN python -m venv /opt/venv
|
||||||
ENV PATH="/opt/venv/bin:$PATH"
|
ENV PATH="/opt/venv/bin:$PATH"
|
||||||
RUN pip install --no-cache-dir --requirement requirements.txt
|
RUN pip install --no-cache-dir --requirement requirements.txt
|
||||||
|
|
||||||
# WeeWX setup
|
# Download weewx and plugins
|
||||||
RUN wget -O "${ARCHIVE}" "http://www.weewx.com/downloads/released_versions/${ARCHIVE}" &&\
|
RUN wget -O "${ARCHIVE}" "http://www.weewx.com/downloads/released_versions/${ARCHIVE}" &&\
|
||||||
wget -O weewx-interceptor.zip https://github.com/nifoc/weewx-interceptor/archive/refs/heads/feature/ecowitt-fields.zip &&\
|
wget -O weewx-interceptor.zip https://github.com/nifoc/weewx-interceptor/archive/refs/heads/feature/ecowitt-fields.zip &&\
|
||||||
wget -O weewx-forecast.zip https://github.com/chaunceygardiner/weewx-forecast/archive/master.zip &&\
|
wget -O weewx-forecast.zip https://github.com/chaunceygardiner/weewx-forecast/archive/master.zip &&\
|
||||||
wget -O neowx-material.zip https://neoground.com/projects/neowx-material/download/${NEOWX_VERSION} &&\
|
wget -O weewx-wdc.zip https://github.com/Daveiano/weewx-wdc/releases/download/${WEEWX_WDC_VERSION}/weewx-wdc-${WEEWX_WDC_VERSION}.zip
|
||||||
wget -O weewx-wdc.zip https://github.com/Daveiano/weewx-wdc/releases/download/${WDC_VERSION}/weewx-wdc-${WDC_VERSION}.zip &&\
|
|
||||||
tar --extract --gunzip --directory ${WEEWX_HOME} --strip-components=1 --file "${ARCHIVE}" &&\
|
|
||||||
mkdir weewx-wdc && unzip weewx-wdc.zip -d weewx-wdc &&\
|
|
||||||
chown -R weewx:weewx ${WEEWX_HOME}
|
|
||||||
|
|
||||||
|
# Extract weewx and (some) plugins
|
||||||
|
RUN tar --extract --gunzip --directory ${WEEWX_HOME} --strip-components=1 --file "${ARCHIVE}" &&\
|
||||||
|
mkdir weewx-wdc && unzip weewx-wdc.zip -d weewx-wdc
|
||||||
|
|
||||||
|
# weewx setup
|
||||||
|
RUN chown -R weewx:weewx ${WEEWX_HOME}
|
||||||
WORKDIR ${WEEWX_HOME}
|
WORKDIR ${WEEWX_HOME}
|
||||||
|
|
||||||
RUN bin/wee_extension --install /tmp/weewx-interceptor.zip &&\
|
RUN bin/wee_extension --install /tmp/weewx-interceptor.zip &&\
|
||||||
bin/wee_extension --install /tmp/weewx-forecast.zip &&\
|
bin/wee_extension --install /tmp/weewx-forecast.zip &&\
|
||||||
bin/wee_extension --install /tmp/neowx-material.zip &&\
|
|
||||||
bin/wee_extension --install /tmp/weewx-wdc &&\
|
bin/wee_extension --install /tmp/weewx-wdc &&\
|
||||||
mkdir user
|
mkdir user
|
||||||
|
|
||||||
COPY entrypoint.sh ./
|
COPY entrypoint.sh ./
|
||||||
COPY user/ ./bin/user/
|
COPY --chown=weewx:weewx user/ ./bin/user/
|
||||||
|
|
||||||
FROM python:3 as stage-2
|
FROM python:3.10.5-slim-bullseye as final
|
||||||
|
|
||||||
|
ARG WEEWX_UID=421
|
||||||
ENV WEEWX_HOME="/home/weewx"
|
ENV WEEWX_HOME="/home/weewx"
|
||||||
|
|
||||||
RUN addgroup --system --gid 421 weewx &&\
|
RUN addgroup --system --gid ${WEEWX_UID} weewx \
|
||||||
adduser --system --uid 421 --ingroup weewx weewx
|
&& adduser --system --uid ${WEEWX_UID} --ingroup weewx weewx
|
||||||
|
|
||||||
|
# Install runtime dependencies
|
||||||
RUN apt-get update -qq -y &&\
|
RUN apt-get update -qq -y &&\
|
||||||
DEBIAN_FRONTEND=noninteractive apt-get install -y libusb-1.0-0 gosu busybox-syslogd tzdata nginx-light -qq -y --no-install-recommends &&\
|
DEBIAN_FRONTEND=noninteractive apt-get install -y \
|
||||||
|
libusb-1.0-0 \
|
||||||
|
gosu \
|
||||||
|
busybox-syslogd \
|
||||||
|
tzdata \
|
||||||
|
nginx-light -qq -y --no-install-recommends &&\
|
||||||
rm -rf /var/lib/apt/lists/*
|
rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
|
# Copy installation from install stage
|
||||||
WORKDIR ${WEEWX_HOME}
|
WORKDIR ${WEEWX_HOME}
|
||||||
|
COPY --from=install /opt/venv /opt/venv
|
||||||
COPY --from=stage-1 /opt/venv /opt/venv
|
COPY --from=install ${WEEWX_HOME} ${WEEWX_HOME}
|
||||||
COPY --from=stage-1 ${WEEWX_HOME} ${WEEWX_HOME}
|
|
||||||
|
|
||||||
RUN mkdir /data && \
|
RUN mkdir /data && \
|
||||||
cp weewx.conf /data
|
cp weewx.conf /data
|
||||||
|
|
3
README.md
Normal file
3
README.md
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
# weewx-docker
|
||||||
|
|
||||||
|
Based on: [felddy/weewx-docker](https://github.com/felddy/weewx-docker)
|
|
@ -23,11 +23,6 @@ if [ "$(id -u)" = 0 ]; then
|
||||||
nginx -c /data/nginx.conf
|
nginx -c /data/nginx.conf
|
||||||
|
|
||||||
# skin config
|
# skin config
|
||||||
if [ -e /data/neowx-material-skin.conf ]; then
|
|
||||||
rm -f ./skins/neowx-material/skin.conf
|
|
||||||
ln -s /data/neowx-material-skin.conf ./skins/neowx-material/skin.conf
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -e /data/weewx-wdc-skin.conf ]; then
|
if [ -e /data/weewx-wdc-skin.conf ]; then
|
||||||
rm -f ./skins/weewx-wdc/skin.conf
|
rm -f ./skins/weewx-wdc/skin.conf
|
||||||
ln -s /data/weewx-wdc-skin.conf ./skins/weewx-wdc/skin.conf
|
ln -s /data/weewx-wdc-skin.conf ./skins/weewx-wdc/skin.conf
|
||||||
|
|
Reference in a new issue