Skip to content

Commit

Permalink
Pulled in release packaging scripting.
Browse files Browse the repository at this point in the history
  • Loading branch information
wayneeseguin committed Aug 23, 2023
1 parent 1491d9d commit 50b1dde
Show file tree
Hide file tree
Showing 3 changed files with 121 additions and 6 deletions.
7 changes: 6 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -147,4 +147,9 @@ website/versions-repo
/electron/out
/electron/dev-ssl
/electron/jetstream
/electron/version
/electron/version

# Packager
/stratos-ui/
/stratos-ui-packaged.zip

15 changes: 10 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ Tested with Browserstack

# Stratos UI pre-packager


This feature helps in pre-building the
[Stratos](https://github.com/cloudfoundry-community/stratos) web application
so that it can be deployed faster in Cloud Foundry, or be run offline.
Expand Down Expand Up @@ -64,21 +65,25 @@ genesis <env-name> do stratos sgs
```
Note: `sgs` creates security groups the first time, upgrades do not use `sgs`.

## Usage
## Packaging

Golang is required, and version 1.12 is recommended as this is the version used
by the Stratos build system.
Golang is required, and version 1.12 is recommended as this is the version used by the Stratos build system.

When you want to build the `4.1.2` tag in
[Stratos UI releases](https://github.com/cloudfoundry-community/stratos/releases),
run this command:

```bash
./bin/package
```
TRAVIS_TAG=4.1.2 ./package.sh
OR to package a specific tag
```bash
TAG="4.1.2" ./bin/package
```

### NOTE
The original code for this feature can be found in the [Orange Cloud foundry Github Repository](https://github.com/orange-cloudfoundry/stratos-ui-cf-packager/).
The original code for this feature can be found in the
[Orange Cloud foundry Github Repository](https://github.com/orange-cloudfoundry/stratos-ui-cf-packager/).
Many thanks to Benjamin & Arthur, we appreciate you both!

## License
Expand Down
105 changes: 105 additions & 0 deletions bin/package
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
#!/usr/bin/env bash

set -euo pipefail

node::install() {
local download_file
download_file="${TMP_DIR}/node${NODE_VERSION}.tar.gz"

export node_install_dir="/tmp/node${NODE_VERSION}"
export node_dir="${node_install_dir}/node-v${NODE_VERSION}-linux-x64"

mkdir -p "${node_install_dir}"

if [[ ! -f "${node_install_dir}/go/bin/go" ]]; then
NODE_MD5="5bda713bd4aa39394536fc48c744854b"
URL=https://buildpacks.cloudfoundry.org/dependencies/node/node-${NODE_VERSION}-linux-x64-40e8e080.tgz

echo "-----> Download Nodejs ${NODE_VERSION}"
curl -s -L --retry 15 --retry-delay 2 $URL -o ${download_file}

DOWNLOAD_MD5=$(md5sum ${download_file} | cut -d ' ' -f 1)

if [[ ${DOWNLOAD_MD5} != ${NODE_MD5} ]]; then
echo " **ERROR** MD5 mismatch: got $DOWNLOAD_MD5 expected $NODE_MD5"
exit 1
fi

tar xzf "${download_file}" -C "${node_install_dir}"
rm "${download_file}"
fi

if [[ ! -f "${node_dir}/bin/node" ]]; then
echo " **ERROR** Could not download nodejs"
exit 1
fi

export NODE_HOME="${node_dir}"
}

declare git_url git_tag work_dir
declare -x TAG NODE_VERSION TMP_DIR

git_url="https://github.com/cloudfoundry-community/stratos.git"
git_tag="${TAG:-master}}"
work_dir="${PWD}"
NODE_VERSION="${NODE_VERISON:-8.11.2}"
TMP_DIR=/tmp

git clone "${git_url}" stratos-ui || true

if [[ -n ${git_tag} ]]; then
pushd stratos-ui
git checkout "${git_tag}"
export stratos_version="${git_tag}"
popd
fi

function exit_trap() {
# See: install_nodejs.sh
NODE_VERSION="8.11.2"
rm -rf "/tmp/node${NODE_VERSION}.tar.gz" "/tmp/node${NODE_VERSION}"
}
trap exit_trap EXIT

if ! which npm > /dev/null; then
node::install
export PATH="${NODE_HOME}/bin:$PATH"
else
npm_location="$(which npm)"
export NODE_HOME="${npm_location%%/bin/npm}"
fi

mkdir -p cache
build_dir="${work_dir}/stratos-ui"

# Fix the "authenticity of host can't be established" error during build
ssh-keyscan "bitbucket.org" >> ~/.ssh/known_hosts

# prebuild ui
cd stratos-ui
npm install
npm run prebuild-ui
rm -Rf ./dist

# Actually build Stratos
bash -x deploy/cloud-foundry/build.sh "${build_dir}" "${work_dir}/cache"
cd "${work_dir}"

# Remove build artifacts (node_modules & bower_components)
if [[ -d "${build_dir}/node_modules" ]]; then
rm -rf "${build_dir}/node_modules"
fi

if [[ -d "${build_dir}/bower_components" ]]; then
rm -rf "${build_dir}/bower_components"
fi

echo "web: ./deploy/cloud-foundry/start.sh" > "${build_dir}/Procfile"

ls -lah "${build_dir}"
cd "${build_dir}"
zip -r "${work_dir}}/stratos-ui-packaged.zip" ./*
cd "${work_dir}"

exit 0

0 comments on commit 50b1dde

Please sign in to comment.