ClouDNS updater script is able to be run either as generic Python 3 script or as Docker container.
When this app runs out of a container it uses an .env file to load config. The file format is as follows:
export URL_CDNS = 'https://ipv4.cloudns.net/api/dynamicURL/?q=..........'
export URL_IPIO = 'https://ipinfo.io/json'
export LOG_FILE = 'iplog.txt'
export HOSTNAME = 'put.yourhostname.here'
export SLEEPTIME = 600
Notes:
- In this script IPInfo service for IP resolution is used. The URL used returns a JSON with a key named "ip" with an IP address as value. You can change this service provider transparently without altering the code meanwhile a JSON is returned with a key named "ip", in lower case letters, and an IP address is included as value.
- In order to get the URL_CDNS for your ClouDNS HOSTNAME you must follow guidance in ClouDNS KB at https://www.cloudns.net/wiki/article/36/. Please note URL_CDNS and HOSTNAME are related. Each HOSTNAME in ClouDNS will have a unique URL_CDNS.
- SLEEPTIME value is seconds, thus, 600 in seconds is 10 minutes.
- Repository: https://hub.docker.com/r/ea1het/cloudns-updater
- Alternatively you can pull directly from docker CLI with
docker pull ea1het/cloudns-updater
In Docker, the way to export variables is to define them on the docker run
execution, on a execution line similar to this:
docker run \
-d --restart unless-stopped \
--name cloudns-updater \
-e URL_CDNS="https://ipv4.cloudns.net/api/dynamicURL/?q=.........." \
-e URL_IPIO="https://ipinfo.io/json" \
-e LOG_FILE="iplog.txt" \
-e HOSTNAME="put.yourhostname.here" \
-e SLEEPTIME=600 \
ea1het/cloudns-updater:latest
Note: It can happen that you cannot see logs from the docker container while it's in execution. This is caused due to Python buffered output. In order to see logs from the container buffered output must be disabled for this specific container. This can be done in two ways, a) setting an environment variable or b) using a modifier for the Python interpreter. The prefered option is the first because it doesn't imply modifying the container. In any case, for the sake of the explanation, following are the options explained:
- Environment variable: set
PYTHONUNBUFFERED=0
in the container execution command (in CLI or in a UI like Portainer). - Interpreter modifier: use
python -u app.py
inside the container (in development or in run time) or craft the appropiate changes in the Dockerfile:ENTRYPOINT ["python3"] CMD ["-u", "app.py"]
docker build \
--build-arg VCS_REF=`git rev-parse --short HEAD` \
--build-arg BUILD_DATE=`date -u +"%Y-%m-%d"` \
--build-arg VERSION=v1.0 \
-t ea1het/cloudns-updater:latest .
Cross-compilation is an experimental Docker feature. You can enable it in your Docker Desktop settings. The procedure to cross-compile can be briefly resumed this way:
- Ensure cross-compiler is available:
docker buildx ls
- Create a new builder instance (a container):
docker buildx create --name testbuilder
- Switch to 'testbuilder' builder instance:
docker buildx use testbuilder
- Ensure 'testbuilder' builder is ready to be used:
docker buildx inspect --bootstrap
- If needed, authenticate against Docker Hub:
docker login
- Clone locally the repo you want to cross compile:
git clone https://.....
- Finally, execute buildx build sentences for the platform you want to cross-compile. Examples below.
docker buildx build \
--platform linux/arm/v7 \
--build-arg VCS_REF=`git rev-parse --short HEAD` \
--build-arg BUILD_DATE=`date -u +"%Y-%m-%d"` \
--build-arg VERSION=v1.0 \
-t ea1het/cloudns-updater:latest-armv7 --push .
docker buildx build \
--platform linux/arm/v6 \
--build-arg VCS_REF=`git rev-parse --short HEAD` \
--build-arg BUILD_DATE=`date -u +"%Y-%m-%d"` \
--build-arg VERSION=v1.0 \
-t ea1het/cloudns-updater:latest-armv6 --push .
docker buildx build \
--platform linux/arm64 \
--build-arg VCS_REF=`git rev-parse --short HEAD` \
--build-arg BUILD_DATE=`date -u +"%Y-%m-%d"` \
--build-arg VERSION=v1.0 \
-t ea1het/cloudns-updater:latest-arm64 --push .
docker buildx build \
--platform linux/amd64 \
--build-arg VCS_REF=`git rev-parse --short HEAD` \
--build-arg BUILD_DATE=`date -u +"%Y-%m-%d"` \
--build-arg VERSION=v1.0 \
-t ea1het/cloudns-updater:latest-amd64 --push .