Skip to content

Commit

Permalink
Added docker-compose build steps to README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
timothymiller committed Aug 5, 2020
1 parent 7e8791c commit 1e55144
Show file tree
Hide file tree
Showing 6 changed files with 61 additions and 14 deletions.
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
1 change: 0 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
48 changes: 44 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

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.

Create a config.json file with your production credentials and run the build-docker-image script.
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)
Expand Down
2 changes: 1 addition & 1 deletion build-docker-image.sh
Original file line number Diff line number Diff line change
@@ -1 +1 @@
docker build -t timothymiller/cloudflare-ddns:latest .
docker build -t timothyjmiller/cloudflare-ddns:latest .
9 changes: 2 additions & 7 deletions cloudflare-ddns.py
Original file line number Diff line number Diff line change
@@ -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]))
Expand Down Expand Up @@ -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:
Expand Down
13 changes: 13 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 1e55144

Please sign in to comment.