reorganize src/ for refactor of UCI build

reorganize, refactor and improve testing
master
David Kebler 2023-04-22 10:23:44 -07:00
parent 496d3cbd68
commit cbc8afedda
29 changed files with 58 additions and 37 deletions

4
build
View File

@ -10,10 +10,10 @@ if [[ $build ]];then
if [[ $BUILD_CADDY_CONF ]]; then
CONF_DIR=${CONF_DIR:-${PWD}/conf}
if [[ -d $CONF_DIR ]]; then
mkdir -p ${BUILD_SRC}/init/caddy/conf
mkdir -p ${BUILD_SRC}/init/opt/caddy/conf
echo adding caddy conf/ directory $CONF_DIR to build
ls -la $CONF_DIR
/bin/cp -R $CONF_DIR/. ${BUILD_SRC}/init/caddy/conf
/bin/cp -R $CONF_DIR/. ${BUILD_SRC}/init/opt/caddy/conf
fi
fi
BUILD_PKGS=${BUILD_PKGS:-${PWD}/caddy.pkgs}

View File

@ -1,3 +1,2 @@
source $ENV_DIR/run.env
export ENTRYPOINT_CMD=caddy
export ENTRYPOINT_CMD_PATH=$BIN_DIR/caddy
export BUILD_NAME=caddy
[ -f "$ENV_DIR/run.env" ] && source $ENV_DIR/run.env

View File

@ -1,16 +1,11 @@
#!/bin/bash
# set -e
echo -e "********** Caddy Setup and Install ***************"
if [[ $(env | grep CADDY_LIB) ]]; then
mkdir -p $CADDY_HOME 2> /dev/null
if [[ -d caddy/ ]]; then
echo "copying caddy/ to $CADDY_HOME"
/bin/cp -R -p caddy/. $CADDY_HOME
fi
pushd $CADDY_HOME || exit 2
mkdir -p $CADDY_HOME >/dev/null
pushd $CADDY_HOME > /dev/null || exit 2
echo making caddy subdirectories $PWD
mkdir data conf settings bin 2> /dev/null
popd
popd > /dev/null || exit 2
chown -R 1000:1000 $CADDY_HOME
echo -e "------------------"
echo $CADDY_HOME

View File

@ -40,6 +40,7 @@ case "$1" in
conf=Caddyfile
fi
if [[ -f $conf ]]; then
echo checking for any run time packages to add...
caddy_add_packages
echo running: $CADDY_BIN run --config $conf --adapter caddyfile
$CADDY_BIN run --config $conf --adapter caddyfile

View File

@ -1,3 +1,6 @@
# will be sourced when "login" action is run via /etc/profile
# set these to customize the "custom" entrypoint command
export ENTRYPOINT_CMD=caddy
export ENTRYPOINT_CMD_PATH=$BIN_DIR/caddy
source $ENV_DIR/caddy.env
export VOLUME_DIRS="$XDG_CONFIG_HOME $XDG_DATA_HOME $CADDY_CONF"

View File

@ -13,7 +13,7 @@ caddy_add_packages () {
}
[[ -f $1 ]] && pkgs=" $(clean $1)"
[[ $BUILDING && -f $BUILD_DIR/caddy.pkgs ]] && pkgs=$(clean $BUILD_DIR/caddy.pkgs "$pkgs")
[[ $BUILDING && -f $BUILD_DIR/caddy.pkgs ]] && pkgs=$(clean $BUILD_DIR/caddy.pkgs "$pkgs")
# echo pkgs after build
# echo $pkgs
[[ -f $CADDY_CONF/caddy.pkgs ]] && pkgs=$(clean $CADDY_CONF/caddy.pkgs "$pkgs")

View File

@ -0,0 +1,8 @@
ca-certificates
libcap
mailcap
jq

View File

@ -1,8 +0,0 @@
#!/bin/sh
echo install packages for alpine caddy
apk update; apk upgrade;
# note: shadow, bash, bash-completion coreutils are installed by default for alpine
apk add --no-cache --no-progress ca-certificates libcap mailcap git jq bash curl

View File

@ -1 +1,10 @@
../build -e test.env $@
#!/bin/bash
[[ $1 = "-f" ]] && force=force && shift
if [[ ! $(udbuild image exists -e test.env) || $force ]] ; then
echo $force building image
../build -e test.env -a build.env $@
echo done building image
else
echo using existing image, use -f to force rebuild
fi

1
test/build.env Normal file
View File

@ -0,0 +1 @@
UCI_SHELL=true

View File

@ -1 +1,3 @@
source ./build $1
[[ $force ]] && shift 1
udbuild try -e test.env -m /opt/caddy/conf -h conf caddy $@

View File

@ -10,7 +10,7 @@ services:
- $CREDENTIALS
volumes:
- conf:/opt/caddy/conf
- opt:/opt
# - opt:/opt
ports:
- 80:80
- 443:443
@ -22,8 +22,8 @@ volumes:
type: none
device: ${PWD}/conf
o: bind
opt:
driver_opts:
type: none
device: ${PWD}/opt
o: bind
# opt:
# driver_opts:
# type: none
# device: ${PWD}/opt
# o: bind

3
test/compose/log Executable file
View File

@ -0,0 +1,3 @@
[[ $1 ]] && opt="-n $1"
[[ $1 == "f" ]] && opt="-f"
docker-compose logs $opt

1
test/compose/scrub Executable file
View File

@ -0,0 +1 @@
docker-compose down -v

5
test/compose/start Executable file
View File

@ -0,0 +1,5 @@
# if no image run ./build first
source ./build $1
[[ $force ]] && shift 1
mkdir -p opt conf
docker-compose ${@:-up}

1
test/compose/stop Executable file
View File

@ -0,0 +1 @@
docker-compose down

3
test/compose/term Executable file
View File

@ -0,0 +1,3 @@
#!/bin/bash
source .env
docker exec -it caddy-testing bash -l

View File

@ -1 +1,3 @@
# if no image run ./build first
source ./build $1
udbuild try -e test.env -m /opt/caddy/conf -h conf -s list-packages

View File

@ -1 +0,0 @@
udbuild try -e test.env -m /opt/caddy/conf -h conf shell $@

View File

@ -1,7 +0,0 @@
# if no image run ./build first
if docker image inspect testing/caddy >/dev/null 2>&1 ;then
docker-compose ${@:-up}
else
./build -e test -t default -p
docker-compose ${@:-up}
fi

4
test/try Executable file
View File

@ -0,0 +1,4 @@
# if no image run ./build first
source ./build $1
[[ $force ]] && shift 1
udbuild try -e test.env -m /opt/caddy/conf -h conf ${@:-shell}