Make Dockerfiles work both within and outside a Platypush source dir.

If the Platypush setup.py is found in the current directory, then use
that directory as the base for the new image.

Otherwise, clone the repo on the fly and build the image from there.
This commit is contained in:
Fabio Manganiello 2024-05-25 00:42:30 +02:00
parent 0fd2992894
commit 8e05a7f4c9
Signed by untrusted user: blacklight
GPG key ID: D90FBA7F76362774
5 changed files with 53 additions and 14 deletions

View file

@ -1,6 +1,5 @@
services:
platypush:
container_name: platypush
restart: "always"
command:
- platypush

View file

@ -1,14 +1,24 @@
FROM alpine
ADD . /install
WORKDIR /var/lib/platypush
ARG DOCKER_CTX=1
ENV DOCKER_CTX=1
WORKDIR /var/lib/platypush
RUN apk update && \
/install/platypush/install/scripts/alpine/install.sh && \
cd /install && pip install -U --no-input --no-cache-dir . --break-system-packages && \
RUN --mount=type=bind,source=.,target=/curdir \
apk update && \
# If the current directory is the Platypush repository, then we can copy the existing files \
if grep 'name="platypush"' /curdir/setup.py >/dev/null 2>&1; \
then \
cp -r /curdir /install; \
# Otherwise, we need to clone the repository \
else \
apk add --no-cache git && \
git clone https://github.com/blacklight/platypush.git /install; \
fi
RUN /install/platypush/install/scripts/alpine/install.sh && \
cd /install && \
pip install -U --no-input --no-cache-dir . --break-system-packages && \
rm -rf /install && \
apk cache clean

View file

@ -1,6 +1,5 @@
FROM debian
ADD . /install
WORKDIR /var/lib/platypush
ARG DEBIAN_FRONTEND=noninteractive
@ -8,8 +7,19 @@ ENV DEBIAN_FRONTEND=noninteractive
ARG DOCKER_CTX=1
ENV DOCKER_CTX=1
RUN apt update && \
/install/platypush/install/scripts/debian/install.sh && \
RUN --mount=type=bind,source=.,target=/curdir \
apt update && \
# If the current directory is the Platypush repository, then we can copy the existing files \
if grep 'name="platypush"' /curdir/setup.py >/dev/null 2>&1; \
then \
cp -r /curdir /install; \
# Otherwise, we need to clone the repository \
else \
apt install -y git && \
git clone https://github.com/blacklight/platypush.git /install; \
fi
RUN /install/platypush/install/scripts/debian/install.sh && \
cd /install && \
pip install -U --no-input --no-cache-dir . --break-system-packages && \
rm -rf /install && \

View file

@ -1,11 +1,21 @@
FROM fedora
ADD . /install
WORKDIR /var/lib/platypush
ARG DOCKER_CTX=1
ENV DOCKER_CTX=1
RUN --mount=type=bind,source=.,target=/curdir \
# If the current directory is the Platypush repository, then we can copy the existing files \
if grep 'name="platypush"' /curdir/setup.py >/dev/null 2>&1; \
then \
cp -r /curdir /install; \
# Otherwise, we need to clone the repository \
else \
dnf install -y git && \
git clone https://github.com/blacklight/platypush.git /install; \
fi
# Enable the RPM Fusion repository
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 && \

View file

@ -1,6 +1,5 @@
FROM ubuntu
ADD . /install
WORKDIR /var/lib/platypush
ARG DEBIAN_FRONTEND=noninteractive
@ -8,8 +7,19 @@ ENV DEBIAN_FRONTEND=noninteractive
ARG DOCKER_CTX=1
ENV DOCKER_CTX=1
RUN apt update && \
/install/platypush/install/scripts/debian/install.sh && \
RUN --mount=type=bind,source=.,target=/curdir \
apt update && \
# If the current directory is the Platypush repository, then we can copy the existing files \
if grep 'name="platypush"' /curdir/setup.py >/dev/null 2>&1; \
then \
cp -r /curdir /install; \
# Otherwise, we need to clone the repository \
else \
apt install -y git && \
git clone https://github.com/blacklight/platypush.git /install; \
fi
RUN /install/platypush/install/scripts/debian/install.sh && \
cd /install && \
pip install -U --no-input --no-cache-dir . --break-system-packages && \
rm -rf /install && \