Single pihole version file. Added 'python-dotenv' to parse for the VERSIONS file.

Signed-off-by: Daniel <daniel@developerdan.com>
This commit is contained in:
Daniel 2021-05-29 03:19:24 +00:00
parent 99de0dce83
commit 6b1765c638
No known key found for this signature in database
GPG Key ID: 4940B41048AF73EA
7 changed files with 40 additions and 21 deletions

View File

@ -8,7 +8,6 @@ ARG S6_VERSION
ENV S6OVERLAY_RELEASE "https://github.com/just-containers/s6-overlay/releases/download/${S6_VERSION}/s6-overlay-${S6_ARCH}.tar.gz"
COPY install.sh /usr/local/bin/install.sh
COPY VERSION /etc/docker-pi-hole-version
COPY VERSIONS /etc/pi-hole-versions
ENV PIHOLE_INSTALL /etc/.pihole/automated\ install/basic-install.sh

View File

@ -20,12 +20,16 @@ from docopt import docopt
import os
import sys
import subprocess
from dotenv import dotenv_values
__version__ = None
dot = os.path.abspath('.')
with open('{}/VERSION'.format(dot), 'r') as v:
raw_version = v.read().strip()
__version__ = raw_version.replace('release/', 'release-')
FTL_VERSION = None
def read_pihole_versions():
global FTL_VERSION
dot = os.path.abspath('.')
config = dotenv_values('{}/VERSIONS'.format(dot))
FTL_VERSION = config['FTL_VERSION']
def build_dockerfiles(args) -> bool:
@ -60,12 +64,12 @@ def run_and_stream_command_output(command, environment_vars, verbose) -> bool:
def build(docker_repo: str, arch: str, debian_version: str, hub_tag: str, show_time: bool, no_cache: bool, verbose: bool) -> bool:
create_tag = f'{docker_repo}:{__version__}-{arch}-{debian_version}'
create_tag = f'{docker_repo}:{FTL_VERSION}-{arch}-{debian_version}'
print(f' ::: Building {create_tag}')
time_arg = 'time' if show_time else ''
cache_arg = '--no-cache' if no_cache else ''
build_env = os.environ.copy()
build_env['PIHOLE_VERSION'] = __version__
build_env['PIHOLE_VERSION'] = FTL_VERSION
build_env['DEBIAN_VERSION'] = debian_version
build_command = f'{time_arg} docker-compose -f build.yml build {cache_arg} --pull {arch}'
print(f' ::: Building {arch} into {create_tag}')
@ -81,6 +85,7 @@ def build(docker_repo: str, arch: str, debian_version: str, hub_tag: str, show_t
if __name__ == '__main__':
args = docopt(__doc__, version='Dockerfile 1.1')
read_pihole_versions()
success = build_dockerfiles(args)
exit_code = 0 if success else 1
sys.exit(exit_code)

View File

@ -58,6 +58,7 @@ Jinja2 = "==2.11.3"
MarkupSafe = "==1.1.1"
PyYAML = "==5.4"
websocket_client = "==0.57.0"
python-dotenv = "==0.17.1"
[requires]
python_version = "3.8"

14
Pipfile.lock generated
View File

@ -1,7 +1,7 @@
{
"_meta": {
"hash": {
"sha256": "6b8495479c1a2a11b99e728c23d5c4ec57b59b9e42e456f63ee46bedfeb24f45"
"sha256": "2c7f1fb7f001bf70bba7309859b06dc323040f21518b32ee8993aa823c27df15"
},
"pipfile-spec": 6,
"requires": {
@ -384,6 +384,7 @@
"sha256:5b327ac1320dc863dca72f4514ecc086f31186744b84a230374cc1fd776feae5",
"sha256:67714da7f7bc052e064859c05c595155bd1ee9f69f76557e21f051443c20947a"
],
"markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'",
"version": "==20.9"
},
"pathlib2": {
@ -464,6 +465,14 @@
"index": "pypi",
"version": "==1.31.0"
},
"python-dotenv": {
"hashes": [
"sha256:00aa34e92d992e9f8383730816359647f358f4a3be1ba45e5a5cefd27ee91544",
"sha256:b1ae5e9643d5ed987fc57cc2583021e38db531946518130777734f9589b3141f"
],
"index": "pypi",
"version": "==0.17.1"
},
"pyyaml": {
"hashes": [
"sha256:02c78d77281d8f8d07a255e57abdbf43b02257f59f50cc6b636937d68efa5dd0",
@ -552,7 +561,8 @@
"toml": {
"hashes": [
"sha256:229f81c57791a41d65e399fc06bf0848bab550a9dfd5ed66df18ce5f05e73d5c",
"sha256:235682dd292d5899d361a811df37e04a8828a5b1da3115886b73cf81ebc9100e"
"sha256:235682dd292d5899d361a811df37e04a8828a5b1da3115886b73cf81ebc9100e",
"sha256:f1db651f9657708513243e61e6cc67d101a39bad662eaa9b5546f789338e07a3"
],
"index": "pypi",
"version": "==0.10.0"

View File

@ -1 +0,0 @@
v5.3.1

View File

@ -52,3 +52,4 @@ virtualenv==16.7.9
wcwidth==0.1.7
websocket-client==0.57.0
zipp==0.6.0
python-dotenv==0.17.1

View File

@ -1,27 +1,31 @@
import functools
import os
import pytest
import subprocess
import testinfra
import types
from dotenv import dotenv_values
local_host = testinfra.get_host('local://')
check_output = local_host.check_output
DEBIAN_VERSION = os.environ.get('DEBIAN_VERSION', 'buster')
__version__ = None
dotdot = os.path.abspath(os.path.join(os.path.abspath(__file__), os.pardir, os.pardir))
with open('{}/VERSION'.format(dotdot), 'r') as v:
raw_version = v.read().strip()
__version__ = raw_version.replace('release/', 'release-')
FTL_VERSION = None
@pytest.fixture(autouse=True)
def read_pihole_versions():
global FTL_VERSION
dotdot = os.path.abspath(os.path.join(os.path.abspath(__file__), os.pardir, os.pardir))
config = dotenv_values('{}/VERSIONS'.format(dotdot))
FTL_VERSION = config['FTL_VERSION']
@pytest.fixture()
def run_and_stream_command_output():
def run_and_stream_command_output_inner(command, verbose=False):
print("Running", command)
build_env = os.environ.copy()
build_env['PIHOLE_VERSION'] = __version__
build_env['PIHOLE_VERSION'] = FTL_VERSION
build_result = subprocess.Popen(command.split(), env=build_env, stdout=subprocess.PIPE, stderr=subprocess.STDOUT,
bufsize=1, universal_newlines=True)
if verbose:
@ -97,7 +101,7 @@ def arch(request):
@pytest.fixture()
def version():
return __version__
return FTL_VERSION
@pytest.fixture()
def debian_version():
@ -128,7 +132,7 @@ def persist_arch():
@pytest.fixture(scope='module')
def persist_version():
return __version__
return FTL_VERSION
@pytest.fixture(scope='module')
def persist_debian_version():