WIP: Get started squashing things down

This commit is contained in:
IamTheFij 2020-01-21 17:44:02 -08:00
parent fea176f7f3
commit de8cf7aab8
5 changed files with 27 additions and 26 deletions

View File

@ -1,21 +1,22 @@
ARG REPO=library
FROM ${REPO}/python:3-alpine
# TODO: Copy from docker hub image
ARG ARCH=x86_64
COPY ./build/qemu-${ARCH}-static /usr/bin/
RUN mkdir -p /src
WORKDIR /src
COPY ./requirements.txt ./
RUN pip install -r ./requirements.txt
# Get Cloudflare example script
ENV CF_VERSION=2.6.0
ADD https://raw.githubusercontent.com/cloudflare/python-cloudflare/$CF_VERSION/examples/example_update_dynamic_dns.py ./update_ddns.py
RUN chmod +x ./update_ddns.py
COPY ./start.sh ./
COPY ./update_ddns.py ./update_ddns.py
RUN pip install cloudflare==$CF_VERSION
ENV DOMAIN=""
USER nobody
CMD [ "/src/start.sh" ]
ENTRYPOINT [ "/src/update_ddns.py" ]

View File

@ -1,4 +1,5 @@
DOCKER_TAG ?= cloudflare-ddns-dev-${USER}
.PHONY: clean all
.PHONY: default
default: test
@ -7,11 +8,6 @@ default: test
test:
@echo ok
.PHONY: update
update:
curl -o update_ddns.py https://raw.githubusercontent.com/cloudflare/python-cloudflare/master/examples/example_update_dynamic_dns.py
chmod +x update_ddns.py
.PHONY: build
build: build/qemu-x86_64-static
docker build . -t ${DOCKER_TAG}
@ -35,7 +31,8 @@ cross-build-arm64: build/qemu-aarch64-static
.PHONY: run
run: build
docker run --rm -e DOMAIN=${DOMAIN} \
docker run --rm \
-e CF_API_EMAIL=${CF_API_EMAIL} \
-e CF_API_KEY=${CF_API_KEY} \
${DOCKER_TAG}
${DOCKER_TAG} \
"${DOMAIN}"

View File

@ -4,18 +4,25 @@ Simple Docker image to dynamically update a Cloudflare DNS record.
## Usage
All parameters are passed to the script using env variables, so export the following:
There are two things to configure. First, the domain that you wish to update needs to be provided as a command line argument. This can be done by adding it to the end of your run command (example in the Makefile) or by adding it as a command to your compose file. Eg:
DOMAIN=sub.example.com
CF_API_EMAIL=admin@example.com
ddns:
image: IamTheFij/cloudflare-ddns
command: ["example.com"]
Your Cloudflare credentials can be passed in any way that [python-cloudflare](https://github.com/cloudflare/python-cloudflare) allows. Generally, either via envioronment variables:
CF_API_EMAIL=admin@example.com # Do not set if using an API Token
CF_API_KEY=00000000000000000000
CF_API_CERTKEY='v1.0-...'
Or by providing a file mounted to the working directory in the image, `/src/.cloudflare.cfg` that contains something like:
[CloudFlare]
emal = admin@example.com # Do not set if using an API Token
token = 00000000000000000000
certtoken = v1.0-...
Then run. To execute from this directory, you can use the convenient Make target.
make run
## Development
The script is straight from the examples provided by Cloudflare on their Github. The latest version can be downloaded using:
make update

View File

@ -1 +0,0 @@
cloudflare

View File

@ -1,3 +0,0 @@
#! /bin/sh
exec /src/update_ddns.py $DOMAIN