diff --git a/platypush/install/docker/fedora.Dockerfile b/platypush/install/docker/fedora.Dockerfile new file mode 100644 index 000000000..d355f8d72 --- /dev/null +++ b/platypush/install/docker/fedora.Dockerfile @@ -0,0 +1,26 @@ +FROM fedora + +ADD . /install +WORKDIR /var/lib/platypush + +ARG DOCKER_CTX=1 +ENV DOCKER_CTX=1 + +# Enable the RPM Fusion repository +RUN dnf install -y \ + https://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-$(rpm -E %fedora).noarch.rpm + +RUN /install/platypush/install/scripts/fedora/install.sh +RUN cd /install && pip install -U --no-input --no-cache-dir . +RUN rm -rf /install +RUN dnf clean all -y + +EXPOSE 8008 + +VOLUME /etc/platypush +VOLUME /var/lib/platypush + +CMD platypush \ + --start-redis \ + --config /etc/platypush/config.yaml \ + --workdir /var/lib/platypush diff --git a/platypush/install/scripts/fedora/PKGCMD b/platypush/install/scripts/fedora/PKGCMD new file mode 100644 index 000000000..6d37a3957 --- /dev/null +++ b/platypush/install/scripts/fedora/PKGCMD @@ -0,0 +1 @@ +dnf install -y diff --git a/platypush/install/scripts/fedora/install.sh b/platypush/install/scripts/fedora/install.sh new file mode 100755 index 000000000..5eb688269 --- /dev/null +++ b/platypush/install/scripts/fedora/install.sh @@ -0,0 +1,28 @@ +#!/bin/sh + +# This script parses the system requirements for a specific OS and it runs the +# appropriate package manager command to install them. + +# This script is usually symlinked in the folders of the individual operating +# systems, and it's not supposed to be invoked directly. +# Instead, it will be called either by the root install.sh script or by a +# Dockerfile. + +SCRIPT_PATH="$( cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )" +OS="$(basename "$SCRIPT_PATH")" +CMD="$(cat "${SCRIPT_PATH}/PKGCMD")" +REQUIREMENTS="$(cat "${SCRIPT_PATH}/../../requirements/${OS}.txt" | tr '\n' ' ')" +SUDO= + +# If we aren't running in a Docker context, or the user is not root, we should +# use sudo to install system packages. +if [ $(id -u) -ne 0 ] || [ -z "$DOCKER_CTX" ]; then + if ! type sudo >/dev/null; then + echo "sudo executable not found, I can't install system packages" >&2 + exit 1 + fi + + SUDO="sudo" +fi + +${SUDO_ARGS} ${CMD} ${REQUIREMENTS} diff --git a/platypush/platydock/__init__.py b/platypush/platydock/__init__.py index ed97dbffb..638e2a953 100755 --- a/platypush/platydock/__init__.py +++ b/platypush/platydock/__init__.py @@ -35,6 +35,7 @@ class DockerBuilder(BaseBuilder): _pkg_manager_by_base_image = { BaseImage.ALPINE: PackageManagers.APK, BaseImage.DEBIAN: PackageManagers.APT, + BaseImage.FEDORA: PackageManagers.DNF, BaseImage.UBUNTU: PackageManagers.APT, } diff --git a/platypush/utils/manifest.py b/platypush/utils/manifest.py index 421fead48..8ca220469 100644 --- a/platypush/utils/manifest.py +++ b/platypush/utils/manifest.py @@ -42,6 +42,7 @@ class BaseImage(Enum): ALPINE = 'alpine' DEBIAN = 'debian' + FEDORA = 'fedora' UBUNTU = 'ubuntu' def __str__(self) -> str: @@ -129,6 +130,15 @@ class PackageManagers(Enum): parse_list_line=lambda line: line.split('/')[0], ) + DNF = PackageManager( + executable='dnf', + install=('dnf', 'install', '-y'), + uninstall=('dnf', 'remove', '-y'), + list=('dnf', 'list', '--installed'), + default_os='fedora', + parse_list_line=lambda line: re.split(r'\s+', line)[0].split('.')[0], + ) + PACMAN = PackageManager( executable='pacman', install=('pacman', '-S', '--noconfirm', '--needed'),