Skip to content

Commit 50b1dde

Browse files
committed
Pulled in release packaging scripting.
1 parent 1491d9d commit 50b1dde

File tree

3 files changed

+121
-6
lines changed

3 files changed

+121
-6
lines changed

.gitignore

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,4 +147,9 @@ website/versions-repo
147147
/electron/out
148148
/electron/dev-ssl
149149
/electron/jetstream
150-
/electron/version
150+
/electron/version
151+
152+
# Packager
153+
/stratos-ui/
154+
/stratos-ui-packaged.zip
155+

README.md

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ Tested with Browserstack
3131

3232
# Stratos UI pre-packager
3333

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

67-
## Usage
68+
## Packaging
6869

69-
Golang is required, and version 1.12 is recommended as this is the version used
70-
by the Stratos build system.
70+
Golang is required, and version 1.12 is recommended as this is the version used by the Stratos build system.
7171

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

76+
```bash
77+
./bin/package
7678
```
77-
TRAVIS_TAG=4.1.2 ./package.sh
79+
OR to package a specific tag
80+
```bash
81+
TAG="4.1.2" ./bin/package
7882
```
7983

8084
### NOTE
81-
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/).
85+
The original code for this feature can be found in the
86+
[Orange Cloud foundry Github Repository](https://github.com/orange-cloudfoundry/stratos-ui-cf-packager/).
8287
Many thanks to Benjamin & Arthur, we appreciate you both!
8388

8489
## License

bin/package

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
#!/usr/bin/env bash
2+
3+
set -euo pipefail
4+
5+
node::install() {
6+
local download_file
7+
download_file="${TMP_DIR}/node${NODE_VERSION}.tar.gz"
8+
9+
export node_install_dir="/tmp/node${NODE_VERSION}"
10+
export node_dir="${node_install_dir}/node-v${NODE_VERSION}-linux-x64"
11+
12+
mkdir -p "${node_install_dir}"
13+
14+
if [[ ! -f "${node_install_dir}/go/bin/go" ]]; then
15+
NODE_MD5="5bda713bd4aa39394536fc48c744854b"
16+
URL=https://buildpacks.cloudfoundry.org/dependencies/node/node-${NODE_VERSION}-linux-x64-40e8e080.tgz
17+
18+
echo "-----> Download Nodejs ${NODE_VERSION}"
19+
curl -s -L --retry 15 --retry-delay 2 $URL -o ${download_file}
20+
21+
DOWNLOAD_MD5=$(md5sum ${download_file} | cut -d ' ' -f 1)
22+
23+
if [[ ${DOWNLOAD_MD5} != ${NODE_MD5} ]]; then
24+
echo " **ERROR** MD5 mismatch: got $DOWNLOAD_MD5 expected $NODE_MD5"
25+
exit 1
26+
fi
27+
28+
tar xzf "${download_file}" -C "${node_install_dir}"
29+
rm "${download_file}"
30+
fi
31+
32+
if [[ ! -f "${node_dir}/bin/node" ]]; then
33+
echo " **ERROR** Could not download nodejs"
34+
exit 1
35+
fi
36+
37+
export NODE_HOME="${node_dir}"
38+
}
39+
40+
declare git_url git_tag work_dir
41+
declare -x TAG NODE_VERSION TMP_DIR
42+
43+
git_url="https://github.com/cloudfoundry-community/stratos.git"
44+
git_tag="${TAG:-master}}"
45+
work_dir="${PWD}"
46+
NODE_VERSION="${NODE_VERISON:-8.11.2}"
47+
TMP_DIR=/tmp
48+
49+
git clone "${git_url}" stratos-ui || true
50+
51+
if [[ -n ${git_tag} ]]; then
52+
pushd stratos-ui
53+
git checkout "${git_tag}"
54+
export stratos_version="${git_tag}"
55+
popd
56+
fi
57+
58+
function exit_trap() {
59+
# See: install_nodejs.sh
60+
NODE_VERSION="8.11.2"
61+
rm -rf "/tmp/node${NODE_VERSION}.tar.gz" "/tmp/node${NODE_VERSION}"
62+
}
63+
trap exit_trap EXIT
64+
65+
if ! which npm > /dev/null; then
66+
node::install
67+
export PATH="${NODE_HOME}/bin:$PATH"
68+
else
69+
npm_location="$(which npm)"
70+
export NODE_HOME="${npm_location%%/bin/npm}"
71+
fi
72+
73+
mkdir -p cache
74+
build_dir="${work_dir}/stratos-ui"
75+
76+
# Fix the "authenticity of host can't be established" error during build
77+
ssh-keyscan "bitbucket.org" >> ~/.ssh/known_hosts
78+
79+
# prebuild ui
80+
cd stratos-ui
81+
npm install
82+
npm run prebuild-ui
83+
rm -Rf ./dist
84+
85+
# Actually build Stratos
86+
bash -x deploy/cloud-foundry/build.sh "${build_dir}" "${work_dir}/cache"
87+
cd "${work_dir}"
88+
89+
# Remove build artifacts (node_modules & bower_components)
90+
if [[ -d "${build_dir}/node_modules" ]]; then
91+
rm -rf "${build_dir}/node_modules"
92+
fi
93+
94+
if [[ -d "${build_dir}/bower_components" ]]; then
95+
rm -rf "${build_dir}/bower_components"
96+
fi
97+
98+
echo "web: ./deploy/cloud-foundry/start.sh" > "${build_dir}/Procfile"
99+
100+
ls -lah "${build_dir}"
101+
cd "${build_dir}"
102+
zip -r "${work_dir}}/stratos-ui-packaged.zip" ./*
103+
cd "${work_dir}"
104+
105+
exit 0

0 commit comments

Comments
 (0)