Skip to content

Commit 8c30c7f

Browse files
committed
Add build folder to .gitignore and address issue comments
Reorder tutorial so that Gradle instructions come first Signed-off-by: Igor Braga <higorb1@gmail.com>
1 parent c4ad232 commit 8c30c7f

File tree

2 files changed

+111
-104
lines changed

2 files changed

+111
-104
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ default.props
66
.ant-targets-build.xml
77
/results/
88
/logs/
9+
/build/
910
/config/custom-config.xml
1011
results
1112
*.retry

README.md

Lines changed: 110 additions & 104 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,109 @@ This README documents the build, customisation and testing of these runtime imag
3636

3737
## Build Runtimes
3838

39-
### You have 2 options to build the NodeJS runtime:
40-
- Building locally
41-
- Using OpenWhisk Actions.
42-
### This README walks you through how to do both
39+
You have 2 options to build the NodeJS runtime:
40+
- [Using Gradle](#using_gradle)
41+
- [Using Docker](#using_docker)
4342

44-
# Building NodeJS Runtime Locally
43+
This README walks you through how to do both
44+
45+
---
46+
47+
## Using Gradle <a name="using_gradle"></a>
48+
49+
### Pre-requisites
50+
- [Gradle](https://gradle.org/)
51+
- [Docker](https://www.docker.com/)
52+
- [OpenWhisk CLI wsk](https://github.com/apache/openwhisk-cli/releases)
53+
54+
If the deployment of Apache OpenWhisk includes these images in the runtime manifest, use the `--kind` parameter to select the Node.js runtime version.
55+
56+
### Node.js v10
57+
58+
```
59+
wsk action update myAction myAction.js --kind nodejs:10
60+
```
61+
62+
### Node.js v12
63+
64+
```
65+
wsk action update myAction myAction.js --kind nodejs:12
66+
```
67+
68+
### Node.js v14
69+
70+
```
71+
wsk action update myAction myAction.js --kind nodejs:14
72+
```
73+
74+
## Images
75+
76+
All the runtime images are published by the project to Docker Hub @ [https://hub.docker.com/u/openwhisk](https://hub.docker.com/u/openwhisk)
77+
78+
- [https://hub.docker.com/r/openwhisk/action-nodejs-v10](https://hub.docker.com/r/openwhisk/action-nodejs-v10)
79+
- [https://hub.docker.com/r/openwhisk/action-nodejs-v12](https://hub.docker.com/r/openwhisk/action-nodejs-v12)
80+
- [https://hub.docker.com/r/openwhisk/action-nodejs-v14](https://hub.docker.com/r/openwhisk/action-nodejs-v14)
81+
82+
These images can be used to execute Node.js actions on any deployment of Apache OpenWhisk, even those without those images defined the in runtime manifest, using the `--docker` action parameter.
83+
84+
```
85+
wsk action update myAction myAction.js --docker openwhisk/action-nodejs-v12
86+
```
87+
88+
If you build a custom version of the images, pushing those an external Docker Hub repository will allow you to use those on the Apache OpenWhisk deployment.
89+
90+
### Runtimes Manifest
91+
92+
Available runtimes in Apache OpenWhisk are defined using the runtimes manifest in this file: [runtimes.json](https://github.com/apache/openwhisk/blob/master/ansible/files/runtimes.json#L16-L72)
93+
94+
Modify the manifest and re-deploy the platform to pick up local images changes.
95+
96+
## Development
97+
98+
Dockerfiles for runtime images are defined in the `core` directory. Each runtime version folder has a custom `Dockerfile` and `package.json`. If you need to add extra dependencies to a runtime version - modify these files.
99+
100+
The `core/nodejsActionBase` folder contains the Node.js app server used to implement the [action interface](https://github.com/apache/openwhisk/blob/master/docs/actions-new.md#action-interface), used by the platform to inject action code into the runtime and fire invocation requests. This common code is used in all runtime versions.
101+
102+
### Build <a name="build_gradle"></a>
103+
104+
- Run the `distDocker` command to generate local Docker images for the different runtime versions. (Make sure docker daemon is running)
105+
106+
```
107+
./gradlew core:nodejs10Action:distDocker
108+
./gradlew core:nodejs12Action:distDocker
109+
./gradlew core:nodejs14Action:distDocker
110+
```
111+
112+
This will return the following runtime images with the following names: `action-nodejs-v10`, `action-nodejs-v12` and `action-nodejs-v14`.
113+
114+
### Testing
115+
116+
- Install project dependencies from the top-level Apache OpenWhisk [project](https://github.com/apache/openwhisk), which ensures correct versions of dependent libraries are available in the Maven cache.
117+
118+
```
119+
./gradlew install
120+
```
121+
122+
*This command **MUST BE** run from the directory containing the main Apache OpenWhisk [repository](https://github.com/apache/openwhisk), not this repository's directory.*
123+
124+
- Build the local Docker images for the runtime versions (see the instructions above).
125+
- Build the custom Docker images used in local testing.
126+
127+
```
128+
./gradlew tests:dat:docker:nodejs10docker:distDocker
129+
./gradlew tests:dat:docker:nodejs12docker:distDocker
130+
./gradlew tests:dat:docker:nodejs14docker:distDocker
131+
```
132+
133+
- Run the project tests.
134+
135+
```
136+
./gradlew :tests:test
137+
```
138+
139+
---
140+
141+
## Using Docker <a name="using_docker"></a>
45142

46143
### Pre-requisites
47144
- [Docker](https://www.docker.com/)
@@ -67,22 +164,24 @@ FROM node:14.16.0-stretch
67164

68165
Or in the command line you can simply type:
69166
```
70-
cp core/nodejs14Action/Dockerfile core/nodejsActionBase/
167+
mkdir build
168+
cp -r core/nodejsActionBase/* build
169+
cp core/nodejs14Action/Dockerfile build
71170
```
72171

73-
If you follow the instructions at end of this tutorial [here](#build_dradle) that uses Gradle, you'll notice that Gradle takes care of this copying for us internally. Here since we just want to use docker and not worry about anything else we copy manually.
172+
If you follow the instructions at beginning of this tutorial [here](#build_gradle) that uses Gradle, you'll notice that Gradle takes care of this copying for us internally. Here since we just want to use docker and not worry about anything else we make create our own little build folder.
74173

75174
**NOTE**: If you think that you messed up some file you can restore all files to its original state by typing the following. Then you can repeat the above command (careful with this command as it will remove all modifications you made to any file locally):
76175
```
77-
git reset --hard origin/master
176+
rm -rf build/*
78177
```
79178

80179
2. Build docker
81180
```
82-
docker build -t nodejs-action-v14:1.0-SNAPSHOT $(pwd)/core/nodejsActionBase
181+
docker build -t nodejs-action-v14:1.0-SNAPSHOT $(pwd)/build
83182
```
84183

85-
2.1. Check docker `IMAGE ID` (1st column) for repository `nodejs-action-v14` (assuming you built with the first option above)
184+
2.1. Check docker `IMAGE ID` (1st column) for repository `nodejs-action-v14`
86185
```
87186
docker images
88187
```
@@ -100,7 +199,7 @@ Or run the container in the background (Add `-d` (detached) to the command above
100199
```
101200
docker run -d -p 127.0.0.1:80:8080/tcp --name=bloom_whisker --rm -it nodejs-action-v14:1.0-SNAPSHOT
102201
```
103-
202+
**NOTE**: The instructions above that [uses gradle](#using_gradle) will also create a docker image. You can also use that image to start your NodeJS container locally and issue the below commands against localhost and things should still work <br/><br/>
104203
Lists all running containers
105204
```
106205
docker ps
@@ -332,96 +431,3 @@ XXX_THE_END_OF_A_WHISK_ACTIVATION_XXX
332431
```
333432

334433
#### At this point you can edit js-fib-run.json an try other `fib_n` values. All you have to do is save `js-fib-run.json` and trigger the function again. Notice that here we're just modifying the parameters of our function; therefore, there's no need to re-run/re-initialize our container that contains our NodeJS runtime.
335-
336-
337-
# Building NodeJS Runtime using OpenWhisk Actions
338-
339-
### Pre-requisites
340-
- [Gradle](https://gradle.org/)
341-
- [Docker](https://www.docker.com/)
342-
- [OpenWhisk CLI wsk](https://github.com/apache/openwhisk-cli/releases)
343-
344-
If the deployment of Apache OpenWhisk includes these images in the runtime manifest, use the `--kind` parameter to select the Node.js runtime version.
345-
346-
### Node.js v10
347-
348-
```
349-
wsk action update myAction myAction.js --kind nodejs:10
350-
```
351-
352-
### Node.js v12
353-
354-
```
355-
wsk action update myAction myAction.js --kind nodejs:12
356-
```
357-
358-
### Node.js v14
359-
360-
```
361-
wsk action update myAction myAction.js --kind nodejs:14
362-
```
363-
364-
## Images
365-
366-
All the runtime images are published by the project to Docker Hub @ [https://hub.docker.com/u/openwhisk](https://hub.docker.com/u/openwhisk)
367-
368-
- [https://hub.docker.com/r/openwhisk/action-nodejs-v10](https://hub.docker.com/r/openwhisk/action-nodejs-v10)
369-
- [https://hub.docker.com/r/openwhisk/action-nodejs-v12](https://hub.docker.com/r/openwhisk/action-nodejs-v12)
370-
- [https://hub.docker.com/r/openwhisk/action-nodejs-v14](https://hub.docker.com/r/openwhisk/action-nodejs-v14)
371-
372-
These images can be used to execute Node.js actions on any deployment of Apache OpenWhisk, even those without those images defined the in runtime manifest, using the `--docker` action parameter.
373-
374-
```
375-
wsk action update myAction myAction.js --docker openwhisk/action-nodejs-v12
376-
```
377-
378-
If you build a custom version of the images, pushing those an external Docker Hub repository will allow you to use those on the Apache OpenWhisk deployment.
379-
380-
### Runtimes Manifest
381-
382-
Available runtimes in Apache OpenWhisk are defined using the runtimes manifest in this file: [runtimes.json](https://github.com/apache/openwhisk/blob/master/ansible/files/runtimes.json#L16-L72)
383-
384-
Modify the manifest and re-deploy the platform to pick up local images changes.
385-
386-
## Development
387-
388-
Dockerfiles for runtime images are defined in the `core` directory. Each runtime version folder has a custom `Dockerfile` and `package.json`. If you need to add extra dependencies to a runtime version - modify these files.
389-
390-
The `core/nodejsActionBase` folder contains the Node.js app server used to implement the [action interface](https://github.com/apache/openwhisk/blob/master/docs/actions-new.md#action-interface), used by the platform to inject action code into the runtime and fire invocation requests. This common code is used in all runtime versions.
391-
392-
### Build <a name="build_dradle"></a>
393-
394-
- Run the `distDocker` command to generate local Docker images for the different runtime versions. (Make sure docker daemon is running)
395-
396-
```
397-
./gradlew core:nodejs10Action:distDocker
398-
./gradlew core:nodejs12Action:distDocker
399-
./gradlew core:nodejs14Action:distDocker
400-
```
401-
402-
This will return the following runtime images with the following names: `action-nodejs-v10`, `action-nodejs-v12` and `action-nodejs-v14`.
403-
404-
### Testing
405-
406-
- Install project dependencies from the top-level Apache OpenWhisk [project](https://github.com/apache/openwhisk), which ensures correct versions of dependent libraries are available in the Maven cache.
407-
408-
```
409-
./gradlew install
410-
```
411-
412-
*This command **MUST BE** run from the directory containing the main Apache OpenWhisk [repository](https://github.com/apache/openwhisk), not this repository's directory.*
413-
414-
- Build the local Docker images for the runtime versions (see the instructions above).
415-
- Build the custom Docker images used in local testing.
416-
417-
```
418-
./gradlew tests:dat:docker:nodejs10docker:distDocker
419-
./gradlew tests:dat:docker:nodejs12docker:distDocker
420-
./gradlew tests:dat:docker:nodejs14docker:distDocker
421-
```
422-
423-
- Run the project tests.
424-
425-
```
426-
./gradlew :tests:test
427-
```

0 commit comments

Comments
 (0)