Todo backend is an example of using the Kitura Swift framework for building a productivity app with a database for storage of tasks.
You can set up your development environment and use XCode 8 for editing, building, debugging, and testing your server application. To use XCode, you must use the command line tools for generating an XCode project.
You can use brew install couchdb
- Clone the TodoList CouchDB repository:
git clone https://github.com/IBM-Swift/TodoList-CouchDB
- Make an XCode project
swift package generate-xcodeproj
-
Start up CouchDB with the
couchdb
command. -
Set up your database
cd Database && ./setup.sh
- Run the
Deploy
target in Xcode and access http://localhost:8090/ in your browser to see an empty database.
To build the project in Linux, you need to first install the Swift 3 toolchain.
-
Install the Swift 3.0 RELEASE toolchain
-
Install CouchDB:
sudo apt-get install couchdb
- Clone the repository:
git clone https://github.com/IBM-Swift/TodoList-CouchDB
-
Compile the project with
swift build
on Linux -
Set up your database
cd Database && ./setup.sh
- Run the server:
.build/debug/Deploy
Then access http://localhost:8090/ in your browser to see an empty database.
The TodoList for Cloudant is deployable with a graphical user interface. Download:
You can use this button to deploy ToDo your Bluemix account, all from the browser. The button will create the application, create and bind any services specified in the manifest.yml file and deploy.
-
Download and install the CloudFoundry CLI here.
-
Install the IBM Containers plugin for CF:
Directions are here 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>
- Build a Docker image
docker build -t todolist-couchdb .
- Tag the Docker image:
docker tag todolist-couchdb registry.ng.bluemix.net/<your namespace>/todolist-couchdb
- Push the Docker image:
docker push registry.ng.bluemix.net/<your namespace>/todolist-couchdb
- Create Cloudant service:
cf create-service cloudantNoSQLDB Lite TodoListCloudantDatabase
-
Create a new local directory with an
empty.txt
file, then navigate into that directory. -
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
- Bind service to bridge app:
cf bind-service containerbridge TodoListCloudantDatabase
- 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
Bluemix is a hosting platform from IBM that makes it easy to deploy your app to the cloud. Bluemix also provides various popular databases. Cloudant is an offering that is compatible with the CouchDB database, but provides additional features. You can use Cloudant with your deployed TodoList-CouchDB application.
-
Get an account for Bluemix
-
Download and install the Cloud Foundry tools:
cf api https://api.ng.bluemix.net cf login
Be sure to run this in the directory where the manifest.yml file is located.
-
Create your Cloudant Service
cf create-service cloudantNoSQLDB Lite TodoListCloudantDatabase
-
Run
cf push
*Note This step will take 3-5 minutes
1 of 1 instances running App started
-
Get the credential information:
cf env TodoListCloudantApp
Note you will see something similar to the following, note the hostname, username, and password:
"VCAP_SERVICES": {
"cloudantNoSQLDB": [ { "credentials": { "host": "465ed079-35a8-4731-9425-911843621d7c-bluemix.cloudant.com", "password": "", "port": 443, "url": "https://465ed079-35a8-4731-9425-911843621d7c-bluemix:efe561fc02805bcb1e2b013dea4c928942951d31cd74cb2e01df3814751d9f45@465ed079-35a8-4731-9425-911843621d7c-bluemix.cloudant.com", "username": "" }, ```
-
Setup your database
Run
cf env
or use the Bluemix dashboard to discover the hostname, username, and password. Run the setup script, passing in these variables through command line argumentscd Database ./setup.sh BLUEMIX_DATABASE_HOST USERNAME PASSWORD
For example,
./setup.sh https://1e2e6460-4090-4e6d-8d37-70f308ae2155-bluemix.cloudant.com:443 \ 1e2e6460-4090-4e6d-8d37-70f308ae2155-bluemix \ somepassword
This Swift application includes code to track deployments to IBM Bluemix and other Cloud Foundry platforms. The following information is sent to a Deployment Tracker service on each deployment:
- Swift project code version (if provided)
- Swift project repository URL
- Application Name (
application_name
) - Space ID (
space_id
) - Application Version (
application_version
) - Application URIs (
application_uris
) - Labels of bound services
- Number of instances for each bound service and associated plan information
This data is collected from the parameters of the CloudFoundryDeploymentTracker
, the VCAP_APPLICATION
and VCAP_SERVICES
environment variables in IBM Bluemix and other Cloud Foundry platforms. This data is used by IBM to track metrics around deployments of sample applications to IBM Bluemix to measure the usefulness of our examples, so that we can continuously improve the content we offer to you. Only deployments of sample applications that include code to ping the Deployment Tracker service will be tracked.
Deployment tracking can be disabled by removing the following line from main.swift
:
CloudFoundryDeploymentTracker(repositoryURL: "https://github.com/IBM-Swift/TodoList-CouchDB.git").track()
Copyright 2016 IBM
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.