Skip to content
This repository was archived by the owner on Nov 16, 2020. It is now read-only.

Commit 6c8f8da

Browse files
authored
Merge pull request #345 from rjew/update-blog-bingo
Updated blog and bingo examples to use image run-time dependencies
2 parents 1554dc4 + 51d49b3 commit 6c8f8da

File tree

6 files changed

+24
-72
lines changed

6 files changed

+24
-72
lines changed

examples/bingo/README.md

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -53,22 +53,18 @@ Let's just add `message.channels` by clicking `Add Workspace Event` button under
5353

5454
## Create Dispatch Objects
5555

56-
Here are all the source files we need: [bingo.js](bingo.js), [base-image/Dockerfile](base-image/Dockerfile).
56+
Here are all the source files we need: [bingo.js](bingo.js), [package.json](package.json).
5757
One more thing: you need a working Dispatch installation and `dispatch` CLI on your computer (all right, that's two things).
5858

5959

6060
### Image
6161

62-
Every Dispatch function needs an image. As of right now, it's the same as base-image. Base images are intended to be basic runtimes for functions - without any additional libraries. Images are to contain the libraries. But for now let's just create a base image with everything we need.
62+
Every Dispatch function needs an image. Base images are intended to be basic runtimes for functions - without any additional libraries. Images are to contain the libraries.
6363

6464
```bash
65-
## Build the image first
66-
docker build -t ${docker_user}/dispatch-nodejs6-bingo-deps:0.0.1-dev1 ./base-image
67-
docker push ${docker_user}/dispatch-nodejs6-bingo-deps:0.0.1-dev1
68-
6965
## Register the image in Dispatch
70-
dispatch create base-image bingo-deps-base ${docker_user}/dispatch-nodejs6-bingo-deps:0.0.1-dev1 --language=nodejs6
71-
dispatch create image bingo-deps bingo-deps-base
66+
dispatch create base-image bingo-base vmware/dispatch-nodejs6-base:0.0.1-dev1 --language=nodejs6
67+
dispatch create image bingo-deps bingo-base --runtime-deps package.json
7268
```
7369

7470
### Secret

examples/bingo/base-image/Dockerfile

Lines changed: 0 additions & 3 deletions
This file was deleted.

examples/bingo/package.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"dependencies": {
3+
"request": "2.83.0"
4+
}
5+
}

examples/blog/README.md

Lines changed: 10 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -49,56 +49,16 @@ $ echo $(kubectl get secret minio-minio-user -n minio -o json | jq -r .data.acce
4949
blogaccess
5050
```
5151

52-
## Build the image
53-
54-
This step is optional, as an alternative, a pre-built image may be used:
55-
```
56-
$ export BASE_IMAGE=berndtj/dispatch-nodejs6-blog-webapp:0.0.1-dev1
57-
```
58-
59-
To build the image yourself, continue.
60-
61-
If a docker registry is installed on your cluster (default), you may use that:
62-
63-
1. Point to the docker client running in minikube
64-
```
65-
$ eval $(minikube docker-env)
66-
```
67-
2. Get the Cluster IP of the registry service:
68-
```
69-
$ LOCAL_REG=$(kubectl -n dispatch get service docker-registry-docker-registry -o json | jq -r .spec.clusterIP):5000
70-
$ echo $LOCAL_REG
71-
10.97.167.150:5000
72-
```
73-
3. Build the image (assuming you've cloned the dispatch repository and your current working directory is dispatch project root):
74-
```
75-
export BASE_IMAGE=$LOCAL_REG/dispatch-nodejs6-blog-webapp:0.0.1-dev1
76-
docker build -t $BASE_IMAGE ./examples/blog/base-image
77-
docker push $BASE_IMAGE
78-
```
79-
80-
Alternatively, you may also use a hosted docker registry (docker hub):
81-
82-
1. Login to docker hub (account required):
83-
```
84-
$ docker login
85-
Login with your Docker ID to push and pull images from Docker Hub. If you don't have a Docker ID, head over to https://hub.docker.com to create one.
86-
Username (berndtj):
87-
Password:
88-
Login Succeeded
89-
```
90-
2. Build the image:
91-
```
92-
$ export BASE_IMAGE=<docker username>/dispatch-nodejs6-blog-webapp:0.0.1-dev1
93-
$ docker build -t $BASE_IMAGE ./examples/blog/base-image
94-
$ docker push $BASE_IMAGE
95-
```
96-
9752
## Register the image with Dispatch
9853

54+
If you haven't cloned the dispatch repository, now is the time:
55+
```
56+
$ git clone https://github.com/vmware/dispatch.git && cd dispatch
57+
```
58+
9959
```
100-
$ dispatch create base-image blog-webapp-base-image $BASE_IMAGE --language=nodejs6
101-
$ dispatch create image blog-webapp-image blog-webapp-base-image
60+
$ dispatch create base-image blog-webapp-base-image vmware/dispatch-nodejs6-base:0.0.1-dev1 --language=nodejs6
61+
$ dispatch create image blog-webapp-image blog-webapp-base-image --runtime-deps examples/blog/package.json
10262
```
10363

10464
Wait for both the base-image and image to be in the ``READY`` state:
@@ -153,11 +113,6 @@ Note: secret values are hidden, please use --all flag to get them
153113

154114
## Upload the post.js as a Dispatch function
155115

156-
If you haven't cloned the dispatch repository, now is the time:
157-
```
158-
$ git clone https://github.com/vmware/dispatch.git && cd dispatch
159-
```
160-
161116
Create a dispatch function and associate it with your just created dispatch secret.
162117

163118
```
@@ -270,7 +225,7 @@ $ echo $DISPATCH_API_URL
270225

271226
Add a new blog post
272227
```
273-
$ curl -s -k -X POST ${DISPATCH_API_URL}/post/add -d '{
228+
$ curl -s -k -X POST ${DISPATCH_API_URL}/post/add -H "Content-Type: application/json" -d '{
274229
"op": "add",
275230
"post":{
276231
"id": "1234",
@@ -326,7 +281,7 @@ $ curl -s -k -X GET ${DISPATCH_API_URL}/post/list?op=list | jq
326281

327282
Update a blog post
328283
```
329-
$ curl -s -k -X PATCH ${DISPATCH_API_URL}/post/update -d '{
284+
$ curl -s -k -X PATCH ${DISPATCH_API_URL}/post/update -H "Content-Type: application/json" -d '{
330285
"op": "update",
331286
"post":{
332287
"id": "1234",
@@ -347,7 +302,7 @@ $ curl -s -k -X PATCH ${DISPATCH_API_URL}/post/update -d '{
347302

348303
Delete a blog post
349304
```
350-
$ curl -s -k -X DELETE ${DISPATCH_API_URL}/post/delete -d '{
305+
$ curl -s -k -X DELETE ${DISPATCH_API_URL}/post/delete -H "Content-Type: application/json" -d '{
351306
"op": "delete",
352307
"post": { "id": "1234"}
353308
}' | jq

examples/blog/base-image/Dockerfile

Lines changed: 0 additions & 6 deletions
This file was deleted.

examples/blog/package.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"dependencies": {
3+
"minio": "3.2.3"
4+
}
5+
}

0 commit comments

Comments
 (0)