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 ARG REPO=library
FROM ${REPO}/python:3-alpine FROM ${REPO}/python:3-alpine
# TODO: Copy from docker hub image
ARG ARCH=x86_64 ARG ARCH=x86_64
COPY ./build/qemu-${ARCH}-static /usr/bin/ COPY ./build/qemu-${ARCH}-static /usr/bin/
RUN mkdir -p /src RUN mkdir -p /src
WORKDIR /src WORKDIR /src
COPY ./requirements.txt ./ # Get Cloudflare example script
RUN pip install -r ./requirements.txt 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 ./ RUN pip install cloudflare==$CF_VERSION
COPY ./update_ddns.py ./update_ddns.py
ENV DOMAIN="" ENV DOMAIN=""
USER nobody USER nobody
CMD [ "/src/start.sh" ] ENTRYPOINT [ "/src/update_ddns.py" ]

View File

@ -1,4 +1,5 @@
DOCKER_TAG ?= cloudflare-ddns-dev-${USER} DOCKER_TAG ?= cloudflare-ddns-dev-${USER}
.PHONY: clean all
.PHONY: default .PHONY: default
default: test default: test
@ -7,11 +8,6 @@ default: test
test: test:
@echo ok @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 .PHONY: build
build: build/qemu-x86_64-static build: build/qemu-x86_64-static
docker build . -t ${DOCKER_TAG} docker build . -t ${DOCKER_TAG}
@ -35,7 +31,8 @@ cross-build-arm64: build/qemu-aarch64-static
.PHONY: run .PHONY: run
run: build run: build
docker run --rm -e DOMAIN=${DOMAIN} \ docker run --rm \
-e CF_API_EMAIL=${CF_API_EMAIL} \ -e CF_API_EMAIL=${CF_API_EMAIL} \
-e CF_API_KEY=${CF_API_KEY} \ -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 ## 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 ddns:
CF_API_EMAIL=admin@example.com 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_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. Then run. To execute from this directory, you can use the convenient Make target.
make run 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