Compare commits

...

4 Commits

Author SHA1 Message Date
Jonas Forsberg
23615777b7 added autobuild 2023-04-17 14:13:30 +02:00
Jonas Forsberg
f860eba8a2 fixed entrypoint and using tumbleweed version instead of restic verson as tag 2023-04-17 14:12:51 +02:00
Jonas Forsberg
a06e4e8f0a fixed tag too reflect TW version 2023-04-17 13:33:47 +02:00
Jonas Forsberg
58a2f63bbe cleaned up git clean checks 2023-04-17 13:33:20 +02:00
4 changed files with 73 additions and 15 deletions

View File

@ -1,10 +1,13 @@
FROM registry.opensuse.org/opensuse/tumbleweed:latest
ARG VERSION ARG VERSION
FROM registry.opensuse.org/opensuse/tumbleweed:${VERSION}
RUN zypper --non-interactive install \ RUN zypper --non-interactive install \
openssh-clients \ openssh-clients \
restic-${VERSION} \ restic \
&& zypper clean -a && zypper clean -a
ADD entrypoint.sh /usr/local/bin/entrypoint.sh
COPY entrypoint.sh /usr/local/bin/entrypoint.sh
RUN chmod +x /usr/local/bin/entrypoint.sh
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"] ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]
CMD ["start"]

View File

@ -1,13 +1,25 @@
.PHONY: default build clean .PHONY: default build clean release require_clean_git
-include .env -include .env
VERSION=0.15.1-1.2 VERSION=20230411
IMAGENAME=restic
REPO=docker.io/bardak
SHELL := /bin/bash SHELL := /bin/bash
guard: require_clean_git:
@ if [ -z "$(git status --porcelain)" ]; then echo "git repo not clean"; exit 1; fi git update-index -q --ignore-submodules --refresh
git diff-files --quiet --ignore-submodules
git diff-index --cached --quiet --ignore-submodules HEAD --
@status=$$(git status --porcelain); \
if test "x$${status}" = x; then \
echo "No untracked files detected"; \
else \
echo "Untracked files detected" >&2; \
exit 1; \
fi
default: build default: build
@ -17,5 +29,10 @@ build:
clean: clean:
podman image rm docker.io/bardak/restic:$(VERSION) podman image rm docker.io/bardak/restic:$(VERSION)
push: guard build release: require_clean_git build
podman push --creds $(USERNAME):$(PASSWORD) docker.io/bardak/restic:$(VERSION) $(eval TMP_MESSAGE := $(shell podman run --rm -it ${REPO}/${IMAGENAME}:$(VERSION) /usr/bin/restic --version))
git tag -a v$(VERSION) -m "${TMP_MESSAGE}"
git push origin v$(VERSION)
podman tag ${REPO}/${IMAGENAME}:$(VERSION) ${REPO}/${IMAGENAME}:latest
podman push --creds $(USERNAME):$(PASSWORD) ${REPO}/${IMAGENAME}:$(VERSION)
podman push --creds $(USERNAME):$(PASSWORD) ${REPO}/${IMAGENAME}:latest

38
autobuild.sh Executable file
View File

@ -0,0 +1,38 @@
#!/usr/bin/env bash
set -aeou pipefail
BASE_IMAGE="registry.opensuse.org/opensuse/tumbleweed"
PACKAGE_NAME="restic"
echo "Pulling latest tumbleweed"
podman pull "${BASE_IMAGE}:latest"
CURRENT_TUMBLEWEED_TAG="$(sed -n 's/.*VERSION=\([0-9]\)/\1/p' Makefile)"
LATEST_TUMBLEWEED_TAG="$(podman image inspect --format "{{.Labels}}" registry.opensuse.org/opensuse/tumbleweed:latest | sed -n 's/.*org\.opencontainers\.image\.version:\([0-9]\{8\}\).*/\1/p')"
if [[ "$CURRENT_TUMBLEWEED_TAG" == "$LATEST_TUMBLEWEED_TAG" ]]; then
echo "Already running latest tumbleweed version"
exit 0
fi
echo "New tumbleweed image exists"
CURRENT_VERSION="$(podman run --rm -it ${BASE_IMAGE}:${CURRENT_TUMBLEWEED_TAG} /usr/bin/bash -c "zypper ref > /dev/null && zypper info $PACKAGE_NAME | sed -n 's/.*Version : \(.*\)$/\1/p'")"
LATEST_VERSION="$(podman run --rm -it ${BASE_IMAGE}:latest /usr/bin/bash -c "zypper ref > /dev/null && zypper info $PACKAGE_NAME | sed -n 's/.*Version : \(.*\)$/\1/p'")"
echo "current : $CURRENT_VERSION"
echo "latest : $LATEST_VERSION"
if [[ "$CURRENT_VERSION" == "$LATEST_VERSION" ]]; then
echo "No new $PACKAGE_NAME version detected"
exit 0
fi
#Updateing Makefile with latest image tag
sed -i 's/VERSION='"$CURRENT_TUMBLEWEED_TAG"'/VERSION='"$LATEST_TUMBLEWEED_TAG"'/' Makefile
git add Makefile
git commit -m "Updated tumpleweed image to $LATEST_TUMBLEWEED_TAG, $PACKAGE_NAME to $LATEST_VERSION"
git push
echo "build and push new image"
make release

10
entrypoint.sh Executable file → Normal file
View File

@ -1,8 +1,8 @@
#!/bin/bash #!/usr/bin/env bash
#
if [[ "$1" == "bash" ]]; then
exec /usr/bin/bash if [[ "$1" == "start" ]]; then
/usr/bin/restic "$@"
else else
restic "$@" exec "$@"
fi fi