Skip to content

Commit e73c46b

Browse files
committed
Merge pull request #21 from hpcloud/rar_build_and_tag
LGTM
2 parents cad553f + 3a87c6d commit e73c46b

5 files changed

+995
-0
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
.DS_Store
22
.idea
3+
output/

README.md

+25
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,30 @@
11
# Stratos Deploy
22

3+
## Building the Console for HCP
4+
5+
```
6+
./build_and_tag.sh
7+
```
8+
9+
This script supports the following optional arguments:
10+
11+
```
12+
-t TAG_NAME
13+
-r REGISTRY_ADDRESS
14+
```
15+
16+
The default for TAG_NAME is a ISO-8601-like timestamp, of `YYYYmmddTHHMMSSZ`
17+
18+
The default for REGISTRY_ADDRESS is `docker-registry.helion.space:443`
19+
20+
This will build all of the images for the console, and creates a folder called `output` that contains
21+
a HCP service definition and instance definition that refer to the specific registry and tag created
22+
during this build.
23+
24+
**Note:** If you're doing local development, against your local registry, the generated service and
25+
instance definition should not be distributed, as they do not refer to a generally accessible Docker
26+
registry!
27+
328
## Deploying the Console locally via Docker Compose
429

530
### Requirements:

build_and_tag.sh

+116
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
#!/bin/bash
2+
set -e
3+
4+
# set the defaults for docker registry and tag
5+
DOCKER_REGISTRY=docker-registry.helion.space:443
6+
TAG=$(date -u +"%Y%m%dT%H%M%SZ")
7+
8+
while getopts ":r:t:" opt; do
9+
case $opt in
10+
r)
11+
DOCKER_REGISTRY="$OPTARG"
12+
;;
13+
t)
14+
TAG="$OPTARG"
15+
;;
16+
\?)
17+
echo "Invalid option: -$OPTARG" >&2
18+
exit 1
19+
;;
20+
:)
21+
echo "Option -$OPTARG requires an argument." >&2
22+
exit 1
23+
;;
24+
esac
25+
done
26+
27+
echo "Registry: $DOCKER_REGISTRY"
28+
echo "Tag: $TAG"
29+
30+
echo "Starting build"
31+
32+
GROUP_NAME=helioncf
33+
BUILD_ARGS=""
34+
__DIRNAME="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
35+
36+
#BUILD_ARGS="--build-arg http_proxy=http://proxy.sdc.hp.com:8080"
37+
#BUILD_ARGS="$BUILD_ARGS --build-arg https_proxy=http://proxy.sdc.hp.com:8080"
38+
39+
function buildAndPublishImage {
40+
# $1 is name
41+
# $2 is docker file name
42+
# $3 is folder name
43+
44+
NAME=$1
45+
DOCKER_FILE=$2
46+
FOLDER=$3
47+
48+
if [ ! -d "${FOLDER}" ]; then
49+
echo "Project ${FOLDER} hasn't been checked out";
50+
exit 1
51+
fi
52+
53+
IMAGE_URL=${DOCKER_REGISTRY}/${GROUP_NAME}/${NAME}:${TAG}
54+
echo Building Docker Image for $NAME
55+
56+
pushd ${FOLDER}
57+
pwd
58+
docker build ${BUILD_ARGS} -t $NAME -f $DOCKER_FILE .
59+
60+
docker tag ${NAME} ${IMAGE_URL}
61+
62+
echo Pushing Docker Image ${IMAGE_URL}
63+
docker push ${IMAGE_URL}
64+
popd
65+
}
66+
67+
# Cleanup the SDL/instance defs
68+
rm -rf ${__DIRNAME}/output/*
69+
70+
# Cleanup prior to generating the UI container
71+
rm -rf ${__DIRNAME}/../stratos-ui/dist
72+
rm -rf ${__DIRNAME}/../stratos-server/dist
73+
74+
# Build and publish all of the images for Stratos Console UI
75+
buildAndPublishImage cnap-console-db Dockerfile.UCP ${__DIRNAME}/../stratos-identity-db
76+
buildAndPublishImage cnap-console-mock-api Dockerfile.mock_api.UCP ${__DIRNAME}/../stratos-node-server
77+
buildAndPublishImage cnap-console-mock-auth Dockerfile.mock_auth.UCP ${__DIRNAME}/../stratos-node-server
78+
buildAndPublishImage cnap-console-api Dockerfile.UCP ${__DIRNAME}/../stratos-node-server
79+
80+
# Build Portal Proxy
81+
PORTAL_PROXY_PATH=$GOPATH/src/github.com/hpcloud/portal-proxy
82+
pushd ${PORTAL_PROXY_PATH}
83+
./tools/build_portal_proxy.sh
84+
popd
85+
86+
# Build and publish the container image for the portal proxy
87+
buildAndPublishImage cnap-console-proxy server.Dockerfile ${PORTAL_PROXY_PATH}
88+
89+
# Build the postgres configuration container
90+
buildAndPublishImage cnap-console-database-configuration database.Dockerfile.UCP ${PORTAL_PROXY_PATH}
91+
92+
# Prepare the nginx server
93+
docker run --rm \
94+
-v ${__DIRNAME}/../stratos-ui:/usr/src/app \
95+
-v ${__DIRNAME}/../helion-ui-framework:/usr/src/helion-ui-framework \
96+
-v ${__DIRNAME}/../helion-ui-theme:/usr/src/helion-ui-theme \
97+
-w /usr/src/app \
98+
node:4.2.3 \
99+
/bin/bash ./provision.sh
100+
101+
# Copy the artifacts from the above to the stratos-server
102+
cp -R ${__DIRNAME}/../stratos-ui/dist ${__DIRNAME}/../stratos-server/dist
103+
104+
# Build and push an image based on stratos-server
105+
buildAndPublishImage cnap-console-server Dockerfile.UCP ${__DIRNAME}/../stratos-server
106+
107+
echo "Creating service and instance definition"
108+
109+
mkdir -p ${__DIRNAME}/output
110+
for FILE in ${__DIRNAME}/ucp_templates/*.json ; do
111+
ofile=${__DIRNAME}/output/$(basename $FILE)
112+
cat $FILE | sed s/{{TAG}}/$TAG/g | sed s/{{REGISTRY}}/$DOCKER_REGISTRY/g > $ofile
113+
done
114+
115+
echo "Build complete. Tag is $TAG and UCP definitions are in ${__DIRNAME}/output/"
116+
echo "The definitions are using registry: $DOCKER_REGISTRY and tag: $TAG"

0 commit comments

Comments
 (0)