This project is part of the 'IBM Cloud Native Reference Architecture' suite, available at https://github.com/ibm-cloud-architecture/refarch-cloudnative
This project sits between the iOS Application and the Object Storage Service. It is built with Swift 3.0 and Kitura web framework with following functionality:
- Serve the application images stored in the Bluemix Object Storage service
The Swift code is located in the Sources folder.
- Provision an instance of
Object Storageinto your Bluemix space.
- Select name for your instance.
- Click the
Createbutton. - Note:
- You can only provision one Free instance of
Object Storageper Bluemix organization.
- You can only provision one Free instance of
- Once provisioned, obtain
Object Storageservice credentials.
- Click on
Service Credentialstab. - Then click on the
View Credentialsdropdown next to the credentials.
- You will need the following:
- projectId: Object Storage Open Stack project id.
- userId: Object Storage user.
- password: Object Storage password.
- Keep those credential handy as they will be needed throughout the rest of this document.
- Create an Object Storage container. Bluemix Object Storage uses
containeras unit of managing content.
- Click the "Manage" tab, then click the
Select Actiondropdown, and chooseCreate Container. - Name the Container
bluecompute.
- Upload the application images into the container.
- From your compute file explore (or Finder in Mac), locate the
imagefolder. - Drag and drop all the images to the Browser Object Storage
bluecomputecontainer.- Alternatively, you can click add file actions to load images.
You can use the following button to deploy the BlueCompute iOS BFF to Bluemix, or you can follow the manual instructions in the following sections. If you decide on the toolchain button, you have to fulfill the following pre-requisites:
- Provision an Object Storage service instance in your Bluemix Space.
- The toolchain will automatically pick up the
Object Storagecredentials.
- The toolchain will automatically pick up the
- If not already done, provision an instance of Object Storage.
- Open
env.shand enter the followingObject Storagecredentials collected in the Pre-requisites:
- projectId
- userId
- password
-
Load credentials into environment
# source env.sh -
Run the application:
# swift build # ./.build/debug/bluecompute-bff-ios
- This will start the application on port 8090.
- Validate the local application:
- If not already done, provision an instance of Object Storage.
- Open
manifest.ymland enter the followingObject Storagecredentials collected in the Pre-requisites:
- projectId
- userId
- password
-
Deploy application to Cloud Foundry:
# cf push -
Alternatively, you can bind existing
Object Storageinstance directly to cf app:cf push bluecompute-bff-ios -n bluecompute-bff-ios -d "mybluemix.net" --no-start cf bind-service bluecompute-bff-ios objectstorage-instance-name cf start bluecompute-bff-ios -
Validate the Cloud Foundry application:
-
If not already done, provision an instance of Object Storage.
-
Build container image:
# docker build -t cloudnative/bluecompute-bff-ios . -
Start the application in docker container:
# docker run -i -d -p 8090:8090 --name bluecompute-bff-ios \ -e "projectId={OS_PROJECT_ID}" \ -e "userId={OS_USER_ID}" \ -e "password={OS_PASSWORD}" \ cloudnative/bluecompute-bff-ios
- Replace {OS_PROJECT_ID} with the
Object Storageproject id. - Replace {OS_USER_ID} with the
Object Storageuser id. - Replace {OS_PASSWORD} with the
Object Storagepassword.
- Validate the local docker application:
##Deploy Mobile BFF Service application on Bluemix container In this section you will deploy the Mobile BFF application to run in IBM Bluemix containers.
-
Log in to your Bluemix account.
# cf login -a <bluemix-api-endpoint> -u <your-bluemix-user-id> -
Set target to use your Bluemix Org and Space.
# cf target -o <your-bluemix-org> -s <your-bluemix-space> -
Log in to IBM Containers plugin.
# cf ic login -
Build container image
# docker build -t cloudnative/bluecompute-bff-ios . -
Tag and push the local docker image to bluemix private registry.
# docker tag cloudnative/bluecompute-bff-ios registry.ng.bluemix.net/$(cf ic namespace get)/bluecompute-bff-ios:cloudnative # docker push registry.ng.bluemix.net/$(cf ic namespace get)/bluecompute-bff-ios:cloudnative -
If not already done, provision an instance of Object Storage.
-
Start the application in IBM Bluemix container.
# cf ic group create -p 8090 -m 1024 --min 1 --auto --name bluecompute-bff-ios \
-e "projectId={OS_PROJECT_ID}" \
-e "userId={OS_USER_ID}" \
-e "password={OS_PASSWORD}" \
-n bluecompute-bff-ios \
-d mybluemix.net registry.ng.bluemix.net/$(cf ic namespace get)/bluecompute-bff-ios:cloudnative
```
- Replace {OS_PROJECT_ID} with the `Object Storage` project id.
- Replace {OS_USER_ID} with the `Object Storage` user id.
- Replace {OS_PASSWORD} with the `Object Storage` password.
7. **Validate. Open a browser and enter the following:**
- [https://bluecompute-bff-ios.mybluemix.net/image/collator.jpg](https://bluecompute-bff-ios.mybluemix.net/image/collator.jpg)
