Sync docs from master to gh-pages
This commit is contained in:
116
openwhisk.html
116
openwhisk.html
@@ -96,7 +96,7 @@ $(addBlockSwitches);
|
||||
<div id="preamble">
|
||||
<div class="sectionbody">
|
||||
<div class="paragraph">
|
||||
<p><strong>2.1.0.BUILD-SNAPSHOT</strong></p>
|
||||
<p><strong>2.1.1.BUILD-SNAPSHOT</strong></p>
|
||||
</div>
|
||||
<div id="index-link" class="paragraph">
|
||||
<p><a href="https://cloud.spring.io/spring-cloud-function/home.html" class="bare">https://cloud.spring.io/spring-cloud-function/home.html</a></p>
|
||||
@@ -110,7 +110,119 @@ $(addBlockSwitches);
|
||||
<h2 id="_quick_start"><a class="link" href="#_quick_start">Quick Start</a></h2>
|
||||
<div class="sectionbody">
|
||||
<div class="paragraph">
|
||||
<p>Unresolved directive in openwhisk.adoc - include::openwhisk-quick-start.adoc[]</p>
|
||||
<p>Implement a POF (be sure to use the <code>functions</code> package):</p>
|
||||
</div>
|
||||
<div class="listingblock">
|
||||
<div class="content">
|
||||
<pre class="highlightjs highlight"><code>package functions;
|
||||
|
||||
import java.util.function.Function;
|
||||
|
||||
public class Uppercase implements Function<String, String> {
|
||||
|
||||
public String apply(String input) {
|
||||
return input.toUpperCase();
|
||||
}
|
||||
}</code></pre>
|
||||
</div>
|
||||
</div>
|
||||
<div class="paragraph">
|
||||
<p>Install it into your local Maven repository:</p>
|
||||
</div>
|
||||
<div class="listingblock">
|
||||
<div class="content">
|
||||
<pre class="highlightjs highlight"><code>./mvnw clean install</code></pre>
|
||||
</div>
|
||||
</div>
|
||||
<div class="paragraph">
|
||||
<p>Create a <code>function.properties</code> file that provides its Maven coordinates. For example:</p>
|
||||
</div>
|
||||
<div class="listingblock">
|
||||
<div class="content">
|
||||
<pre class="highlightjs highlight"><code>dependencies.function: com.example:pof:0.0.1-SNAPSHOT</code></pre>
|
||||
</div>
|
||||
</div>
|
||||
<div class="paragraph">
|
||||
<p>Copy the openwhisk runner JAR to the working directory (same directory as the properties file):</p>
|
||||
</div>
|
||||
<div class="listingblock">
|
||||
<div class="content">
|
||||
<pre class="highlightjs highlight"><code>cp spring-cloud-function-adapters/spring-cloud-function-adapter-openwhisk/target/spring-cloud-function-adapter-openwhisk-2.0.0.BUILD-SNAPSHOT.jar runner.jar</code></pre>
|
||||
</div>
|
||||
</div>
|
||||
<div class="paragraph">
|
||||
<p>Generate a m2 repo from the <code>--thin.dryrun</code> of the runner JAR with the above properties file:</p>
|
||||
</div>
|
||||
<div class="listingblock">
|
||||
<div class="content">
|
||||
<pre class="highlightjs highlight"><code>java -jar -Dthin.root=m2 runner.jar --thin.name=function --thin.dryrun</code></pre>
|
||||
</div>
|
||||
</div>
|
||||
<div class="paragraph">
|
||||
<p>Use the following Dockerfile:</p>
|
||||
</div>
|
||||
<div class="listingblock">
|
||||
<div class="content">
|
||||
<pre class="highlightjs highlight"><code>FROM openjdk:8-jdk-alpine
|
||||
VOLUME /tmp
|
||||
COPY m2 /m2
|
||||
ADD runner.jar .
|
||||
ADD function.properties .
|
||||
ENV JAVA_OPTS=""
|
||||
ENTRYPOINT [ "java", "-Djava.security.egd=file:/dev/./urandom", "-jar", "runner.jar", "--thin.root=/m2", "--thin.name=function", "--function.name=uppercase"]
|
||||
EXPOSE 8080</code></pre>
|
||||
</div>
|
||||
</div>
|
||||
<div class="quoteblock">
|
||||
<blockquote>
|
||||
<div class="admonitionblock note">
|
||||
<table>
|
||||
<tr>
|
||||
<td class="icon">
|
||||
<i class="fa icon-note" title="Note"></i>
|
||||
</td>
|
||||
<td class="content">
|
||||
you could use a Spring Cloud Function app, instead of just a jar with a POF in it, in which case you would have to change the way the app runs in the container so that it picks up the main class as a source file. For example, you could change the <code>ENTRYPOINT</code> above and add <code>--spring.main.sources=com.example.SampleApplication</code>.
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</blockquote>
|
||||
</div>
|
||||
<div class="paragraph">
|
||||
<p>Build the Docker image:</p>
|
||||
</div>
|
||||
<div class="listingblock">
|
||||
<div class="content">
|
||||
<pre class="highlightjs highlight"><code>docker build -t [username/appname] .</code></pre>
|
||||
</div>
|
||||
</div>
|
||||
<div class="paragraph">
|
||||
<p>Push the Docker image:</p>
|
||||
</div>
|
||||
<div class="listingblock">
|
||||
<div class="content">
|
||||
<pre class="highlightjs highlight"><code>docker push [username/appname]</code></pre>
|
||||
</div>
|
||||
</div>
|
||||
<div class="paragraph">
|
||||
<p>Use the OpenWhisk CLI (e.g. after <code>vagrant ssh</code>) to create the action:</p>
|
||||
</div>
|
||||
<div class="listingblock">
|
||||
<div class="content">
|
||||
<pre class="highlightjs highlight"><code>wsk action create example --docker [username/appname]</code></pre>
|
||||
</div>
|
||||
</div>
|
||||
<div class="paragraph">
|
||||
<p>Invoke the action:</p>
|
||||
</div>
|
||||
<div class="listingblock">
|
||||
<div class="content">
|
||||
<pre class="highlightjs highlight"><code>wsk action invoke example --result --param payload foo
|
||||
{
|
||||
"result": "FOO"
|
||||
}</code></pre>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user