Minimal multi-stage docker build
This commit is contained in:
parent
a1e1348214
commit
df6b8a381a
16
.github/ISSUE_TEMPLATE/bug_report.md
vendored
16
.github/ISSUE_TEMPLATE/bug_report.md
vendored
@ -3,7 +3,7 @@ name: Bug report
|
||||
about: Create a report to help us improve
|
||||
title: ''
|
||||
labels: ''
|
||||
assignees: ''
|
||||
assignees: 'timothymiller'
|
||||
|
||||
---
|
||||
|
||||
@ -24,15 +24,15 @@ A clear and concise description of what you expected to happen.
|
||||
If applicable, add screenshots to help explain your problem.
|
||||
|
||||
**Desktop (please complete the following information):**
|
||||
- OS: [e.g. iOS]
|
||||
- Browser [e.g. chrome, safari]
|
||||
- Version [e.g. 22]
|
||||
- OS: [e.g. Arch Linux]
|
||||
- Browser [e.g. Chrome, Safari]
|
||||
- Version [e.g. 60]
|
||||
|
||||
**Smartphone (please complete the following information):**
|
||||
- Device: [e.g. iPhone6]
|
||||
- OS: [e.g. iOS8.1]
|
||||
- Browser [e.g. stock browser, safari]
|
||||
- Version [e.g. 22]
|
||||
- Device: [e.g. iPhone X]
|
||||
- OS: [e.g. iOS 14.0]
|
||||
- Browser [e.g. stock browser, Safari]
|
||||
- Version [e.g. 60]
|
||||
|
||||
**Additional context**
|
||||
Add any other context about the problem here.
|
||||
|
||||
69
.gitignore
vendored
69
.gitignore
vendored
@ -1,3 +1,4 @@
|
||||
# Private API keys for updating IPv4 & IPv6 addresses on Cloudflare
|
||||
config.json
|
||||
|
||||
# Byte-compiled / optimized / DLL files
|
||||
@ -39,43 +40,6 @@ MANIFEST
|
||||
pip-log.txt
|
||||
pip-delete-this-directory.txt
|
||||
|
||||
# Unit test / coverage reports
|
||||
htmlcov/
|
||||
.tox/
|
||||
.nox/
|
||||
.coverage
|
||||
.coverage.*
|
||||
.cache
|
||||
nosetests.xml
|
||||
coverage.xml
|
||||
*.cover
|
||||
*.py,cover
|
||||
.hypothesis/
|
||||
.pytest_cache/
|
||||
|
||||
# Translations
|
||||
*.mo
|
||||
*.pot
|
||||
|
||||
# Django stuff:
|
||||
*.log
|
||||
local_settings.py
|
||||
db.sqlite3
|
||||
db.sqlite3-journal
|
||||
|
||||
# Flask stuff:
|
||||
instance/
|
||||
.webassets-cache
|
||||
|
||||
# Scrapy stuff:
|
||||
.scrapy
|
||||
|
||||
# Sphinx documentation
|
||||
docs/_build/
|
||||
|
||||
# PyBuilder
|
||||
target/
|
||||
|
||||
# Jupyter Notebook
|
||||
.ipynb_checkpoints
|
||||
|
||||
@ -86,19 +50,6 @@ ipython_config.py
|
||||
# pyenv
|
||||
.python-version
|
||||
|
||||
# pipenv
|
||||
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
||||
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
||||
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
||||
# install all needed dependencies.
|
||||
#Pipfile.lock
|
||||
|
||||
# celery beat schedule file
|
||||
celerybeat-schedule
|
||||
|
||||
# SageMath parsed files
|
||||
*.sage.py
|
||||
|
||||
# Environments
|
||||
.env
|
||||
.venv
|
||||
@ -107,21 +58,3 @@ venv/
|
||||
ENV/
|
||||
env.bak/
|
||||
venv.bak/
|
||||
|
||||
# Spyder project settings
|
||||
.spyderproject
|
||||
.spyproject
|
||||
|
||||
# Rope project settings
|
||||
.ropeproject
|
||||
|
||||
# mkdocs documentation
|
||||
/site
|
||||
|
||||
# mypy
|
||||
.mypy_cache/
|
||||
.dmypy.json
|
||||
dmypy.json
|
||||
|
||||
# Pyre type checker
|
||||
.pyre/
|
||||
|
||||
18
.vscode/settings.json
vendored
Normal file
18
.vscode/settings.json
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
{
|
||||
"files.exclude": {
|
||||
"**/.git": true,
|
||||
"**/.svn": true,
|
||||
"**/.hg": true,
|
||||
"**/CVS": true,
|
||||
"**/.DS_Store": true,
|
||||
".github": true,
|
||||
".vscode": true,
|
||||
"LICENSE": true,
|
||||
"requirements.txt": true,
|
||||
"build-docker-image.sh": true,
|
||||
".gitignore": true,
|
||||
"Dockerfile": false,
|
||||
"start-sync.sh": false
|
||||
},
|
||||
"explorerExclude.backup": null
|
||||
}
|
||||
18
Dockerfile
Normal file
18
Dockerfile
Normal file
@ -0,0 +1,18 @@
|
||||
# ---- Base ----
|
||||
FROM python:alpine AS base
|
||||
|
||||
#
|
||||
# ---- Dependencies ----
|
||||
FROM base AS dependencies
|
||||
# install dependencies
|
||||
COPY requirements.txt .
|
||||
RUN pip install -r requirements.txt
|
||||
|
||||
#
|
||||
# ---- Release ----
|
||||
FROM dependencies AS release
|
||||
# copy project file(s)
|
||||
WORKDIR /
|
||||
COPY cloudflare-ddns.py .
|
||||
COPY config.json .
|
||||
CMD ["python", "/cloudflare-ddns.py"]
|
||||
1
build-docker-image.sh
Executable file
1
build-docker-image.sh
Executable file
@ -0,0 +1 @@
|
||||
docker build -t timothymiller/cloudflare-ddns:latest .
|
||||
@ -104,6 +104,27 @@ def cf_api(endpoint, method, config, headers={}, data=False):
|
||||
|
||||
return response.json()
|
||||
|
||||
for ip in getIPs():
|
||||
print("Checking " + ip["type"] + " records")
|
||||
commitRecord(ip)
|
||||
# Scheduling
|
||||
import time, traceback
|
||||
|
||||
def every(delay, task):
|
||||
next_time = time.time() + delay
|
||||
while True:
|
||||
time.sleep(max(0, next_time - time.time()))
|
||||
try:
|
||||
task()
|
||||
except Exception:
|
||||
traceback.print_exc()
|
||||
# in production code you might want to have this instead of course:
|
||||
# logger.exception("Problem while executing repetitive task.")
|
||||
# skip tasks if we are behind schedule:
|
||||
next_time += (time.time() - next_time) // delay * delay + delay
|
||||
|
||||
def updateIPs():
|
||||
for ip in getIPs():
|
||||
print("Checking " + ip["type"] + " records")
|
||||
commitRecord(ip)
|
||||
|
||||
updateIPs()
|
||||
import threading
|
||||
threading.Thread(target=lambda: every(60*15, updateIPs)).start()
|
||||
1
requirements.txt
Normal file
1
requirements.txt
Normal file
@ -0,0 +1 @@
|
||||
requests==2.24.0
|
||||
@ -4,7 +4,7 @@ DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
|
||||
python3 -m venv venv
|
||||
source ./venv/bin/activate
|
||||
|
||||
pip install requests
|
||||
pip3 install requests
|
||||
|
||||
cd $DIR
|
||||
python3 cloudflare-ddns.py
|
||||
|
||||
Reference in New Issue
Block a user