diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 90d298dbe..b0e816a5c 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -101,5 +101,6 @@ and we will add you. **All** contributors belong here. 💯 - [guangwu guo](https://github.com/testwill) - [Eric Herrmann](https://github.com/egherrmann) - [Alex Dejanu](https://github.com/dejanu) +- [John Cudd](https://github.com/jmcudd) diff --git a/docs/content/docs/getting-started/install-porter.md b/docs/content/docs/getting-started/install-porter.md index 76d07ed0c..6eaa0eea7 100644 --- a/docs/content/docs/getting-started/install-porter.md +++ b/docs/content/docs/getting-started/install-porter.md @@ -12,6 +12,7 @@ aliases: - [Install or Upgrade Porter](#install-or-upgrade) - [Clean Install](#clean-install) - [Install Latest Release](#latest) +- [Air-gapped Install](#air-gapped-install) - [Install a Canary Build](#canary) - [Install a Mixin](#mixins) - [Install a Plugin](#plugins) @@ -114,6 +115,29 @@ You will need to create a [PowerShell Profile][ps-link] if you do not have one. iwr "https://cdn.porter.sh/latest/install-windows.ps1" -UseBasicParsing | iex ``` +## Air-gapped Install + +To run the installation script in an air-gapped environment, create an air-gapped installation package with the `bundle-linux.sh` script. Note that mixins are not currently included in the air-gapped-bundle. + +```sh +curl -L https://raw.githubusercontent.com/getporter/porter/main/scripts/bundle/bundle-linux.sh | bash +``` + +Then extract and install Porter. + +```sh +tar -xzf porter-air-gapped-install-latest.tar.gz -C . +cd porter-air-gapped-install-latest +bash install-bundle.sh +``` + +Note: The `install-bundle.sh` script starts mongo. If mongo ever has to be restarted use the following command. + +``` +docker run --name porter-mongodb-docker-plugin -d -p 27018:27017 -v mongodb_data:/data/db --restart always mongo:4.0-xenial +``` + + ## Canary Install the most recent build of Porter and the [exec mixin] from the main branch. diff --git a/docs/static/_redirects b/docs/static/_redirects index 03e339998..6b3528ef8 100644 --- a/docs/static/_redirects +++ b/docs/static/_redirects @@ -64,6 +64,7 @@ /:version/install-linux.sh https://github.com/getporter/porter/releases/download/:version/install-linux.sh 200 /:version/install-mac.sh https://github.com/getporter/porter/releases/download/:version/install-mac.sh 200 /:version/install-windows.ps1 https://github.com/getporter/porter/releases/download/:version/install-windows.ps1 200 +/:version/bundle-linux.sh https://github.com/getporter/porter/releases/download/:version/bundle-linux.sh 200 # Redirect the porter release artifacts /:version/* https://github.com/getporter/porter/releases/download/:version/:splat 302 diff --git a/scripts/bundle/bundle-linux.sh b/scripts/bundle/bundle-linux.sh new file mode 100644 index 000000000..7e0e60f10 --- /dev/null +++ b/scripts/bundle/bundle-linux.sh @@ -0,0 +1,52 @@ +#!/usr/bin/env bash +set -euo pipefail + +PORTER_MIRROR=${PORTER_MIRROR:-https://cdn.porter.sh} +PORTER_VERSION=${PORTER_VERSION:-latest} +MONGO_IMAGE_FILE="mongo_image.tar" +MONGO_IMAGE_URL="docker.io/library/mongo:4.0-xenial" +BUNDLE_NAME="porter-air-gapped-install-$PORTER_VERSION" +DOWNLOAD_DIR="/tmp/$BUNDLE_NAME" + +PORTER_BINARY_URL=${PORTER_BINARY_URL:-"$PORTER_MIRROR/$PORTER_VERSION/porter-linux-amd64"} +PORTER_SCRIPT_URL=${PORTER_SCRIPT_URL:-"$PORTER_MIRROR/$PORTER_VERSION/install-linux.sh"} + +mkdir -p $DOWNLOAD_DIR + +echo "Pulling MongoDB image..." +docker pull "$MONGO_IMAGE_URL" +echo "Saving MongoDB image to $MONGO_IMAGE_FILE..." +docker save -o "$DOWNLOAD_DIR/$MONGO_IMAGE_FILE" "$MONGO_IMAGE_URL" + +echo "Downloading Porter Install Script from $PORTER_SCRIPT_URL" +curl -fsSLo "$DOWNLOAD_DIR/install-linux.sh" "$PORTER_SCRIPT_URL" + +echo "Downloading Porter Binary from $PORTER_BINARY_URL" +curl -fsSLo "$DOWNLOAD_DIR/porter-linux-amd64" "$PORTER_BINARY_URL" + +cat << EOF > $DOWNLOAD_DIR/install-bundle.sh +export PORTER_BINARY_URL="file://\$(realpath ./porter-linux-amd64)" +export PORTER_SCRIPT_URL="file://\$(realpath ./install-linux.sh)" +bash install-linux.sh +docker load -i "$MONGO_IMAGE_FILE" +if ! docker ps -q -f name=porter-mongodb-docker-plugin; then + echo "Running MongoDB container..." + docker run --name porter-mongodb-docker-plugin -d -p 27018:27017 -v mongodb_data:/data/db --restart always mongo:4.0-xenial +else + echo "MongoDB container is already running." +fi +EOF + + +TAR_FILE="$BUNDLE_NAME.tar.gz" +echo "Creating tarball: $TAR_FILE..." +tar -czvf "$TAR_FILE" -C /tmp "$(basename "$DOWNLOAD_DIR")" + +echo "Bundle created: $TAR_FILE" +echo "Usage Instructions:" +echo "tar -xzf $TAR_FILE -C ." +echo "cd $BUNDLE_NAME" +echo "bash install-bundle.sh" + +exit 0 + diff --git a/scripts/install/install-linux.sh b/scripts/install/install-linux.sh index 9cda6dde4..e23ec20e0 100755 --- a/scripts/install/install-linux.sh +++ b/scripts/install/install-linux.sh @@ -2,20 +2,22 @@ set -euo pipefail # Installs the porter CLI for a single user. -# PORTER_HOME: Location where Porter is installed (defaults to ~/.porter). -# PORTER_MIRROR: Base URL where Porter assets, such as binaries and atom feeds, are downloaded. -# This lets you setup an internal mirror. -# PORTER_VERSION: The version of Porter assets to download. +# PORTER_HOME: Location where Porter is installed (defaults to ~/.porter). +# PORTER_MIRROR: Base URL where Porter assets, such as binaries and atom feeds, are downloaded. +# This lets you setup an internal mirror. +# PORTER_VERSION: The version of Porter assets to download. +# PORTER_BINARY_URL: The URL to porter binary (https:// or file:// for local binary) export PORTER_HOME=${PORTER_HOME:-~/.porter} export PORTER_MIRROR=${PORTER_MIRROR:-https://cdn.porter.sh} PORTER_VERSION=${PORTER_VERSION:-latest} +PORTER_BINARY_URL=${PORTER_BINARY_URL:-"$PORTER_MIRROR/$PORTER_VERSION/porter-linux-amd64"} -echo "Installing porter@$PORTER_VERSION to $PORTER_HOME from $PORTER_MIRROR" +echo "Installing porter@$PORTER_VERSION to $PORTER_HOME from $PORTER_BINARY_URL" mkdir -p "$PORTER_HOME/runtimes" -curl -fsSLo "$PORTER_HOME/porter" "$PORTER_MIRROR/$PORTER_VERSION/porter-linux-amd64" +curl -fsSLo "$PORTER_HOME/porter" "$PORTER_BINARY_URL" chmod +x "$PORTER_HOME/porter" cp "$PORTER_HOME/porter" "$PORTER_HOME/runtimes/porter-runtime" echo Installed "$("$PORTER_HOME"/porter version)" diff --git a/scripts/prep-install-scripts.sh b/scripts/prep-install-scripts.sh index 5c53576dd..17181c47c 100755 --- a/scripts/prep-install-scripts.sh +++ b/scripts/prep-install-scripts.sh @@ -8,3 +8,4 @@ ls -R bin sed -e "s|PORTER_VERSION:-latest|PORTER_VERSION:-$VERSION|g" scripts/install/install-mac.sh > bin/$VERSION/install-mac.sh sed -e "s|PORTER_VERSION:-latest|PORTER_VERSION:-$VERSION|g" scripts/install/install-linux.sh > bin/$VERSION/install-linux.sh sed -e "s|PORTER_VERSION='latest'|PORTER_VERSION='$VERSION'|g" scripts/install/install-windows.ps1 > bin/$VERSION/install-windows.ps1 +sed -e "s|PORTER_VERSION:-latest|PORTER_VERSION:-$VERSION|g" scripts/bundle/bundle-linux.sh > bin/$VERSION/bundle-linux.sh