Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run as non-root user #182

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
6 changes: 6 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Ignore everything
*

# Allow specific files and folders
!/requirements.txt
!/cloudflare-ddns.py
1 change: 1 addition & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"**/Thumbs.db": true,
".github": true,
".gitignore": true,
".dockerignore": true,
".vscode": true,
"Dockerfile": true,
"LICENSE": true,
Expand Down
8 changes: 6 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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"]
4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 1 addition & 4 deletions docker/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
version: '3.9'
services:
cloudflare-ddns:
image: timothyjmiller/cloudflare-ddns:latest
container_name: cloudflare-ddns
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