New way of managing installation scripts and dependencies.

Created `platypush/install` folder that contains:

- Dockerfiles for the supported distros
- Lists of required base dependencies for the supported distros
- Install and run scripts
- Added Debian to supported base images
This commit is contained in:
Fabio Manganiello 2023-08-20 01:54:55 +02:00
parent 71c5291190
commit 199ac5f0f7
Signed by: blacklight
GPG key ID: D90FBA7F76362774
18 changed files with 186 additions and 1 deletions

View file

@ -1,4 +1,5 @@
recursive-include platypush/backend/http/webapp/dist *
recursive-include platypush/install *
include platypush/plugins/http/webpage/mercury-parser.js
include platypush/config/*.yaml
global-include manifest.yaml

View file

@ -0,0 +1,14 @@
FROM alpine
ADD . /install
WORKDIR /var/lib/platypush
RUN DOCKER_CTX=1 /install/platypush/install/scripts/alpine/install.sh
RUN cd /install && pip install -U --no-input --no-cache-dir .
RUN rm -rf /install
EXPOSE 8008
VOLUME /etc/platypush
VOLUME /var/lib/platypush
CMD /run.sh

View file

@ -0,0 +1,18 @@
FROM debian
ADD . /install
WORKDIR /var/lib/platypush
RUN apt update
RUN DOCKER_CTX=1 /install/platypush/install/scripts/debian/install.sh
RUN cd /install && pip install -U --no-input --no-cache-dir .
RUN rm -rf /install
RUN apt autoclean -y
RUN apt autoremove -y
RUN apt clean
EXPOSE 8008
VOLUME /etc/platypush
VOLUME /var/lib/platypush
CMD /run.sh

View file

@ -0,0 +1,18 @@
FROM ubuntu
ADD . /install
WORKDIR /var/lib/platypush
RUN apt update
RUN DOCKER_CTX=1 /install/platypush/install/scripts/debian/install.sh
RUN cd /install && pip install -U --no-input --no-cache-dir .
RUN rm -rf /install
RUN apt autoclean -y
RUN apt autoremove -y
RUN apt clean
EXPOSE 8008
VOLUME /etc/platypush
VOLUME /var/lib/platypush
CMD /run.sh

View file

@ -0,0 +1,26 @@
python3
py3-pip
py3-alembic
py3-bcrypt
py3-dateutil
py3-docutils
py3-flask
py3-frozendict
py3-greenlet
py3-magic
py3-mypy-extensions
py3-psutil
py3-redis
py3-requests
py3-rsa
py3-sqlalchemy
py3-tornado
py3-typing-extensions
py3-tz
py3-websocket-client
py3-websockets
py3-wheel
py3-yaml
py3-zeroconf
redis
sudo

View file

@ -0,0 +1,24 @@
python
python-alembic
python-bcrypt
python-dateutil
python-docutils
python-flask
python-frozendict
python-magic
python-marshmallow
python-pip
python-psutil
python-pytz
python-redis
python-requests
python-rsa
python-sqlalchemy
python-tornado
python-websocket-client
python-websockets
python-wheel
python-yaml
python-zeroconf
redis
sudo

View file

@ -0,0 +1,28 @@
python3
python3-pip
python3-alembic
python3-bcrypt
python3-dateutil
python3-docutils
python3-flask
python3-frozendict
python3-greenlet
python3-magic
python3-marshmallow
python3-mypy-extensions
python3-psutil
python3-redis
python3-requests
python3-rsa
python3-sqlalchemy
python3-tornado
python3-typing-extensions
python3-typing-inspect
python3-tz
python3-websocket
python3-websockets
python3-wheel
python3-yaml
python3-zeroconf
redis
sudo

View file

@ -0,0 +1 @@
debian.txt

View file

@ -0,0 +1 @@
apk add --update --no-interactive --no-cache

View file

@ -0,0 +1 @@
../install.sh

View file

@ -0,0 +1 @@
pacman -S --noconfirm

View file

@ -0,0 +1 @@
../install.sh

View file

@ -0,0 +1 @@
DEBIAN_FRONTEND=noninteractive apt install -y

View file

@ -0,0 +1 @@
../install.sh

View file

@ -0,0 +1,8 @@
#!/bin/sh
# This script is used as a default entry point for Docker containers
DOCKER_CTX=1 platypush \
--start-redis \
--config /etc/platypush/config.yaml \
--workdir /var/lib/platypush

View file

@ -0,0 +1,34 @@
#!/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 are running in a Docker context then we want to copy the docker-run.sh
# script where we can easily find it.
if [ -n "$DOCKER_CTX" ]; then
cp -v /install/platypush/install/scripts/docker-run.sh /run.sh
fi
# 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)" != "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}

View file

@ -0,0 +1 @@
debian

View file

@ -21,6 +21,7 @@ class BaseImage(Enum):
"""
ALPINE = 'alpine'
DEBIAN = 'debian'
UBUNTU = 'ubuntu'
def __str__(self) -> str:
@ -30,6 +31,7 @@ class BaseImage(Enum):
return self.value
# pylint: disable=too-few-public-methods
class DockerfileGenerator:
"""
Generate a Dockerfile from on a configuration file.
@ -40,6 +42,7 @@ class DockerfileGenerator:
_pkg_manager_by_base_image = {
BaseImage.ALPINE: PackageManagers.APK,
BaseImage.DEBIAN: PackageManagers.APT,
BaseImage.UBUNTU: PackageManagers.APT,
}
@ -54,6 +57,8 @@ class DockerfileGenerator:
:param cfgfile: Path to the configuration file.
:return: The content of the generated Dockerfile.
"""
import platypush
Config.init(self.cfgfile)
new_file_lines = []
ports = self._get_exposed_ports()
@ -66,7 +71,8 @@ class DockerfileGenerator:
is_after_expose_cmd = False
base_file = os.path.join(
str(pathlib.Path(inspect.getfile(Config)).parent),
str(pathlib.Path(inspect.getfile(platypush)).parent),
'install',
'docker',
f'{self.image}.Dockerfile',
)