Add config profile and Dockerfile args to deploy script
This commit is contained in:
1 parent
4f6614c080
commit
7801ac9300
1 file changed
+40
-8
@@ -10,9 +10,11 @@ Positionals:
|
||||
release The release id. This will be appended to the container prefix to form the new container name.
|
||||
|
||||
Options:
|
||||
--app The application to bounce [PubSubServer | DataStreamPublisher | Bts.DataStreamWebApp.Server]
|
||||
--app APP The application to bounce [PubSubServer | DataStreamPublisher | Bts.DataStreamWebApp.Server]
|
||||
--container-prefix The container prefix to use. Existing dockers with this prefix will be terminated.
|
||||
--release The release id. This will be appended to the container prefix to form the new container name.
|
||||
--dockerfile PATH The Dockerfile used to build the image.
|
||||
--config CONFIG The Configuration profile to use, must be defined: 'src/DataStreamSuite/<APP>/Configurations/<CONFIG>.json'
|
||||
|
||||
EOF
|
||||
exit "$1"
|
||||
@@ -21,6 +23,8 @@ exit "$1"
|
||||
app_name=""
|
||||
container_prefix=""
|
||||
release=""
|
||||
cfg_profile=""
|
||||
dockerfile=""
|
||||
|
||||
while [[ $# -gt 0 ]]; do
|
||||
case "$1" in
|
||||
@@ -48,6 +52,22 @@ while [[ $# -gt 0 ]]; do
|
||||
release="$2"
|
||||
shift 2
|
||||
;;
|
||||
--config)
|
||||
if [[ -z "$2" ]]; then
|
||||
echo "Config profile (--config) must be non-empty"
|
||||
print_help_and_exit 1
|
||||
fi
|
||||
cfg_profile="$2"
|
||||
shift 2
|
||||
;;
|
||||
--dockerfile)
|
||||
if [[ -z "$2" ]]; then
|
||||
echo "Dockerfile (--dockerfile) must be non-empty"
|
||||
print_help_and_exit 1
|
||||
fi
|
||||
dockerfile="$(realpath "$2")"
|
||||
shift 2
|
||||
;;
|
||||
-h)
|
||||
;&
|
||||
--help)
|
||||
@@ -58,6 +78,7 @@ while [[ $# -gt 0 ]]; do
|
||||
print_help_and_exit 1
|
||||
;;
|
||||
*)
|
||||
# Positionals
|
||||
if [[ -z "$1" ]]; then
|
||||
echo "Invalid position argument '$1'"
|
||||
print_help_and_exit 1
|
||||
@@ -96,13 +117,20 @@ fi
|
||||
|
||||
this_dir="$(realpath "$(dirname "${BASH_SOURCE[0]}")")"
|
||||
cd $this_dir/..
|
||||
cfg_profile="AwsProd"
|
||||
|
||||
# Init and validate config profile
|
||||
if [[ -z "$cfg_profile" ]]; then
|
||||
cfg_profile="AwsProd"
|
||||
fi
|
||||
cfg_profiles_dir="src/DataStreamSuite/$app_name/Configurations"
|
||||
cfg_profile_json="$cfg_profiles_dir/$cfg_profile.json"
|
||||
if [ ! -e "$cfg_profile_json" ]; then
|
||||
echo "Profile '${cfg_profile}' not found. Looked for file '${cfg_profile_json}'"
|
||||
echo "Profile '${cfg_profile}' not found. Looked for file '$(realpath "$cfg_profile_json")'"
|
||||
fi
|
||||
|
||||
if [[ -z "$dockerfile" ]]; then
|
||||
dockerfile="docker/ubuntu-22.04/dotnet-7/Dockerfile"
|
||||
fi
|
||||
release_dir=".tmp/$release"
|
||||
mkdir -p "$release_dir"
|
||||
release_bin="$release_dir/bin"
|
||||
@@ -118,8 +146,8 @@ if [ $status -ne 0 ]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Copy configuration file to release_bin
|
||||
echo "Copying configuration to appsettings.json"
|
||||
# Copy config profile to release_bin
|
||||
echo "Copying configuration to $release_bin/appsettings.json"
|
||||
cp "$cfg_profile_json" "$release_bin/appsettings.json"
|
||||
status=$?
|
||||
if [ $status -ne 0 ]; then
|
||||
@@ -129,11 +157,12 @@ if [ $status -ne 0 ]; then
|
||||
fi
|
||||
|
||||
# Copy Dockerfile to release_dir
|
||||
cp "docker/ubuntu-22.04/dotnet-7/Dockerfile" "$release_dir/"
|
||||
echo "Copying Dockerfile to $release_dir"
|
||||
cp "$dockerfile" "$release_dir/"
|
||||
status=$?
|
||||
if [ $status -ne 0 ]; then
|
||||
echo "Copy Dockerfile exited with code $status. Full command below:"
|
||||
echo "cp docker/ubuntu-22.04/dotnet-7/Dockerfile $release_dir/"
|
||||
echo "cp $dockerfile $release_dir/"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
@@ -173,7 +202,10 @@ remote=bts-cloud-streams
|
||||
echo "Uploading $release.tar.gz to $remote"
|
||||
scp "$release.tar.gz" $remote:~/DataStream/releases/
|
||||
|
||||
# Start. Remove the existing release dir first - its named after the commit hash, which does not
|
||||
# reflect modified files, so someone may "redeploy" a release that actually contains a different
|
||||
# build due to differences in modified files.
|
||||
cat <<EOF | ssh $remote /usr/bin/env bash
|
||||
rm -r /home/ubuntu/DataStream/releases/$release
|
||||
rm -rf /home/ubuntu/DataStream/releases/$release
|
||||
/home/ubuntu/DataStream/scripts/bounce_data_stream_app.sh $app_name $container_prefix $release
|
||||
EOF
|
||||
Reference in new issue
Block a user