diff --git a/.github/workflows/docker-release.yml b/.github/workflows/container.yml similarity index 75% rename from .github/workflows/docker-release.yml rename to .github/workflows/container.yml index 4119b52..c63491f 100644 --- a/.github/workflows/docker-release.yml +++ b/.github/workflows/container.yml @@ -1,7 +1,12 @@ -name: 'docker' +name: 'container' on: push: + branches: + - main + tags: + - '*' + workflow_dispatch: jobs: release: @@ -17,6 +22,12 @@ jobs: uses: 1466587594/get-current-time@v1 id: current-time + - name: Docker meta + id: meta + uses: docker/metadata-action@v3 + with: + images: ${{ secrets.DOCKER_USERNAME }}/${{ secrets.DOCKER_IMAGE }},ghcr.io/${{ github.repository }} + - name: Login to DockerHub uses: docker/login-action@v1 with: @@ -44,7 +55,6 @@ jobs: push: true build-args: | BUILD_DATE=${{ steps.current-time.outputs.time }} + VERSION=${{ github.ref_name }} VCS_REF=${{ env.GITHUB_SHA_SHORT }} - tags: | - ghcr.io/${{ github.repository }}:latest - ${{ secrets.DOCKER_USERNAME }}/${{ secrets.DOCKER_IMAGE }}:latest + tags: ${{ steps.meta.outputs.tags }} diff --git a/Dockerfile b/Dockerfile index 817e6d6..9d09f04 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,34 +1,30 @@ -FROM php:7-cli-alpine +FROM php:8-cli-alpine ARG BUILD_DATE ARG VCS_REF +ARG VERSION -ENV SCHEDULE "*/10 * * * *" +ENV SCHEDULE="*/10 * * * *" \ + CRON_CMD="php /app/updater.php" \ + DOMAIN="" \ + MODE="@" \ + IPV4="yes" \ + IPV6="no" \ + TTL="0" \ + CUSTOMER_ID="" \ + API_KEY="" \ + API_PASSWORD="" \ + FORCE="no" -ENV DOMAIN "" +ADD rootfs/ / -ENV MODE "@" +ENTRYPOINT ["/entrypoint.sh"] -ENV IPV4 "yes" -ENV IPV6 "no" +CMD ["/usr/sbin/crond", "-f"] -ENV TTL "0" - -ENV CUSTOMER_ID "" -ENV API_KEY "" -ENV API_PASSWORD "" - -ENV FORCE "no" - -RUN mkdir /app/ - -ADD . /app/ - -RUN echo "@reboot php /app/updater.php" > /etc/crontabs/root && \ - echo "${SCHEDULE} php /app/updater.php" >> /etc/crontabs/root - -CMD ["/usr/sbin/crond", "-l", "2", "-f"] +SHELL ["/bin/ash"] LABEL org.opencontainers.image.created=${BUILD_DATE} \ org.opencontainers.image.revision=${VCS_REF} \ + org.opencontainers.image.revision=${VERSION} \ org.opencontainers.image.source="https://github.com/b2un0/docker-netcup-dyndns" diff --git a/README.md b/README.md index d48c7af..a9d7408 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # Netcup DNS API DynDNS Docker Client ![Docker Pulls](https://img.shields.io/docker/pulls/b2un0/netcup-dyndns.svg) -![Docker Build](https://github.com/b2un0/docker-netcup-dyndns/workflows/docker/badge.svg?branch=master&event=push) +![Docker Build](https://github.com/b2un0/docker-netcup-dyndns/workflows/container/badge.svg?branch=master&event=push) ![MicroBadger Size](https://img.shields.io/docker/image-size/b2un0/netcup-dyndns.svg) ## Credits diff --git a/src/Client.php b/rootfs/app/src/Client.php similarity index 100% rename from src/Client.php rename to rootfs/app/src/Client.php diff --git a/src/Config.php b/rootfs/app/src/Config.php similarity index 100% rename from src/Config.php rename to rootfs/app/src/Config.php diff --git a/src/DynDNS.php b/rootfs/app/src/DynDNS.php similarity index 100% rename from src/DynDNS.php rename to rootfs/app/src/DynDNS.php diff --git a/updater.php b/rootfs/app/updater.php similarity index 84% rename from updater.php rename to rootfs/app/updater.php index 7ef81aa..33dd17b 100755 --- a/updater.php +++ b/rootfs/app/updater.php @@ -9,13 +9,13 @@ require_once __DIR__ . '/src/Config.php'; if ('yes' === $_ENV['IPV4']) { - $ipv4 = trim(file_get_contents('https://v4.ident.me')); + $ipv4 = trim(file_get_contents('http://v4.ident.me')); } else { $ipv4 = null; } if ('yes' === $_ENV['IPV6']) { - $ipv6 = trim(file_get_contents('https://v6.ident.me')); + $ipv6 = trim(file_get_contents('http://v6.ident.me')); } else { $ipv6 = null; } diff --git a/rootfs/entrypoint.sh b/rootfs/entrypoint.sh new file mode 100755 index 0000000..6dc3a31 --- /dev/null +++ b/rootfs/entrypoint.sh @@ -0,0 +1,12 @@ +#!/bin/ash -e + +echo "startup $0" + +if [ ! -z "${SCHEDULE}" ] && [ ! -z "${CRON_CMD}" ]; then + echo "configure cron: ${SCHEDULE} ${CRON_CMD}" + echo "@reboot ${CRON_CMD}" > /etc/crontabs/root + echo "${SCHEDULE} ${CRON_CMD}" >> /etc/crontabs/root +fi + +echo "run: $@" +exec "$@"