Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reformat Deploy Options #11

Merged
merged 1 commit into from Sep 2, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
33 changes: 6 additions & 27 deletions README.md
Expand Up @@ -27,40 +27,19 @@ When the reader has completed this Code Pattern, they will understand how to:
* [Cloud](https://developer.ibm.com/depmodels/cloud/): Accessing computer and information technology resources through the Internet.
* [Node.js](https://nodejs.org/): An open-source JavaScript run-time environment for executing server-side JavaScript code.

# Steps
Use the ``Deploy to IBM Cloud`` button **OR** create run locally
## Deployment options

## Deploy to IBM Cloud
Click on one of the options below for instructions on deploying the app.

[![Deploy to IBM Cloud](https://cloud.ibm.com/devops/setup/deploy/button.png)](https://cloud.ibm.com/devops/setup/deploy?repository=https://github.com/IBM/cos-web-gallery)
| | |
| - | - |
| [![public](https://raw.githubusercontent.com/IBM/pattern-utils/master/deploy-buttons/cf.png)](doc/source/cf.md) | [![local](https://raw.githubusercontent.com/IBM/pattern-utils/master/deploy-buttons/local.png)](doc/source/local.md) |

Press the above ``Deploy to IBM Cloud`` button and then click on ``Deploy``.

## Run the app locally
> NOTE: These steps are only needed when running locally instead of using the ``Deploy to IBM Cloud`` button.

1. [Clone the repo](#1-clone-the-repo)
2. [Configure IBM Cloud Object Storage](#2-configure-ibm-cloud-object-storage)
3. [Run the application](#3-run-the-application)

### 1. Clone the repo

Clone the `cos-web-gallery` locally. In a terminal, run:

```
$ git clone https://github.com/IBM/cos-web-gallery
```

### 2. Configure IBM Cloud Object Storage

In the IBM Cloud Console for COS, select the instance you would like to use, and then **Service Credentials** from the menu on the left. Create a new credential, and then copy the contents of this credential to the clipboard using the **Copy to Clipboard** icon. Paste the contents into a file named `~/.bluemix/cos_credentials`.

### 3. Run the application
1. [Install Node.js][] runtime or NPM.
1. Start the app by running `npm install`, followed by `npm start`.
1. Access the running app in a browser at `localhost:3000`

# Sample output
## Sample output

Once run either locally or on IBM Cloud, you should see the following page when you hit the URL for your application:

Expand Down
43 changes: 43 additions & 0 deletions doc/source/cf.md
@@ -0,0 +1,43 @@
# Run on IBM Cloud with Cloud Foundry

This document shows how to run the `cos-web-gallery` application using Cloud Foundry on IBM Cloud.

## Steps

1. [Clone the repo](#1-clone-the-repo)
2. [Configure the application](#2-configure-the-application)
3. [Launch the application](#3-launch-the-application)
4. [Configure Object Storage](#4-configure-object-storage)

### 1. Clone the repo

Clone `cos-web-gallery` locally. In a terminal, run:

`$ git clone https://github.com/ibm/cos-web-gallery`

### 2. Configure the application

You will need to specify an unique name for the `host` in the `manifest.yml` file. You will also need to update `src/controllers/galleryController.js` with a unique name for your bucket (line 22) and an endpoint if you are using a region other then `us-south` (lines 20, 21).

### 3. Launch the application

Login to IBM Cloud and push the application

```bash
ibmcloud login
cd cos-web-gallery
cf push
```

### 4. Configure Object Storage

In the IBM Cloud Console for COS, select the instance you would like to use, and then **Service Credentials** from the menu on the left. Create a new credential, making sure to check the **Include HMAC Credential** box. View your new credential and take note of two values in the `cos_hmac_keys` section: `access_key_id` and `secret_access_key`. Back in your application, navigate to the **Environment variables** page, and create two user defined variables named `AWS_ACCESS_KEY_ID` and `AWS_SECRET_ACCESS_KEY`. Use the values from your COS credential.

![variables](/doc/source/images/env-variables.jpg)

<!---
[![Deploy to IBM Cloud](https://cloud.ibm.com/devops/setup/deploy/button.png)](https://cloud.ibm.com/devops/setup/deploy?repository=https://github.com/IBM/cos-web-gallery)

Click the ``Deploy to IBM Cloud`` button and hit ``Create`` on the next prompt. This will automatically create the services and application for you.
--->
[![return](https://raw.githubusercontent.com/IBM/pattern-utils/master/deploy-buttons/return.png)](https://github.com/IBM/cos-web-gallery#deployment-options)
Binary file added doc/source/images/env-variables.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
27 changes: 27 additions & 0 deletions doc/source/local.md
@@ -0,0 +1,27 @@
# Run locally

This document show how to run the 'cos-web-gallery' application on your local machine.

## Steps

1. [Clone the repo](#1-clone-the-repo)
2. [Configure IBM Cloud Object Storage](#2-configure-ibm-cloud-object-storage)
3. [Run the application](#3-run-the-application)

### 1. Clone the repo

Clone the `cos-web-gallery` locally. In a terminal, run:

```
$ git clone https://github.com/IBM/cos-web-gallery
```

### 2. Configure IBM Cloud Object Storage

In the IBM Cloud Console for COS, select the instance you would like to use, and then **Service Credentials** from the menu on the left. Create a new credential, and then copy the contents of this credential to the clipboard using the **Copy to Clipboard** icon. Paste the contents into a file named `~/.bluemix/cos_credentials`.

### 3. Run the application
1. [Install Node.js](https://nodejs.org/en/download/) runtime or NPM.
1. Start the app by running `npm install`, followed by `npm start`.
1. Access the running app in a browser at `localhost:3000`

4 changes: 2 additions & 2 deletions src/controllers/galleryController.js
Expand Up @@ -17,8 +17,8 @@ var galleryController = function(title) {
var aws = require('ibm-cos-sdk');
var multer = require('multer');
var multerS3 = require('multer-s3');
var ep = new aws.Endpoint('https://s3-api.us-geo.objectstorage.softlayer.net');
var s3 = new aws.S3({endpoint: ep, region: 'us-east-1'});
var ep = new aws.Endpoint('https://s3.us-south.cloud-object-storage.appdomain.cloud');
var s3 = new aws.S3({endpoint: ep, region: 'us-south'});
var myBucket = 'web-images-olaph';

var upload = multer({
Expand Down