Added docker-compose build steps to README.md

This commit is contained in:
timothymiller 2020-08-05 13:30:33 -04:00
parent 7e8791c879
commit 1e55144bf2
6 changed files with 61 additions and 14 deletions

View File

@ -9,7 +9,7 @@
".vscode": true,
"LICENSE": true,
"requirements.txt": true,
"build-docker-image.sh": true,
"build-docker-image.sh": false,
".gitignore": true,
"Dockerfile": false,
"start-sync.sh": false,

View File

@ -14,5 +14,4 @@ FROM dependencies AS release
# copy project file(s)
WORKDIR /
COPY cloudflare-ddns.py .
COPY config.json .
CMD ["python", "/cloudflare-ddns.py", "--repeat"]

View File

@ -45,14 +45,54 @@ Alternatively, you can use the traditional API keys by setting appropriate value
## :fax: Hosting multiple domains on the same IP?
You can save yourself some trouble when hosting multiple domains pointing to the same IP address (in the case of Traefik) by defining one A & AAAA record 'ddns.example.com' pointing to the IP of the server that will be updated by this DDNS script. For each subdomain, create a CNAME record pointing to 'ddns.example.com'. Now you don't have to manually modify the script config every time you add a new subdomain to your site!
## :whale: Deploy to Docker
## :whale: Deploy with Docker Compose
Create a config.json file with your production credentials and run the build-docker-image script.
Modify the host file path of config.json inside the volumes section of docker-compose.yml.
```yml
version: "3.7"
services:
cloudflare-ddns:
image: timothymiller/cloudflare-ddns:latest
container_name: cloudflare-ddns
security_opt:
- no-new-privileges:true
environment:
- PUID=1000
- PGID=1000
volumes:
- /EDIT/YOUR/PATH/HERE/config.json:/config.json
restart: unless-stopped
```
### :running: Running
From the project root directory
```bash
docker-compose up -d
```
### Building from source
Create a config.json file with your production credentials.
Give build-docker-image.sh permission to execute.
```bash
sudo chmod +x ./build-docker-image.sh
```
At project root, run the build-docker-image.sh script.
```bash
chmod +x ./build-docker-image.sh
./build-docker-image.sh
docker run -d timothymiller/cloudflare_ddns:latest
```
#### Run the locally compiled version
```bash
docker run -d timothyjmiller/cloudflare_ddns:latest
```
## :penguin: (legacy) Linux + cron instructions (all distros)

View File

@ -1 +1 @@
docker build -t timothymiller/cloudflare-ddns:latest .
docker build -t timothyjmiller/cloudflare-ddns:latest .

View File

@ -1,7 +1,5 @@
import requests
import json
import sys
import os
import requests, json, sys, os
import time, traceback
PATH = os.getcwd() + "/"
version = float(str(sys.version_info[0]) + "." + str(sys.version_info[1]))
@ -104,9 +102,6 @@ def cf_api(endpoint, method, config, headers={}, data=False):
return response.json()
# Scheduling
import time, traceback
def every(delay, task):
next_time = time.time() + delay
while True:

13
docker-compose.yml Normal file
View File

@ -0,0 +1,13 @@
version: "3.7"
services:
cloudflare-ddns:
image: timothymiller/cloudflare-ddns:latest
container_name: cloudflare-ddns
security_opt:
- no-new-privileges:true
environment:
- PUID=1000
- PGID=1000
volumes:
- /EDIT/YOUR/PATH/HERE/config.json:/config.json
restart: unless-stopped