Coder Social home page Coder Social logo

todolist-db2's Introduction

TodoList DB2 backend

Build Status

Table of Contents

Summary

A Swift DB2 implementation of the TodoList backend

Installation:

  1. Install Swift 3

XCode 8 if on macOS or the toolchain if on Linux

  1. Install dependencies:

macOS: brew install wget unixodbc

Linux: sudo apt-get update sudo apt-get install -y clang unixodbc-dev unzip wget tar

  1. Install the DB2 system driver:

wget https://github.com/IBM-DTeam/swift-for-db2-cli/archive/master.zip && unzip master.zip && cd swift-for-db2-cli-master && sudo ./cli.sh && . env.sh && cd .. && rm -f master.zip && rm -rf swift-for-db2-cli-master

  1. Clone the repository:

git clone https://github.com/IBM-Swift/todolist-db2

  1. Compile the application

macOS: swift build -Xcc -I/usr/local/include -Xlinker -L/usr/local/lib

Linux: swift build -Xcc -I/usr/local/include -Xlinker -L/usr/local/lib

##Setup DB2 service

  1. Login to your Bluemix account (create an account, if necessary)

  2. Open the Bluemix catalog by clicking the blue hexagon '+' icon DB2 service

  3. Search for "DB2" and open the dashDB Database DB2 service

  4. Select your desired plan and click the Create button. DB2 service You will now have a provisioned dashDB Database in your services.

  5. Open the newly created service in Bluemix, then open the dashDB dashboard.

  6. Select "Tables" from the menu on the left, then click "Add Table" button. Enter the following DDL statement to create your TODOS table:

CREATE TABLE "todos"
(
"todoid" INT NOT NULL GENERATED ALWAYS AS IDENTITY (START WITH 1 INCREMENT BY 1),
"title"	VARCHAR(256) NOT NULL,
"ownerid" VARCHAR(128) NOT NULL,
"completed" INT NOT NULL,
"orderno" INT NOT NULL
);

DB2 service

Run the app locally

Change the default parameters in Sources/TodoList/TodoList.swift to the parameters of your DB2 instance - hostname, port, uid and password.

The parameters of your DB2 instance can be copied from your dashDB settings, "Service Credentials" tab.

dashDB Credentials

Using Docker

  1. Install Docker on your operating system

  2. Build the Docker image:

sudo docker build -t todolist-db2 .

  1. Run the web server:

sudo docker run -p 8090:8090 -d todolist-db2

##Deploy to Bluemix To deploy this app to Bluemix, you have to build and a deploy a Docker image with the app.

  1. Login to your Bluemix account (create an account, if necessary)

  2. Download and install the Cloud Foundry tools.

  3. Login to Bluemix CLI

cf login

bluemix api https://api.ng.bluemix.net

bluemix login -u username -o org_name -s space_name

  1. Download and install the [IBM Container's Plugin] (https://console.ng.bluemix.net/docs/containers/container_cli_cfic_install.html)

  2. Configure the IBM Container's Plugin - set your IBM Container Namespace.

  3. Login into cf ic

cf ic login

  1. Build the Docker image:

sudo docker build -t todolist-db2 .

  1. Tag the Docker image:

docker tag todolist-db2 registry.ng.bluemix.net/<NAMESPACE FROM STEP 5>/todolist-db2

  1. Push the Docker image:

docker push registry.ng.bluemix.net/<NAMESPACE FROM STEP 5>/todolist-db2

  1. Go to Bluemix and click on All Items

DB2 Service

  1. Click on the + sign to create a new Container

DB2 Service

  1. Select the Docker image that was pushed in Step 7

DB2 Service

  1. Configure the Container as follows. Make sure to switch from Single to Scalable Group and to set HTTP port to 8090 (the your app listens to)

DB2 Service

  1. Create the Container

  2. The URL of the app appears in the "Routes" field of the Container Overview Container Routes

  3. Now you can test and access your app by the URL from step 15. In particular, when accessing the app's URL, a list of currently existing todo items will be returned. Note that you must not to append the port to the URL, the default ports will be used. (The port 8090 that you specified in step 13 is used by Bluemix to access your app and is mapped to the default HTTP/HTTPS ports)

##Test

  1. Clone the Tests to your project:

git clone https://github.com/IBM-Swift/todolist-tests Tests

  1. Run the tests:

swift test -Xcc -I/usr/local/include -Xlinker -L/usr/local/lib

todolist-db2's People

Contributors

jsphyin avatar vadimeisenbergibm avatar rfdickerson avatar defiyeti avatar chiahuang avatar jesspittman avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.