Skip to content

dprosper/ce-starter-app

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Starter application for IBM Cloud Code Engine

This application is an example used to test deploying to IBM Cloud Code Engine using the following two GitHub Actions:

Set up the IBM Cloud CLI

Create, Update and Delete to IBM Cloud Code Engine

Before you begin

In order to follow the steps under getting started, you will need the following:

  • A GitHub username
  • An IBM Cloud account with Pay-As-You-Go plan.

Getting started

In the image above, the header on the page is titled "Hello World", we will modify it to read something else and submit a pull request inside your fork of this repository.

  1. In the top-right corner of the page, click Fork.

  2. In your fork, go to Settings > Secrets > Actions and create a new repository secret: API_KEY: IBM Cloud API Key with the necessary permissions to create / delete Code Engine projects.

  3. Click on the <>Code tab, and then on main, create a new branch called header-title.

  4. Navigate to the webui/src folder and using the built-in editor on GitHub, edit the Header.tsx file.

  5. Modify line 9, from Hello World!! to My Code Engine Application.

  • From:

  • To:

  1. Commit your changes.

  2. Click on the Actions tab and click on I understand my workflows, go ahead and enable them.

  3. Create a pull request comparing main to header-title branches in your forked repository. Note, by default the compare is done against the source repository, so make sure to select your forked repository on both sides of the compare.

  4. After submitting the pull request, the application will be built from source and deployed to Code Engine.

  5. Use the URL provided to validate the application changes. Once you are satisfied, merge and close the pull request.

  6. Once the pull request is closed, the application will be deleted from Code Engine.

Manually deploy to Code Engine

  1. Target your desired region.
  ibmcloud target -r us-east -g default
  1. Create the Code Engine project.
  ibmcloud code-engine project create --name ce-starter-app
  1. Create a configmap for the list of data centers (json file).
  ibmcloud code-engine configmap create \
  --name random.json \
  --from-file ./data/random.json 
  1. Create the application from an existing container image, expose port 3001 and map the configmap to a volume.
  ibmcloud code-engine app create -n ce-starter-app \
  --image <registry_host>/<registry_namespace>/ce-starter-app \
  --port 3001 \
  --mount-configmap /data=random.json
  1. Optional - Update configmap
  ibmcloud code-engine configmap update \
  --name random.json \
  --from-file ./data/random.json 
  1. Optional - Update the application from an existing container image, expose port 3001 and map the configmap to a volume.
  ibmcloud code-engine app update -n ce-starter-app \
  --image <registry_host>/<registry_namespace>/ce-starter-app \
  --port 3001 \
  --mount-configmap /data=random.json

Build and run locally

Build image

  docker build -t <registry_namespace>/ce-starter-app -f ./api/Dockerfile .

Run local

  docker run --rm -v $(pwd)/data:/data -p 3001:3001 <registry_namespace>/ce-starter-app