Skip to content

Commit

Permalink
add entrypoint so SCHEDULE really works
Browse files Browse the repository at this point in the history
  • Loading branch information
b2un0 committed Apr 1, 2022
1 parent 3d870ff commit b644de0
Show file tree
Hide file tree
Showing 8 changed files with 47 additions and 29 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
name: 'docker'
name: 'container'

on:
push:
branches:
- main
tags:
- '*'
workflow_dispatch:

jobs:
release:
Expand All @@ -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:
Expand Down Expand Up @@ -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 }}
40 changes: 18 additions & 22 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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"
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions updater.php → rootfs/app/updater.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
12 changes: 12 additions & 0 deletions rootfs/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -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 "$@"

0 comments on commit b644de0

Please sign in to comment.