Skip to content

Commit

Permalink
updated populate-db command
Browse files Browse the repository at this point in the history
  • Loading branch information
tfrank64 committed Jan 13, 2017
1 parent 73267ef commit 3af97b2
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 75 deletions.
69 changes: 3 additions & 66 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,77 +136,14 @@ Or, you can follow the step-by-step instructions below.
```
cf ic group inspect <imageName>
```

At this point, your app should be deployed! Accessing your apps route should return your todos, which should be `[]` to start.

### Deploying Docker to IBM Bluemix Container (old)

1. Download and install the CloudFoundry CLI [here](https://github.com/cloudfoundry/cli/releases).

2. Install the IBM Containers plugin for CF:

[Directions are here](https://console.ng.bluemix.net/docs/containers/container_cli_cfic_install.html) for different operating systems.


```
cf install-plugin https://static-ice.ng.bluemix.net/ibm-containers-mac
cf api https://api.ng.bluemix.net
cf login
cf ic login
```

Note the namespace you see:

```
Authenticating with the IBM Containers registry host registry.ng.bluemix.net...
OK
You are authenticated with the IBM Containers registry.
Your organization's private Bluemix registry: registry.ng.bluemix.net/<your namespace>
```

5. Build a Docker image

```
docker build -t todolist-couchdb .
```

6. Tag the Docker image:

```
docker tag todolist-couchdb registry.ng.bluemix.net/<your namespace>/todolist-couchdb
```

7. Push the Docker image:

```
docker push registry.ng.bluemix.net/<your namespace>/todolist-couchdb
```

8. Create Cloudant service:
8. Optionally, if you want to populate your database with some sample data, run the following command with your image name:

```
cf create-service cloudantNoSQLDB Lite TodoListCloudantDatabase
./config.sh populate-db <imageName>
```

8. Create a new local directory with an `empty.txt` file, then navigate into that directory.

8. Create a bridge application:

```
cf push containerbridge -p . -i 1 -d mybluemix.net -k 1M -m 64M --no-hostname --no-manifest --no-route --no-start
```

8. Bind service to bridge app:

```
cf bind-service containerbridge TodoListCloudantDatabase
```

8. Create the Docker group:

```
cf ic group create --anti --auto --name todolist-couchdb -n <hostname you want> -d mybluemix.net -p 8090 -m 128 -e "CCS_BIND_APP=containerbridge" registry.ng.bluemix.net/<your namespace>/todolist-couchdb
```
At this point, your app should be deployed! Accessing your apps route should return your todos, which should be `[]` if you did not populate the database.

### Manually

Expand Down
18 changes: 9 additions & 9 deletions config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ function help {
create-bridge Creates empty bridge application
create-db Creates database service and binds to bridge
deploy <imageName> Binds everything together (app, db, container) through container group
populate-db Populates database with initial data
populate-db <imageName> Populates database with initial data
delete <imageName> Delete the group container and deletes created service if possible
all <imageName> Combines all necessary commands to deploy an app to Bluemix in a Docker container.
!!EOF
Expand Down Expand Up @@ -132,16 +132,16 @@ deployContainer () {
}

populateDB () {
if [ -z $BRIDGE_APP_NAME ]
if [ -z "$1" ]
then
echo "Error: Could not deploy container to Bluemix, missing variables."
echo "Error: Could not populate db with sample data, missing imageName."
return
fi
rawValue=$(cf env $BRIDGE_APP_NAME | grep 'uri_cli' | awk -F: '{print $2}')
commanToRun=$(echo $rawValue | tr -d '\' | sed -e 's/^"//' -e 's/"$//')

password=$(cf env $BRIDGE_APP_NAME | grep 'postgres://' | sed -e 's/@bluemix.*$//' -e 's/^.*admin://')
eval PGPASSWORD=$password $commanToRun < Database/schema.sql

appURL="https://"$1"-app.mybluemix.net"
eval $(curl -X POST -H "Content-Type: application/json" -d '{ "title": "Wash the car", "order": 0, "completed": false }' $appURL)
eval $(curl -X POST -H "Content-Type: application/json" -d '{ "title": "Walk the dog", "order": 2, "completed": true }' $appURL)
eval $(curl -X POST -H "Content-Type: application/json" -d '{ "title": "Clean the gutters", "order": 1, "completed": false }' $appURL)
}

delete () {
Expand Down Expand Up @@ -193,7 +193,7 @@ case $ACTION in
"create-bridge") createBridge;;
"create-db") createDatabase;;
"deploy") deployContainer "$2";;
"populate-db") populateDB;;
"populate-db") populateDB "$2";;
"delete") delete "$2";;
"all") all "$2";;
*) help;;
Expand Down

0 comments on commit 3af97b2

Please sign in to comment.