diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml new file mode 100644 index 0000000..79da890 --- /dev/null +++ b/.github/workflows/docker-image.yml @@ -0,0 +1,19 @@ +name: Docker Image CI + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + +jobs: + + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + - name: Build the Docker image + run: ./scripts/build-image.sh -t "ci-${{github.sha}}" + diff --git a/censere/__init__.py b/censere/__init__.py index d60ea2a..4175eff 100644 --- a/censere/__init__.py +++ b/censere/__init__.py @@ -1,8 +1,6 @@ # # Copyright (c) 2023 Richard Offer, All rights reserved. -from . import cmds - LOGGING = { "version": 1, "disable_existing_loggers": True, diff --git a/censere/cli.py b/censere/cli.py index 16c623e..8a6b16a 100755 --- a/censere/cli.py +++ b/censere/cli.py @@ -7,11 +7,7 @@ import click import os -#import sys -#import configobj import pathlib -#import json -#import pydantic import logging import logging.config @@ -27,6 +23,10 @@ cmd_folder = os.path.abspath(os.path.join(os.path.dirname(__file__), "cmds")) +CONTEXT_SETTINGS = dict( + auto_envvar_prefix='CENSERE' +) + class CensereCLI(click.Group): def list_commands(self, ctx): rv = [] @@ -43,7 +43,7 @@ def get_command(self, ctx, name): return return mod.cli -@click.group(cls=CensereCLI, invoke_without_command=True) +@click.group(cls=CensereCLI, invoke_without_command=True, context_settings=CONTEXT_SETTINGS) @click.pass_context @click.option( '--verbose', @@ -127,7 +127,7 @@ def cli(ctx, verbose, debug, log_level, database, dump, debug_sql): logging.getLogger( s[0] ).setLevel( s[1] ) -if __name__ == '__main__': +#if __name__ == '__main__': - cli( obj=None , auto_envvar_prefix='CENSERE') +# cli( obj=None , auto_envvar_prefix='CENSERE') diff --git a/scripts/build-image.sh b/scripts/build-image.sh new file mode 100755 index 0000000..d3f05c4 --- /dev/null +++ b/scripts/build-image.sh @@ -0,0 +1,31 @@ +#! /bin/sh + +topdir=$( cd "$( dirname "$0" )/../" && pwd ) + +NAME=mars-censere + +date=date + +if [ "$(uname -s)" == "Darwin" ]; then + date=gdate +fi + +# process the options + +. ${topdir}/scripts/standard-args.sh +ParseArgs $* + +if [ -n "${REGISTRY}" ] +then + PULL=--pull +fi + +set -x +set -euo pipefail + +echo docker buildx build --progress plain -o type=image -t ${NAME}:${TAG} . +exit 0 +st=$? +docker image ls "${NAME}" +set +x +exit $st diff --git a/scripts/build.sh b/scripts/build.sh index 1146b16..8c9ea46 100755 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -4,37 +4,15 @@ topdir=$( cd "$( dirname "$0" )/../" && pwd ) NAME=mars-censere -date=date - -if [ "$(uname -s)" == "Darwin" ]; then - date=gdate -fi - - - - - # process the options - . ${topdir}/scripts/standard-args.sh ParseArgs $* -if [ -n "${REGISTRY}" ] -then - PULL=--pull -fi - -TAG=$(${date} +"${NAME}:%y.%m%d.%H%M") - set -x set -euo pipefail -#docker pull ${NAME}:base || true -#docker pull ${NAME}:builder || true -docker buildx build --progress plain -o type=image -t ${TAG} . +python -m build st=$? -docker image ls "${NAME}" -#docker push ${NAME}:base -#docker push ${NAME}:builder +ls -l dist set +x exit $st diff --git a/scripts/standard-args.sh b/scripts/standard-args.sh index 1c2f7b6..f1dd7e9 100644 --- a/scripts/standard-args.sh +++ b/scripts/standard-args.sh @@ -60,11 +60,4 @@ EOF shift $((OPTIND-1)) - if [ -n "${PROJECT}" ] - then - TAG=${PROJECT}/${DIR}${TAG}:latest - else - TAG=${DIR}${TAG}:latest - fi - }