Skip to content

Commit

Permalink
Merge branch 'development' into master
Browse files Browse the repository at this point in the history
Signed-off-by: Adam Warner <[email protected]>
  • Loading branch information
PromoFaux authored Sep 2, 2024
2 parents 4cb3c3a + c38a6ea commit a796a89
Show file tree
Hide file tree
Showing 71 changed files with 815 additions and 2,412 deletions.
2 changes: 1 addition & 1 deletion .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
`{Please select 'base: dev' as target branch above! (you can delete this line)}`
`{Please select 'base: development' as target branch above! (you can delete this line)}`

<!--- Provide a general summary of your changes in the Title above -->

Expand Down
35 changes: 35 additions & 0 deletions .github/actions/login-repo/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Login to container registries
description: Login to container registries Docker Hub and GitHub Container Registry

inputs:
# Actions cannot access secrets so pass them in as inputs
docker_username:
required: true
description: The username to use to login to Docker Hub
docker_password:
required: true
description: The password to use to login to Docker Hub
ghcr_username:
required: true
description: The username to use to login to GitHub Container Registry
ghcr_password:
required: true
description: The password to use to login to GitHub Container Registry

runs:
using: "composite"
steps:
-
name: Login to Docker Hub
uses: docker/login-action@v2
with:
registry: docker.io
username: ${{ inputs.docker_username }}
password: ${{ inputs.docker_password }}
-
name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ inputs.ghcr_username }}
password: ${{ inputs.ghcr_password }}
32 changes: 32 additions & 0 deletions .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Build Image and Test
on:
pull_request:

jobs:
test:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
# Official docker images for docker are only available for amd64 and arm64
# TODO: Look at: https://github.com/docker-library/official-images#architectures-other-than-amd64
# Is testing on all platforms really necessary?
# Disabled arm64 tests for the time being, something is wrong with the test config and the volumes are getting shared between the test containers on different architectures
#platform: [linux/amd64, linux/arm64]
platform: [linux/amd64]
steps:
- name: Checkout Repo
uses: actions/checkout@v4

- name: Set up QEMU
uses: docker/setup-qemu-action@v3
with:
platforms: ${{ matrix.platform }}

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Run Tests
run: |
echo "Building image to test"
PLATFORM=${{ matrix.platform }} ./build-and-test.sh
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,6 @@ var-log/

# WIP/test stuff
doco.yml

# Ignore FTL Binary if it exists
src/pihole-FTL
5 changes: 5 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"github-actions.workflows.pinned.workflows": [
".github/workflows/v6-alpine-play.yml"
]
}
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

Please review the following before opening a pull request (PR) to help your PR go smoothly:

* Code changes go to the `dev` branch first
* To ensure proper testing and quality control, target any code change pull requests against `dev` branch.
* Code changes go to the `development` branch first
* To ensure proper testing and quality control, target any code change pull requests against `development` branch.

* Make sure the tests pass
* Take a look at [TESTING.md](test/TESTING.md) to see how to run tests locally so you do not have to push all your code to a PR and have GitHub Actions run it.
Expand Down
256 changes: 110 additions & 146 deletions README.md

Large diffs are not rendered by default.

11 changes: 7 additions & 4 deletions build-and-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,23 @@
set -ex

if [[ "$1" == "enter" ]]; then
enter="-it --entrypoint=bash"
enter="-it"
cmd="sh"
fi

GIT_BRANCH=$(git rev-parse --abbrev-ref HEAD | sed "s/\//-/g")
GIT_TAG=$(git describe --tags --exact-match 2> /dev/null || true)
GIT_TAG=$(git describe --tags --exact-match 2>/dev/null || true)
GIT_TAG="${GIT_TAG:-$GIT_BRANCH}"
PLATFORM="${PLATFORM:-linux/amd64}"

# generate and build dockerfile
docker build --tag image_pipenv --file test/Dockerfile test/
docker buildx build --load --platform=${PLATFORM} --tag image_pipenv --file test/Dockerfile test/
docker run --rm \
--volume /var/run/docker.sock:/var/run/docker.sock \
--volume "$(pwd):/$(pwd)" \
--workdir "$(pwd)" \
--env PIPENV_CACHE_DIR="$(pwd)/.pipenv" \
--env GIT_TAG="${GIT_TAG}" \
--env PY_COLORS=1 \
${enter} image_pipenv
--env TARGETPLATFORM="${PLATFORM}" \
${enter} image_pipenv ${cmd}
90 changes: 90 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
#!/bin/bash

# Usage function
usage() {
echo "Usage: $0 [-l] [-f <ftl_branch>] [-c <core_branch>] [-w <web_branch>] [-t <tag>] [use_cache]"
echo "Options:"
echo " -f, --ftlbranch <branch> Specify FTL branch (cannot be used in conjunction with -l)"
echo " -c, --corebranch <branch> Specify Core branch"
echo " -w, --webbranch <branch> Specify Web branch"
echo " -p, --paddbranch <branch> Specify PADD branch"
echo " -t, --tag <tag> Specify Docker image tag (default: pihole:local)"
echo " -l, --local Use locally built FTL binary (requires src/pihole-FTL file)"
echo " use_cache Enable caching (by default --no-cache is used)"
echo ""
echo "If no options are specified, the following command will be executed:"
echo " docker buildx build src/. --tag pihole:local --load --no-cache"
exit 1
}

# Set default values
DOCKER_BUILD_CMD="docker buildx build src/. --tag pihole:local --load --no-cache"
FTL_FLAG=false

# Parse command line arguments
while [[ $# -gt 0 ]]; do
key="$1"

case $key in
-l | --local)
if [ ! -f "src/pihole-FTL" ]; then
echo "File 'src/pihole-FTL' not found. Exiting."
exit 1
fi
if [ "$FTL_FLAG" = true ]; then
echo "Error: Both -l and -f cannot be used together."
usage
fi
FTL_FLAG=true
DOCKER_BUILD_CMD+=" --build-arg FTL_SOURCE=local"
shift
;;
-f | --ftlbranch)
if [ "$FTL_FLAG" = true ]; then
echo "Error: Both -l and -f cannot be used together."
usage
fi
FTL_FLAG=true
FTL_BRANCH="$2"
DOCKER_BUILD_CMD+=" --build-arg FTL_BRANCH=$FTL_BRANCH"
shift
shift
;;
-c | --corebranch)
CORE_BRANCH="$2"
DOCKER_BUILD_CMD+=" --build-arg CORE_BRANCH=$CORE_BRANCH"
shift
shift
;;
-w | --webbranch)
WEB_BRANCH="$2"
DOCKER_BUILD_CMD+=" --build-arg WEB_BRANCH=$WEB_BRANCH"
shift
shift
;;
-p | --paddbranch)
PADD_BRANCH="$2"
DOCKER_BUILD_CMD+=" --build-arg PADD_BRANCH=$PADD_BRANCH"
shift
shift
;;
-t | --tag)
TAG="$2"
DOCKER_BUILD_CMD=${DOCKER_BUILD_CMD/pihole:local/$TAG}
shift
shift
;;
use_cache)
DOCKER_BUILD_CMD=${DOCKER_BUILD_CMD/--no-cache/}
shift
;;
*)
echo "Unknown option: $1"
usage
;;
esac
done

# Execute the docker build command
echo "Executing command: $DOCKER_BUILD_CMD"
eval $DOCKER_BUILD_CMD
43 changes: 20 additions & 23 deletions examples/docker-compose-caddy-proxy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,50 +5,47 @@ services:
container_name: caddy
image: caddy:latest
networks:
- caddy-net # Network exclusively for Caddy-proxied containers
- caddy-net # Network exclusively for Caddy-proxied containers
restart: unless-stopped
ports:
- "80:80"
- "443:443"
- "443:443/udp" # QUIC protocol support: https://www.chromium.org/quic/
- "443:443/udp" # QUIC protocol support: https://www.chromium.org/quic/
volumes:
- ./Caddyfile:/etc/caddy/Caddyfile # config file on host in same directory as docker-compose.yml for easy editing.
- ./Caddyfile:/etc/caddy/Caddyfile # config file on host in same directory as docker-compose.yml for easy editing.
#- $PWD/site:/srv # Only use if you are serving a website behind caddy
- caddy_data:/data # Use docker volumes here bc no need to access these files from host
- caddy_config:/config # Use docker volumes here bc no need to access these files from host

- caddy_data:/data # Use docker volumes here bc no need to access these files from host
- caddy_config:/config # Use docker volumes here bc no need to access these files from host

# More info at https://github.com/pi-hole/docker-pi-hole/ and https://docs.pi-hole.net/
pihole:
depends_on:
depends_on:
- caddy
container_name: pihole
#dns: # Optional. Specify desired upstream DNS servers here.
# - 127.0.0.1
# - 9.9.9.9
# - 149.112.112.112
image: pihole/pihole:latest
networks:
- caddy-net # Need to plug into caddy net to access proxy
ports:
- "8081:80/tcp" # Pi-hole web admin interface, proxied through Caddy (configure port in Caddyfile)
# Following are NOT proxied through Caddy, bound to host net instead:
- "53:53/udp"
- "53:53/tcp"
- "853:853/tcp" # DNS-over-TLS
- "853:853/tcp" # DNS-over-TLS
#- "67:67/udp" # DHCP, if desired. If not bound to host net you need an mDNS proxy service configured somewhere on host net.
# ref: https://docs.pi-hole.net/docker/DHCP/
environment:
TZ: 'America/New_York' # Supported TZ database names: https://en.wikipedia.org/wiki/List_of_tz_database_time_zones#Time_Zone_abbreviations
WEBPASSWORD: 'password' # Only used on first boot, change with pihole cli then comment out here.
# Set the appropriate timezone for your location (https://en.wikipedia.org/wiki/List_of_tz_database_time_zones), e.g:
TZ: 'Europe/London'
# Set a password to access the web interface. Not setting one will result in a random password being assigned
FTLCONF_webserver_api_password: 'correct horse battery staple'
# Volumes store your data between container upgrades
volumes:
# For persisting Pi-hole's databases and common configuration file
- './etc-pihole:/etc/pihole'
- './etc-dnsmasq.d:/etc/dnsmasq.d'
- './etc-lighttpd/external.conf:/etc/lighttpd/external.conf' # Recommend leave as bind mount for easier editing.
# ref for why you may need to change this file: https://docs.pi-hole.net/guides/webserver/caddy/#modifying-lighttpd-configuration
#cap_add: # Uncomment if using Pi-hole as DHCP server
# https://github.com/pi-hole/docker-pi-hole#note-on-capabilities
#- NET_ADMIN # ONLY required if you are using Pi-hole as your DHCP server, else remove for better security
# Uncomment the below if you have custom dnsmasq config files that you want to persist. Not needed for most.
#- './etc-dnsmasq.d:/etc/dnsmasq.d'
cap_add:
# See https://github.com/pi-hole/docker-pi-hole#note-on-capabilities
# Required if you are using Pi-hole as your DHCP server, else not needed
- NET_ADMIN
restart: unless-stopped

# ref: https://hub.docker.com/_/caddy
Expand All @@ -60,5 +57,5 @@ networks:
# ref: https://hub.docker.com/_/caddy
volumes:
caddy_data:
external: true # May need to create volume with 'docker volume create caddy_data'
external: true # May need to create volume with 'docker volume create caddy_data'
caddy_config:
57 changes: 0 additions & 57 deletions examples/docker-compose-nginx-proxy.yml

This file was deleted.

23 changes: 0 additions & 23 deletions examples/docker-compose.yml.example

This file was deleted.

Loading

0 comments on commit a796a89

Please sign in to comment.