Skip to content

Commit

Permalink
Add the project_id to the app build path
Browse files Browse the repository at this point in the history
This is so app "X" from two different projects don't
conflict.

Change-Id: Ia74c955ae94eccd42be43ed4bae26ebfc814bda3
  • Loading branch information
Angus Salkeld committed Mar 7, 2014
1 parent bfd1077 commit 3ccde36
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 17 deletions.
7 changes: 5 additions & 2 deletions contrib/lp-cedarish/docker/README.md
Expand Up @@ -29,7 +29,11 @@ This should prepare your system to use the docker builder by building a few cont
The build script takes two positional arguments. The location of the git repo, and the app name. Currently requires sudo access to work with docker. Run it as the same user you installed devstack which has passwordless sudo.

```
/solum/contrib/lp-cedarish/docker/build-app https://github.com/paulczar/example-nodejs-express.git nodejs
$ source ~/devstack/openrc
$ keystone tenant-get $OS_TENANT_NAME
# get the tenant_id and pass that into build-app
/solum/contrib/lp-cedarish/docker/build-app https://github.com/paulczar/example-nodejs-express.git nodejs $OS_TENANT_ID
```

This script will upload a docker container with your built application to glance to be run via nova.
Expand All @@ -39,7 +43,6 @@ This script will upload a docker container with your built application to glance
Due to a bug with the docker driver the first VM you start will run `sh` instead of the embedded `CMD`. thus we should kick off a dummy build first

```
$ source ~/devstack/openrc
$ nova image-list
+--------------------------------------+---------------------------------+--------+--------+
| ID | Name | Status | Server |
Expand Down
30 changes: 15 additions & 15 deletions contrib/lp-cedarish/docker/build-app
Expand Up @@ -3,20 +3,24 @@
docker ps 2> /dev/null > /dev/null
[[ $? != 0 ]] && echo "cannot talk to docker." && exit 1

if [[ -z $1 ]] || [[ -z $2 ]]; then
echo "Usage: build git_url appname"
if [[ -z $1 ]] || [[ -z $2 ]] || [[ -z $3 ]]; then
echo "Usage: build git_url appname project_id"
exit 1
fi

GIT=$1
APP=$2
TENANT=$3

mkdir -p /opt/solum/apps/$APP
APP_DIR=/opt/solum/apps/$TENANT/$APP
mkdir -p $APP_DIR

[[ -d /opt/solum/apps/$APP/build ]] && rm -rf /opt/solum/apps/$APP/build
git clone $GIT /opt/solum/apps/$APP/build
[[ -d $APP_DIR/build ]] && rm -rf $APP_DIR/build
git clone $GIT $APP_DIR/build

cd /opt/solum/apps/$APP/build
cd $APP_DIR/build

echo '===> building App'

# Build the application slug
BUILD_ID=$(git archive master | sudo docker run -i -a stdin \
Expand All @@ -26,15 +30,15 @@ BUILD_ID=$(git archive master | sudo docker run -i -a stdin \

sudo docker attach $BUILD_ID

cd /opt/solum/apps/$APP
sudo docker cp $BUILD_ID:/tmp/slug.tgz /opt/solum/apps/$APP/
cd $APP_DIR
sudo docker cp $BUILD_ID:/tmp/slug.tgz $APP_DIR/
sudo docker rm $BUILD_ID
rm -rf /opt/solum/apps/$APP/build
rm -rf $APP_DIR/build

# Build the application image by injecting slug into runner
# and push to docker-registry ( which is tied to glance )

cat << EOF > /opt/solum/apps/$APP/Dockerfile
cat << EOF > $APP_DIR/Dockerfile
# SOLUM APP BUILDER
FROM solum/slugrunner
ADD slug.tgz /app
Expand All @@ -44,11 +48,7 @@ ENTRYPOINT ["/runner/init"]
CMD ["start","web"]
EOF

cd /opt/solum/apps/$APP
cd $APP_DIR
sudo docker build -t 127.0.0.1:5042/$APP .

sudo docker push 127.0.0.1:5042/$APP




0 comments on commit 3ccde36

Please sign in to comment.