Community

Custom GitHub Samples with IBM Cloud Tools for Swift

Share this post:

Disclaimer: IBM Cloud Tools for Swift (ICT) is no longer supported. Check out IBM Cloud App Service to take advantage of the same features of ICT in a more comprehensive experience for building Cloud Native applications in any programming language.


With our latest release of version 1.2, IBM Cloud Tools for Swift (ICT) now supports deployment of GitHub projects to Bluemix.

ICT is a Mac application developed for users to deploy, manage, and monitor their end-to-end applications. The tool is part of a larger IBM initiative to bring Swift to the server.

If this is your first time hearing about ICT and want to get started right away, there’s a great getting started guide and a To-Do List Sample App walk-through.

What’s New

Users can now clone and deploy GitHub projects to Bluemix using a simple UI. This allows for a more pleasant experience when sharing GitHub projects with other ICT users.

The first step in setting up your GitHub project for Bluemix is to create a manifest.yml file at the root of your project’s directory. Before doing so, check out Cloud Foundry’s documentation about how to create a manifest.yml.

There are a few gotch ya’s that will be the difference between failure and success of your app’s deployment. In this post, we will share some of these scenarios and their fixes. But first, we will go over some quick, successful examples.

Simple Example

Below is a code snippet of a simple manifest.yml file from Bluemix’s sample Hello World using node.js.

---
applications:
- name:    hello-node
  host:    hello-node
  memory:  128M
  command: node server.js

Here, we see that the app has a name, a memory allocation declaration, and the command needed to run the app. ICT will clone the project from GitHub, parse this manifest.yml, zip the contents of the cloned project, and send it to Bluemix with the manifest.yml‘s parsed information. Once received by Bluemix, it will execute the command to begin running the app.

Note: Even though the path data point is not specified for the server script (server.js in this example), there is an assumption that it lives in ./. Choosing to not specify a path data point is the same as setting it to ./.

 

Deployment of Simple Example

first step

Figure 1. Create Sample Project

To create a project in ICT with a GitHub repo, begin by clicking IBM Cloud Tools for Swift in the menu bar, then Advanced, and finally Create Sample Project From GitHub Repo.

 

second step

Figure 2. Link to Project URL on GitHub

Next, enter the URL to the GitHub repo.

 

third step

Figure 3. Name Runtime for Bluemix

Then, enter the desired name of your Cloud Runtime and select the space in which you would like to create the Cloud Runtime for your app. A Cloud Runtime is equivalent to a Cloud Foundry Application on Bluemix. When you’re done choosing a name and space, click Next.

 

fourth step

Figure 4. Wait for Deployment to Finish

Following the creation of a Cloud Runtime, ICT will clone the GitHub repo to a local folder of your choosing, parse the manifest.yml, create your Cloud Runtime on Bluemix, and deploy your application to the Cloud. This may take a few minutes.

 

final step

Figure 5. Enjoy Deployment

Once your app is done deploying to Bluemix, you can use ICT to manage and monitor your project.

 

Complex Example

Here is an example of a manifest.yml with multiple YAML data points. This comes from Swift@IBM‘s BluePic – a photo-sharing sample app that uses multiple Bluemix services. BluePic is a sample app already featured in ICT. Check out the project’s ReadMe for instructions on deploying it through the app. The data points to look at in this example are declared-services (top) and services (bottom).

Note: Bluemix services are subject to usage charges. This information can be found in their pricing catalog.

---
declared-services:
  BluePic-Cloudant:
    label: cloudantNoSQLDB
    plan: Shared
  BluePic-Object-Storage:
    label: Object-Storage
    plan: Free
  BluePic-Mobile-Client-Access:
    label: AdvancedMobileAccess
    plan: Gold
  BluePic-IBM-Push:
    label: imfpush
    plan: Basic
  BluePic-Insights-for-Weather:
    label: weatherinsights
    plan: Free-v2
  BluePic-Alchemy:
    label: alchemy_api
    plan: free
applications:
- name: BluePic
  path: ./BluePic-Server
  random-route: true
  memory: 512M
  disk_quota: 1024M
  instances: 1
  buildpack: https://github.com/IBM-Swift/swift-buildpack.git#develop
  services:
  - BluePic-Cloudant
  - BluePic-Object-Storage
  - BluePic-Mobile-Client-Access
  - BluePic-IBM-Push
  - BluePic-Insights-for-Weather
  - BluePic-Alchemy

In order for your app to deploy properly, there needs to be the same number of services as there are declared-services. Bluemix uses these data points to create the right services, name your instances, and bind them appropriately for your app.

Note: To successfully deploy BluePic, you will need 6 service spaces available. If you already a service instance of Object-Storage or Alchemy, the deployment will fail.

 

Invalid Examples

Here are examples of what not to do when creating a manifest.yml file for ICT.

Mismatch in Services to Declared-Services

In this example, there are services within the YAML data point, but there is no declared-services data point.

---
applications:
- name: invalid-project
  memory: 256M
  instances: 1
  host: invalid-project
  domain: mybluemix.net
  path: .
  command: npm start
  services:
    - redis01

The Fix: In order for this to deploy successfully, redis01 will need to be added to the declared-services data point with the appropriate service information.

 

Path Points to File

From a quick glance, we see that everything seems to check out A-OK.

---
declared-services:
  myElephant:
    label: elephantsql
    plan: turtle
applications:
- name: myUploader
  memory: 256M
  instances: 1
  path: ElephantSQL-Uploader.war # points to startup script
  services:
    - myElephant

Although, when deploying, we’ll get a “file not found” error.

invalid-path-to-file-fnf-error

Figure 6. File Not Found Error

The Fix: .war requires more explicit setup from the command line. Here is a good resource for setting up a .war.

 

Additional Examples to Fiddle With

Conclusion

The aim of the Custom GitHub Samples feature is to get users seamlessly deploying, scaling, and integrating their existing projects with Bluemix. If you have not already done so, download the IBM Cloud Tools for Swift Mac App. If you would like to submit any feedback to our team, please complete our survey. To learn more about the Swift@IBM program, visit our site.

More Community stories
August 3, 2018

Five Exciting Things About Istio v1.0

Istio, an open platform to connect, secure, control, and observe microservices, was launched on May 24, 2017, with joint force by IBM, Google, and Lyft. Over the last year, numerous new features and improvements have been made to get to the current production-ready version 1.0.

Continue reading

July 18, 2018

Part III: Wimbledon Facebook Bot on IBM Cloud

Delivering at scale: In the final part of the series, we discuss integrations with on-site systems at the All England Club and how we used Multi-Region within IBM Cloud to ensure scale and availability.

Continue reading

July 12, 2018

Db2 on Cloud Announces Disaster Recovery Node

The Db2 on Cloud team is excited to announce Disaster Recovery (DR) capabilities for Db2 on Cloud. It leverages Db2's HADR technology and lets users add a DR Node on demand in an offsite data center of their choice. In an unlikely event where the primary data server is affected by external circumstances, such as a natural disaster, users can failover to their Geo-Replicated Disaster Recovery Node with a few clicks.

Continue reading