Skip to content

Commit

Permalink
deploy script add PACK_MODE support.
Browse files Browse the repository at this point in the history
  • Loading branch information
hughjfchen committed Sep 20, 2022
1 parent a757b2f commit 6542ba4
Show file tree
Hide file tree
Showing 7 changed files with 165 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,42 @@ SCRIPT_ABS_PATH=$(turn_to_absolute_path "$0")

begin_banner "Top level" "project deploy - generic"

if [ $# != 2 ]; then
echo "usage: $(basename "$0") deployTargetSite releasePhase"
# the default pack mode is full, i.e., pack full dependencies
# there are two passible value for this option:
# full - means pack the binary and its all dependencies
# incremental - means only pack the changed derivations
PACK_MODE="full"

if [ $# == 2 ] || [ $# == 3 ]; then
if [ $# == 3 ]; then
if [ "$3" == "full" ] || [ "$3" == "incremental" ]; then
PACK_MODE="$3"
else
echo "usage: $(basename "$0") deployTargetSite releasePhase <pack mode>"
echo "the <pack mode> could only be 'full' or 'incremental'."
exit 126
fi
fi
else
echo "usage: $(basename "$0") deployTargetSite releasePhase <pack mode>"
echo "the <pack mode> is optional, it could be 'full' or 'incremental', the default is 'full'."
exit 125
fi

[ -d "$SCRIPT_ABS_PATH/../env/site/$1/phase/$2" ] || (echo "Directory $SCRIPT_ABS_PATH/../env/site/$1/phase/$2 not exists" && exit 126)
[ -d "$SCRIPT_ABS_PATH/../config/site/$1/phase/$2" ] || (echo "Directory $SCRIPT_ABS_PATH/../config/site/$1/phase/$2 not exists" && exit 126)

set +u
[ -e "$HOME"/.nix-profile/etc/profile.d/nix.sh ] && . "$HOME"/.nix-profile/etc/profile.d/nix.sh
set -u

if [ "$PACK_MODE" == "full" ]; then
# clean up the reference so that let the packer do a full pack
rm -fr "/nix/var/reference-file/my-openresty-$1-$2.reference"
rm -fr "/nix/var/reference-file-static/my-openresty-$1-$2/my-openresty-$1-$2.reference"
rm -fr "/nix/var/reference-file-static/my-openresty-$1-$2"
fi

# build the boundle for the specific release target
nix-build ./release.nix --arg site \""$1"\" --arg phase \""$2"\" --attr "mk-my-release-packer" --out-link "mk-my-release-packer"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,42 @@ SCRIPT_ABS_PATH=$(turn_to_absolute_path "$0")

begin_banner "Top level" "project deploy - generic"

if [ $# != 2 ]; then
echo "usage: $(basename "$0") deployTargetSite releasePhase"
# the default pack mode is full, i.e., pack full dependencies
# there are two passible value for this option:
# full - means pack the binary and its all dependencies
# incremental - means only pack the changed derivations
PACK_MODE="full"

if [ $# == 2 ] || [ $# == 3 ]; then
if [ $# == 3 ]; then
if [ "$3" == "full" ] || [ "$3" == "incremental" ]; then
PACK_MODE="$3"
else
echo "usage: $(basename "$0") deployTargetSite releasePhase <pack mode>"
echo "the <pack mode> could only be 'full' or 'incremental'."
exit 126
fi
fi
else
echo "usage: $(basename "$0") deployTargetSite releasePhase <pack mode>"
echo "the <pack mode> is optional, it could be 'full' or 'incremental', the default is 'full'."
exit 125
fi

[ -d "$SCRIPT_ABS_PATH/../env/site/$1/phase/$2" ] || (echo "Directory $SCRIPT_ABS_PATH/../env/site/$1/phase/$2 not exists" && exit 126)
[ -d "$SCRIPT_ABS_PATH/../config/site/$1/phase/$2" ] || (echo "Directory $SCRIPT_ABS_PATH/../config/site/$1/phase/$2 not exists" && exit 126)

set +u
[ -e "$HOME"/.nix-profile/etc/profile.d/nix.sh ] && . "$HOME"/.nix-profile/etc/profile.d/nix.sh
set -u

if [ "$PACK_MODE" == "full" ]; then
# clean up the reference so that let the packer do a full pack
rm -fr "/nix/var/reference-file/my-postgrest-$1-$2.reference"
rm -fr "/nix/var/reference-file-static/my-postgrest-$1-$2/my-postgrest-$1-$2.reference"
rm -fr "/nix/var/reference-file-static/my-postgrest-$1-$2"
fi

# build the boundle for the specific release target
nix-build ./release.nix --arg site \""$1"\" --arg phase \""$2"\" --attr "mk-my-release-packer" --out-link "mk-my-release-packer"

Expand Down
29 changes: 27 additions & 2 deletions project-scaffold-template/full-system-nixos2111-ghc8107/db/deploy
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,42 @@ SCRIPT_ABS_PATH=$(turn_to_absolute_path "$0")

begin_banner "Top level" "project deploy - generic"

if [ $# != 2 ]; then
echo "usage: $(basename "$0") deployTargetSite releasePhase"
# the default pack mode is full, i.e., pack full dependencies
# there are two passible value for this option:
# full - means pack the binary and its all dependencies
# incremental - means only pack the changed derivations
PACK_MODE="full"

if [ $# == 2 ] || [ $# == 3 ]; then
if [ $# == 3 ]; then
if [ "$3" == "full" ] || [ "$3" == "incremental" ]; then
PACK_MODE="$3"
else
echo "usage: $(basename "$0") deployTargetSite releasePhase <pack mode>"
echo "the <pack mode> could only be 'full' or 'incremental'."
exit 126
fi
fi
else
echo "usage: $(basename "$0") deployTargetSite releasePhase <pack mode>"
echo "the <pack mode> is optional, it could be 'full' or 'incremental', the default is 'full'."
exit 125
fi

[ -d "$SCRIPT_ABS_PATH/../env/site/$1/phase/$2" ] || (echo "Directory $SCRIPT_ABS_PATH/../env/site/$1/phase/$2 not exists" && exit 126)
[ -d "$SCRIPT_ABS_PATH/../config/site/$1/phase/$2" ] || (echo "Directory $SCRIPT_ABS_PATH/../config/site/$1/phase/$2 not exists" && exit 126)

set +u
[ -e "$HOME"/.nix-profile/etc/profile.d/nix.sh ] && . "$HOME"/.nix-profile/etc/profile.d/nix.sh
set -u

if [ "$PACK_MODE" == "full" ]; then
# clean up the reference so that let the packer do a full pack
rm -fr "/nix/var/reference-file/my-postgresql-$1-$2.reference"
rm -fr "/nix/var/reference-file-static/my-postgresql-$1-$2/my-postgresql-$1-$2.reference"
rm -fr "/nix/var/reference-file-static/my-postgresql-$1-$2"
fi

# build the boundle for the specific release target
nix-build ./release.nix --arg site \""$1"\" --arg phase \""$2"\" --attr "mk-my-release-packer" --out-link "mk-my-release-packer"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,42 @@ SCRIPT_ABS_PATH=$(turn_to_absolute_path "$0")

begin_banner "Top level" "project deploy - generic"

if [ $# != 2 ]; then
echo "usage: $(basename "$0") deployTargetSite releasePhase"
# the default pack mode is full, i.e., pack full dependencies
# there are two passible value for this option:
# full - means pack the binary and its all dependencies
# incremental - means only pack the changed derivations
PACK_MODE="full"

if [ $# == 2 ] || [ $# == 3 ]; then
if [ $# == 3 ]; then
if [ "$3" == "full" ] || [ "$3" == "incremental" ]; then
PACK_MODE="$3"
else
echo "usage: $(basename "$0") deployTargetSite releasePhase <pack mode>"
echo "the <pack mode> could only be 'full' or 'incremental'."
exit 126
fi
fi
else
echo "usage: $(basename "$0") deployTargetSite releasePhase <pack mode>"
echo "the <pack mode> is optional, it could be 'full' or 'incremental', the default is 'full'."
exit 125
fi

[ -d "$SCRIPT_ABS_PATH/../env/site/$1/phase/$2" ] || (echo "Directory $SCRIPT_ABS_PATH/../env/site/$1/phase/$2 not exists" && exit 126)
[ -d "$SCRIPT_ABS_PATH/../config/site/$1/phase/$2" ] || (echo "Directory $SCRIPT_ABS_PATH/../config/site/$1/phase/$2 not exists" && exit 126)

set +u
[ -e "$HOME"/.nix-profile/etc/profile.d/nix.sh ] && . "$HOME"/.nix-profile/etc/profile.d/nix.sh
set -u

if [ "$PACK_MODE" == "full" ]; then
# clean up the reference so that let the packer do a full pack
rm -fr "/nix/var/reference-file/my-rabbitmq-$1-$2.reference"
rm -fr "/nix/var/reference-file-static/my-rabbitmq-$1-$2/my-rabbitmq-$1-$2.reference"
rm -fr "/nix/var/reference-file-static/my-rabbitmq-$1-$2"
fi

# build the boundle for the specific release target
nix-build ./release.nix --arg site \""$1"\" --arg phase \""$2"\" --attr "mk-my-release-packer" --out-link "mk-my-release-packer"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,42 @@ SCRIPT_ABS_PATH=$(turn_to_absolute_path "$0")

begin_banner "Top level" "project deploy - generic"

if [ $# != 2 ]; then
echo "usage: $(basename "$0") deployTargetSite releasePhase"
# the default pack mode is full, i.e., pack full dependencies
# there are two passible value for this option:
# full - means pack the binary and its all dependencies
# incremental - means only pack the changed derivations
PACK_MODE="full"

if [ $# == 2 ] || [ $# == 3 ]; then
if [ $# == 3 ]; then
if [ "$3" == "full" ] || [ "$3" == "incremental" ]; then
PACK_MODE="$3"
else
echo "usage: $(basename "$0") deployTargetSite releasePhase <pack mode>"
echo "the <pack mode> could only be 'full' or 'incremental'."
exit 126
fi
fi
else
echo "usage: $(basename "$0") deployTargetSite releasePhase <pack mode>"
echo "the <pack mode> is optional, it could be 'full' or 'incremental', the default is 'full'."
exit 125
fi

[ -d "$SCRIPT_ABS_PATH/../env/site/$1/phase/$2" ] || (echo "Directory $SCRIPT_ABS_PATH/../env/site/$1/phase/$2 not exists" && exit 126)
[ -d "$SCRIPT_ABS_PATH/../config/site/$1/phase/$2" ] || (echo "Directory $SCRIPT_ABS_PATH/../config/site/$1/phase/$2 not exists" && exit 126)

set +u
[ -e "$HOME"/.nix-profile/etc/profile.d/nix.sh ] && . "$HOME"/.nix-profile/etc/profile.d/nix.sh
set -u

if [ "$PACK_MODE" == "full" ]; then
# clean up the reference so that let the packer do a full pack
rm -fr "/nix/var/reference-file/my-{{name}}-$1-$2.reference"
rm -fr "/nix/var/reference-file-static/my-{{name}}-$1-$2/my-{{name}}-$1-$2.reference"
rm -fr "/nix/var/reference-file-static/my-{{name}}-$1-$2"
fi

# build the boundle for the specific release target
nix-build ./release.nix --arg site \""$1"\" --arg phase \""$2"\" --attr "mk-my-release-packer" --out-link "mk-my-release-packer"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ in rec {
units = serviceNameUnit;
})
else
{ };
"";
# following derivation just to make sure the setup and unsetup will
# be packed into the distribute tarball.
setup-and-unsetup-or-bin-sh = nPkgs.symlinkJoin {
Expand Down
33 changes: 29 additions & 4 deletions project-scaffold-template/nixos2111-ghc8107-haskell.nix/deploy
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,42 @@ SCRIPT_ABS_PATH=$(turn_to_absolute_path "$0")

begin_banner "Top level" "project deploy - generic"

if [ $# != 2 ]; then
echo "usage: $(basename "$0") deployTargetSite releasePhase"
# the default pack mode is full, i.e., pack full dependencies
# there are two passible value for this option:
# full - means pack the binary and its all dependencies
# incremental - means only pack the changed derivations
PACK_MODE="full"

if [ $# == 2 ] || [ $# == 3 ]; then
if [ $# == 3 ]; then
if [ "$3" == "full" ] || [ "$3" == "incremental" ]; then
PACK_MODE="$3"
else
echo "usage: $(basename "$0") deployTargetSite releasePhase <pack mode>"
echo "the <pack mode> could only be 'full' or 'incremental'."
exit 126
fi
fi
else
echo "usage: $(basename "$0") deployTargetSite releasePhase <pack mode>"
echo "the <pack mode> is optional, it could be 'full' or 'incremental', the default is 'full'."
exit 125
fi
[ -d "$SCRIPT_ABS_PATH/env/site/$1/phase/$2" ] || (echo "Directory $SCRIPT_ABS_PATH/env/site/$1/phase/$2 not exists" && exit 126)
[ -d "$SCRIPT_ABS_PATH/config/site/$1/phase/$2" ] || (echo "Directory $SCRIPT_ABS_PATH/config/site/$1/phase/$2 not exists" && exit 126)

[ -d "$SCRIPT_ABS_PATH/../env/site/$1/phase/$2" ] || (echo "Directory $SCRIPT_ABS_PATH/../env/site/$1/phase/$2 not exists" && exit 126)
[ -d "$SCRIPT_ABS_PATH/../config/site/$1/phase/$2" ] || (echo "Directory $SCRIPT_ABS_PATH/../config/site/$1/phase/$2 not exists" && exit 126)

set +u
[ -e "$HOME"/.nix-profile/etc/profile.d/nix.sh ] && . "$HOME"/.nix-profile/etc/profile.d/nix.sh
set -u

if [ "$PACK_MODE" == "full" ]; then
# clean up the reference so that let the packer do a full pack
rm -fr "/nix/var/reference-file/my-{{name}}-$1-$2.reference"
rm -fr "/nix/var/reference-file-static/my-{{name}}-$1-$2/my-{{name}}-$1-$2.reference"
rm -fr "/nix/var/reference-file-static/my-{{name}}-$1-$2"
fi

# build the boundle for the specific release target
nix-build ./release.nix --arg site \""$1"\" --arg phase \""$2"\" --attr "mk-my-release-packer" --out-link "mk-my-release-packer"

Expand Down

0 comments on commit 6542ba4

Please sign in to comment.