-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Expand dockerfile with docker-compose doco DOCKER.md add venv doco to README.md add gitignore to exclude python venv Signed-off-by: Nic Boet <[email protected]>
- Loading branch information
Showing
5 changed files
with
81 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
venv* | ||
.cache/* | ||
*.zone |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
# Docker | ||
|
||
Dockerfile and docker-compose.yml provide alternative for installations and development | ||
|
||
Some tweaking is expected to suit a production deployment | ||
|
||
## Build | ||
|
||
```shell | ||
docker-compose build | ||
``` | ||
|
||
## AdBlock Zone | ||
|
||
The example container writes the generated rpz-adblocker.zone file under /bind-adblock | ||
|
||
Docker-compose file has an options for using either a volume (i.e containerized bind9 integration) or host mount point (i.e. bind9 running on the docker host os) for that path. | ||
|
||
## Deploy | ||
|
||
```shell | ||
docker-compose up -d | ||
``` | ||
|
||
## Running Considerations | ||
|
||
### Cron | ||
|
||
The current image runs the python script at startup and then exits. | ||
There is no cron scheduler provided at this time. | ||
|
||
### On Demand | ||
|
||
Once deployed, issuing a run will start the container again, run the update script, then exit after writing the zone file. | ||
|
||
```shell | ||
docker run bind-adblock_updater | ||
``` | ||
|
||
### Bind9 Zone reloads | ||
|
||
You might wish to combine bind-adblock and bind9 into the same container in which a cron service controls executing this python script and in turn can trigger named to reload the zone. | ||
|
||
An aggressive workaround is start the adblock updater container then fully restart the bind9 container. | ||
|
||
```shell | ||
docker-compose up updater >/dev/null 2>&1 && docker-compose restart bind9 >/dev/null 2>&1 | ||
``` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,19 @@ | ||
FROM python:latest | ||
|
||
ENV SRC="." | ||
WORKDIR /root | ||
|
||
VOLUME /bind-adblock | ||
COPY blocklist.txt . | ||
COPY config.yml . | ||
COPY update-zonefile.py . | ||
COPY requirements.txt . | ||
|
||
COPY ${SRC}/blocklist.txt ./ | ||
COPY ${SRC}/config.yml ./ | ||
COPY ${SRC}/update-zonefile.py ./ | ||
COPY ${SRC}/requirements.txt ./ | ||
ENV VIRTUAL_ENV=/opt/venv | ||
RUN python3 -m venv $VIRTUAL_ENV | ||
ENV PATH="$VIRTUAL_ENV/bin:$PATH" | ||
|
||
RUN pip install -r requirements.txt | ||
RUN pip install --upgrade pip && \ | ||
pip install -r requirements.txt | ||
|
||
RUN mkdir /bind-adblock | ||
|
||
CMD ["python3", "./update-zonefile.py", "--no-bind", "/bind-adblock/rpz-adblocker.zone", "rpz.adblocker"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
--- | ||
version: "3" | ||
|
||
services: | ||
updater: | ||
container_name: adblock | ||
build: | ||
context: . | ||
volumes: | ||
- 'bind9-zones:/bind-adblock' | ||
# - '/var/bind:/bind-adblock' | ||
|
||
volumes: | ||
bind9-zones: |