feat(deploy): add production one-click deployment
This commit is contained in:
@@ -4,9 +4,40 @@ export LC_ALL=C
|
||||
|
||||
script_dir=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
|
||||
compose_args=(-f "$script_dir/docker-compose.prod.yml")
|
||||
if (($#)); then
|
||||
env_file=$1
|
||||
env_file=
|
||||
allow_local_images=false
|
||||
while (($#)); do
|
||||
case $1 in
|
||||
--allow-local-images)
|
||||
allow_local_images=true
|
||||
shift
|
||||
;;
|
||||
--)
|
||||
shift
|
||||
if (($# != 1)) || [[ -n $env_file ]]; then
|
||||
echo "usage: $0 [--allow-local-images] [env-file]" >&2
|
||||
exit 2
|
||||
fi
|
||||
env_file=$1
|
||||
shift
|
||||
;;
|
||||
-*)
|
||||
echo "unknown option: $1" >&2
|
||||
exit 2
|
||||
;;
|
||||
*)
|
||||
if [[ -n $env_file ]]; then
|
||||
echo "usage: $0 [--allow-local-images] [env-file]" >&2
|
||||
exit 2
|
||||
fi
|
||||
env_file=$1
|
||||
shift
|
||||
;;
|
||||
esac
|
||||
done
|
||||
if [[ -n $env_file ]]; then
|
||||
set -a
|
||||
# shellcheck disable=SC1090
|
||||
source "$env_file"
|
||||
set +a
|
||||
compose_args=(--env-file "$env_file" "${compose_args[@]}")
|
||||
@@ -112,6 +143,13 @@ while IFS= read -r image; do
|
||||
if [[ $image =~ @sha256:[0-9a-fA-F]{64}$ ]]; then
|
||||
continue
|
||||
fi
|
||||
if [[ $allow_local_images == true ]]; then
|
||||
if ! docker image inspect "$image" >/dev/null 2>&1; then
|
||||
echo "local production image is not loaded: $image" >&2
|
||||
exit 1
|
||||
fi
|
||||
continue
|
||||
fi
|
||||
echo "production image must be pinned to a sha256 digest: $image" >&2
|
||||
exit 1
|
||||
done <<< "$images"
|
||||
|
||||
Reference in New Issue
Block a user