Several Docker image improvements.

- Reduced size of the Ubuntu image by removing some unneeded packages
  (docutils, manpages, babel, fonts, python-pil etc.) that take a lot of
  space.

- Better self-documented docker-compose.yml.

- Added reference to the registry.platypush.tech/platypush image in
  docker-compose.yml (README reference will follow).

- Fixed grep condition in the Docker prepare script.

- Pass `--no-deps` to `pip install platypush`. The dependencies of the
  application, now that `marshmallow_dataclasses` has been removed, are
  all available in the package managers of the supported images (with
  the exception for croniter in Alpine Linux for now), so they can all
  be installed via system package manager rather than pip. This also
  prevents Ubuntu builds from breaking because system-installed packages
  are being overwritten with pip-installed copies.
This commit is contained in:
Fabio Manganiello 2024-10-03 20:35:01 +02:00
parent 2308c4e927
commit 9ebe251d46
Signed by untrusted user: blacklight
GPG key ID: D90FBA7F76362774
5 changed files with 50 additions and 39 deletions

View file

@ -1,24 +1,9 @@
services: services:
platypush: platypush:
restart: "always" # Replace the build section with the next line if instead of building the
command: # image from a local checkout you want to pull the latest base
- platypush # (Alpine-based) image from the remote registry
# Comment --start-redis if you want to run an external Redis service # image: "registry.platypush.tech/platypush:latest"
# In such case you'll also have to ensure that the appropriate Redis
# variables are set in the .env file, or the Redis configuration is
# passed in the config.yaml, or use the --redis-host and --redis-port
# command-line options
- --start-redis
# Custom list of host devices that should be accessible to the container -
# e.g. an Arduino, an ESP-compatible microcontroller, a joystick etc.
# devices:
# - /dev/ttyUSB0
# Uncomment if you need plugins that require access to low-level hardware
# (e.g. Bluetooth BLE or GPIO/SPI/I2C) if access to individual devices is
# not enough or isn't practical
# privileged: true
build: build:
context: . context: .
@ -31,6 +16,25 @@ services:
# Fedora base image # Fedora base image
# dockerfile: ./platypush/install/docker/fedora.Dockerfile # dockerfile: ./platypush/install/docker/fedora.Dockerfile
restart: "always"
command:
- platypush
- --redis-host
- redis
# Or, if you want to run Redis from the same container as Platypush,
# replace --redis-host redis with the line below
# - --start-redis
# Custom list of host devices that should be accessible to the container -
# e.g. an Arduino, an ESP-compatible microcontroller, a joystick etc.
# devices:
# - /dev/ttyUSB0
# Uncomment if you need plugins that require access to low-level hardware
# (e.g. Bluetooth BLE or GPIO/SPI/I2C) if access to individual devices is
# not enough or isn't practical
# privileged: true
# Copy .env.example to .env and modify as needed # Copy .env.example to .env and modify as needed
# env_file: # env_file:
# - .env # - .env
@ -40,7 +44,13 @@ services:
# expose it # expose it
- "8008:8008" - "8008:8008"
volumes: # volumes:
- /path/to/your/config.yaml:/etc/platypush # Replace with a path that contains/will contain your config.yaml file
- /path/to/a/workdir:/var/lib/platypush # - /path/to/your/config:/etc/platypush
# Replace with a path that contains/will contain your working directory
# - /path/to/a/workdir:/var/lib/platypush
# Optionally, use an external volume for the cache
# - /path/to/a/cachedir:/var/cache/platypush # - /path/to/a/cachedir:/var/cache/platypush
redis:
image: redis

View file

@ -7,7 +7,7 @@ WORKDIR /var/lib/platypush
RUN --mount=type=bind,source=.,target=/curdir \ RUN --mount=type=bind,source=.,target=/curdir \
apk update && \ apk update && \
# If the current directory is the Platypush repository, then we can copy the existing files \ # If the current directory is the Platypush repository, then we can copy the existing files \
if grep 'name="platypush"' /curdir/pyproject.toml >/dev/null 2>&1; \ if grep -E 'name\s*=\s*"platypush"' /curdir/pyproject.toml >/dev/null 2>&1; \
then \ then \
cp -r /curdir /install; \ cp -r /curdir /install; \
# Otherwise, we need to clone the repository \ # Otherwise, we need to clone the repository \
@ -18,10 +18,9 @@ RUN --mount=type=bind,source=.,target=/curdir \
RUN /install/platypush/install/scripts/alpine/install.sh && \ RUN /install/platypush/install/scripts/alpine/install.sh && \
cd /install && \ cd /install && \
pip install -U --no-input --no-cache-dir . --break-system-packages && \ pip install -U --no-input --no-cache-dir --no-deps . croniter --break-system-packages && \
rm -rf /install && \ rm -rf /install && \
rm -rf /root/.cache && \ rm -rf /root/.cache && \
find / | grep -E "(/__pycache__$|\.pyc$|\.pyo$)" | xargs rm -rf && \
apk del gcc git && \ apk del gcc git && \
apk cache clean && \ apk cache clean && \
rm -rf /var/cache/apk/* && \ rm -rf /var/cache/apk/* && \

View file

@ -10,7 +10,7 @@ ENV DOCKER_CTX=1
RUN --mount=type=bind,source=.,target=/curdir \ RUN --mount=type=bind,source=.,target=/curdir \
apt update && \ apt update && \
# If the current directory is the Platypush repository, then we can copy the existing files \ # If the current directory is the Platypush repository, then we can copy the existing files \
if grep 'name="platypush"' /curdir/pyproject.toml >/dev/null 2>&1; \ if grep -E 'name\s*=\s*"platypush"' /curdir/pyproject.toml >/dev/null 2>&1; \
then \ then \
cp -r /curdir /install; \ cp -r /curdir /install; \
# Otherwise, we need to clone the repository \ # Otherwise, we need to clone the repository \
@ -21,10 +21,9 @@ RUN --mount=type=bind,source=.,target=/curdir \
RUN /install/platypush/install/scripts/debian/install.sh && \ RUN /install/platypush/install/scripts/debian/install.sh && \
cd /install && \ cd /install && \
pip install -U --no-input --no-cache-dir . --break-system-packages && \ pip install -U --no-input --no-cache-dir --no-deps . --break-system-packages && \
rm -rf /install && \ rm -rf /install && \
rm -rf /root/.cache && \ rm -rf /root/.cache && \
find / | grep -E "(/__pycache__$|\.pyc$|\.pyo$)" | xargs rm -rf && \
apt remove -y git build-essential && \ apt remove -y git build-essential && \
rm -rf /var/lib/apt/lists/* && \ rm -rf /var/lib/apt/lists/* && \
apt autoclean -y && \ apt autoclean -y && \

View file

@ -7,20 +7,19 @@ ENV DOCKER_CTX=1
RUN --mount=type=bind,source=.,target=/curdir \ RUN --mount=type=bind,source=.,target=/curdir \
# If the current directory is the Platypush repository, then we can copy the existing files \ # If the current directory is the Platypush repository, then we can copy the existing files \
if grep 'name="platypush"' /curdir/pyproject.toml >/dev/null 2>&1; \ if grep -E 'name\s*=\s*"platypush"' /curdir/pyproject.toml >/dev/null 2>&1; \
then \ then \
cp -r /curdir /install; \ cp -r /curdir /install; \
# Otherwise, we need to clone the repository \ # Otherwise, we need to clone the repository \
else \ else \
dnf install -y git && \ dnf install -y git && \
git clone https://github.com/blacklight/platypush.git /install; \ git clone https://github.com/blacklight/platypush.git /install; \
fi fi; \
dnf install -y https://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-$(rpm -E %fedora).noarch.rpm
# Enable the RPM Fusion repository RUN /install/platypush/install/scripts/fedora/install.sh && \
RUN dnf install -y https://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-$(rpm -E %fedora).noarch.rpm && \
/install/platypush/install/scripts/fedora/install.sh && \
cd /install && \ cd /install && \
pip install -U --no-input --no-cache-dir . --break-system-packages && \ pip install -U --no-input --no-cache-dir --no-deps . --break-system-packages && \
rm -rf /install && \ rm -rf /install && \
rm -rf /root/.cache && \ rm -rf /root/.cache && \
dnf remove -y build-essential git && \ dnf remove -y build-essential git && \

View file

@ -10,7 +10,7 @@ ENV DOCKER_CTX=1
RUN --mount=type=bind,source=.,target=/curdir \ RUN --mount=type=bind,source=.,target=/curdir \
apt update && \ apt update && \
# If the current directory is the Platypush repository, then we can copy the existing files \ # If the current directory is the Platypush repository, then we can copy the existing files \
if grep 'name="platypush"' /curdir/pyproject.toml >/dev/null 2>&1; \ if grep -E 'name\s*=\s*"platypush"' /curdir/pyproject.toml >/dev/null 2>&1; \
then \ then \
cp -r /curdir /install; \ cp -r /curdir /install; \
# Otherwise, we need to clone the repository \ # Otherwise, we need to clone the repository \
@ -21,12 +21,16 @@ RUN --mount=type=bind,source=.,target=/curdir \
RUN /install/platypush/install/scripts/debian/install.sh && \ RUN /install/platypush/install/scripts/debian/install.sh && \
cd /install && \ cd /install && \
pip install -U --no-input --no-cache-dir . --break-system-packages && \ pip install -U --no-input --no-cache-dir --no-deps . --break-system-packages && \
rm -rf /install && \ rm -rf /install && \
rm -rf /root/.cache && \ rm -rf /root/.cache && \
find / | grep -E "(/__pycache__$|\.pyc$|\.pyo$)" | xargs rm -rf && \ apt remove -y git \
apt remove -y git build-essential && \ build-essential \
rm -rf /var/lib/apt/lists/* && \ docutils-common \
fonts-dejavu-mono \
manpages \
manpages-dev \
python-babel-localedata && \
apt autoclean -y && \ apt autoclean -y && \
apt autoremove -y && \ apt autoremove -y && \
apt clean && \ apt clean && \