Compare commits

...

2 Commits

Author SHA1 Message Date
Ricard Illa 6d8109d9a0
static page builder for ci 2022-08-22 12:20:17 +02:00
Ricard Illa ed6ca7774e
rsync client, to use with ci 2022-08-22 12:19:18 +02:00
5 changed files with 114 additions and 0 deletions

10
rsync/Dockerfile Normal file
View File

@ -0,0 +1,10 @@
FROM alpine:3.16
COPY entrypoint.sh /entrypoint
RUN chmod +x /entrypoint && \
apk add --no-cache \
openssh-client \
rsync
ENTRYPOINT ["/entrypoint"]

19
rsync/Makefile Normal file
View File

@ -0,0 +1,19 @@
IMG_NAME=rsync
REGISTRY=registry.monotremata.xyz
IMG=$(REGISTRY)/$(IMG_NAME)
PLATFORMS=linux/amd64,linux/arm64
.PHONY: build push buildx
build: Dockerfile entrypoint.sh
docker build -t $(IMG) .
push: build
docker image push $(IMG)
buildx: Dockerfile entrypoint.sh
docker buildx build \
--platform $(PLATFORMS) \
--tag $(IMG) \
--push \
.

51
rsync/entrypoint.sh Normal file
View File

@ -0,0 +1,51 @@
#!/bin/sh
set -e
# check settings
HOST="${HOST:-${PLUGIN_HOST}}"
if [ -z "$HOST" ]; then
echo "'host' must be specified"
exit 1
fi
USER="${USER:-${PLUGIN_USER:-root}}"
SSH_KEY="${SSH_KEY:-${PLUGIN_KEY}}"
if [ -z "$SSH_KEY" ]; then
echo "ssh_key must be specified"
exit 1
fi
KNOWN_HOSTS="${KNOWN_HOSTS:=${PLUGIN_KNOWN_HOSTS}}"
SOURCE="${SOURCE:-${PLUGIN_SOURCE}}"
if [ -z "$SOURCE" ]; then
echo "'source' must be specified"
exit 1
fi
TARGET="${TARGET:-${PLUGIN_TARGET}}"
if [ -z "$TARGET" ]; then
echo "'target' must be specified"
exit 1
fi
ARGS=${ARGS:-${PLUGIN_ARGS}}
# prepare SSH
mkdir -p "$HOME/.ssh"
keyfile="$HOME/.ssh/id_rsa"
echo "$SSH_KEY" > "$keyfile"
chmod 0600 "$keyfile"
known_hosts_file="${HOME}/.ssh/known_hosts"
[ -n "${KNOWN_HOSTS}" ] && echo "${KNOWN_HOSTS}" >> "$known_hosts_file"
[ -f "${known_hosts_file}" ] && chmod 0600 "$known_hosts_file"
# run rsync
# shellcheck disable=SC2086
exec rsync $ARGS "${SOURCE}" "${USER}"@"${HOST}":"${TARGET}"

View File

@ -0,0 +1,15 @@
# maybe switch to a stable version of alpine once tidyhtml is avaiblable there
FROM alpine:edge
# py3-pip is only needed to install j2cli, but python3 and py3-setuptools are
# also needed to run it
RUN apk add --no-cache \
findutils \
make \
py3-pip \
py3-setuptools \
python3 \
sassc \
tidyhtml && \
pip install j2cli[yaml] && \
apk del py3-pip

View File

@ -0,0 +1,19 @@
IMG_NAME=static-page-builder
REGISTRY=registry.monotremata.xyz
IMG=$(REGISTRY)/$(IMG_NAME)
PLATFORMS=linux/amd64,linux/arm64
.PHONY: build push buildx
build: Dockerfile
docker build -t $(IMG) .
push: build
docker image push $(IMG)
buildx: Dockerfile
docker buildx build \
--platform $(PLATFORMS) \
--tag $(IMG) \
--push \
.