Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docker Export/Load #167

Merged
merged 4 commits into from
Apr 23, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ RUN apt-get update \
unzip \
wget \
python3 \
sed \
python3-pip


Expand Down
24 changes: 23 additions & 1 deletion src/docs/ui-deployment.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ Here's the full list of parameters for reference:
```plaintext
setup_ezdeploy.sh: Setup the front end for MLZ
argument description
--docker-strategy -d [local|build|load] 'local' for localhost, 'build' to build from this repo, or 'load' to unzip an image
--docker-strategy -d [local|build|load|export] 'local' for localhost, 'build' to build from this repo, or 'load' to unzip an image, 'export' to build and create mlz.zip with the docker image
--subscription-id -s Subscription ID for MissionLZ resources
--location -l The location that you're deploying to (defaults to 'eastus')
--tf-environment -e Terraform azurerm environment (defaults to 'public') see: https://www.terraform.io/docs/language/settings/backends/azurerm.html#environment
Expand All @@ -56,6 +56,28 @@ setup_ezdeploy.sh: Setup the front end for MLZ
--tier2-sub-id -2 subscription ID for tier 2 network and resources (defaults to the value provided for -s --subscription-id)
```

### Step-by-Step Azure Air Gapped Installation

This process closely mirrors the standard azure documentation with a few subtle amendments.
Breanna-Stryker marked this conversation as resolved.
Show resolved Hide resolved

On your internet connected staging machine (With Docker Installed):

Build the docker image needed for deployment:

```BASH
cd src/scripts
./setup_ezdeploy.sh -d export
```

This will take some time by building the docker image, and then saving it to the scripts working directory and compressing it to "mlz.zip"

Move this file along with the repo to the destination for airgapped deployment Then execute the following

```BASH
cd src/scripts
./setup_ezdeploy.sh -d load -s <subscription id> -e "<AZURE_ENVIRONMENT>" -l "<AZURE_LOCATION>"
```

### Step-by-Step Local Installation

Running the user interface on your local workstation is not our recommended approach because it requires more setup, but it works.
Expand Down
2 changes: 1 addition & 1 deletion src/scripts/container-registry/add_auth_scopes.sh
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ wait_for_app_query_from_list "${mlz_fe_app_name}" "appId"

echo "INFO: sourcing app registration information for app ID ${app_id}..."
client_password=$(az ad app credential reset \
--id ${app_id} \
--id "${app_id}" \
--query password \
--only-show-errors \
--output tsv)
Expand Down
60 changes: 37 additions & 23 deletions src/scripts/setup_ezdeploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ show_help() {
printf "%20s %2s %s \n" "$long_name" "$char_name" "$desc"
}
print_formatted "argument" "" "description"
print_formatted "--docker-strategy" "-d" "[local|build|load] 'local' for localhost, 'build' to build from this repo, or 'load' to unzip an image (defaults to 'build')"
print_formatted "--docker-strategy" "-d" "[local|build|load|export] 'local' for localhost, 'build' to build from this repo, or 'load' to unzip an image (defaults to 'build'), export to build and create mlz.zip with the docker image"
print_formatted "--subscription-id" "-s" "Subscription ID for MissionLZ resources"
print_formatted "--location" "-l" "The location that you're deploying to (defaults to 'eastus')"
print_formatted "--tf-environment" "-e" "Terraform azurerm environment (defaults to 'public') see: https://www.terraform.io/docs/language/settings/backends/azurerm.html#environment"
Expand Down Expand Up @@ -79,23 +79,50 @@ container_registry_path="$(realpath "${this_script_path}")/container-registry"
"${this_script_path}/util/checkfordocker.sh"

# check mandatory parameters
for i in { $docker_strategy $mlz_config_subid $mlz_config_location $tf_environment $mlz_env_name $web_port }
do
if [[ $i == "notset" ]]; then
error_log "ERROR: Missing required arguments. These arguments are mandatory: -d, -s, -l, -e, -z, -p"
usage
exit 1
fi
done
if [[ $docker_strategy != "export" ]]; then
for i in { $docker_strategy $mlz_config_subid $mlz_config_location $tf_environment $mlz_env_name $web_port }
do
if [[ $i == "notset" ]]; then
error_log "ERROR: Missing required arguments. These arguments are mandatory: -d, -s, -l, -e, -z, -p"
usage
exit 1
fi
done
Breanna-Stryker marked this conversation as resolved.
Show resolved Hide resolved
fi

# check docker strategy
if [[ $docker_strategy != "local" && \
$docker_strategy != "build" && \
$docker_strategy != "load" ]]; then
$docker_strategy != "load" && \
$docker_strategy != "export" ]]; then
error_log "ERROR: Unrecognized docker strategy detected. Must be 'local', 'build', or 'load'."
exit 1
fi

# build/load, tag, and push image
image_name="lzfront"
image_tag="latest"

if [[ $docker_strategy == "build" || $docker_strategy == "export" ]]; then
echo "INFO: building docker image"
docker build -t "${image_name}" "${src_path}"
fi

if [[ $docker_strategy == "export" ]]; then
echo "INFO: Saving docker image and compressing it before exiting."
docker save "${image_name}:${image_tag}" -o mlz.tar
zip mlz.zip mlz.tar
rm mlz.tar
echo "INFO: Compressed deployable archive is saved locally as mlz.zip."
exit
fi
Breanna-Stryker marked this conversation as resolved.
Show resolved Hide resolved

if [[ $docker_strategy == "load" ]]; then
echo "INFO: Decompressing mlz zip archive and loading it to local docker image library."
unzip mlz.zip
docker load -i mlz.tar
fi

# switch to the MLZ subscription
echo "INFO: setting current az cli subscription to ${mlz_config_subid}..."
az account set --subscription "${mlz_config_subid}"
Expand Down Expand Up @@ -149,19 +176,6 @@ fi
# otherwise, create container registry
"${container_registry_path}/create_acr.sh" "$mlz_config_file"

# build/load, tag, and push image
image_name="lzfront"
image_tag="latest"

if [[ $docker_strategy == "build" ]]; then
docker build -t "${image_name}" "${src_path}"
fi

if [[ $docker_strategy == "load" ]]; then
unzip mlz.zip .
docker load -i mlz.tar
fi

docker tag "${image_name}:${image_tag}" "${mlz_acr_name}${mlz_acrLoginServerEndpoint}/${image_name}:${image_tag}"
docker push "${mlz_acr_name}${mlz_acrLoginServerEndpoint}/${image_name}:${image_tag}"

Expand Down