diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..0a56b6f --- /dev/null +++ b/.dockerignore @@ -0,0 +1,6 @@ +# Ignore everything +* + +# Allow specific files and folders +!/requirements.txt +!/cloudflare-ddns.py diff --git a/.vscode/settings.json b/.vscode/settings.json index 4f20a6d..a90a6ea 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -8,6 +8,7 @@ "**/Thumbs.db": true, ".github": true, ".gitignore": true, + ".dockerignore": true, ".vscode": true, "Dockerfile": true, "LICENSE": true, diff --git a/Dockerfile b/Dockerfile index a66379b..1830201 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,18 +1,22 @@ # ---- Base ---- FROM python:alpine AS base +ENV VENV_DIR="/app" +ENV PATH="${VENV_DIR}/bin:$PATH" + # # ---- Dependencies ---- FROM base AS dependencies # install dependencies COPY requirements.txt . -RUN pip install --user -r requirements.txt +RUN python3 -m venv "${VENV_DIR}" +RUN pip install -r requirements.txt # # ---- Release ---- FROM base AS release # copy installed dependencies and project source file(s) WORKDIR / -COPY --from=dependencies /root/.local /root/.local +COPY --from=dependencies "${VENV_DIR}" "${VENV_DIR}" COPY cloudflare-ddns.py . CMD ["python", "-u", "/cloudflare-ddns.py", "--repeat"] diff --git a/README.md b/README.md index a9f82f2..3265cd3 100755 --- a/README.md +++ b/README.md @@ -291,9 +291,7 @@ services: security_opt: - no-new-privileges:true network_mode: 'host' - environment: - - PUID=1000 - - PGID=1000 + user: 1000:1000 volumes: - /YOUR/PATH/HERE/config.json:/config.json restart: unless-stopped diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml index bb8b21c..20f0910 100644 --- a/docker/docker-compose.yml +++ b/docker/docker-compose.yml @@ -1,4 +1,3 @@ -version: '3.9' services: cloudflare-ddns: image: timothyjmiller/cloudflare-ddns:latest @@ -6,9 +5,7 @@ services: security_opt: - no-new-privileges:true network_mode: 'host' - environment: - - PUID=1000 - - PGID=1000 + user: 1000:1000 volumes: - /YOUR/PATH/HERE/config.json:/config.json restart: unless-stopped