Git Product home page Git Product logo

apache / openwhisk-runtime-docker Goto Github PK

View Code? Open in Web Editor NEW
24.0 29.0 43.0 3.1 MB

Apache OpenWhisk SDK for building Docker "blackbox" runtimes

Home Page: https://openwhisk.apache.org/

License: Apache License 2.0

Python 53.78% Shell 7.82% C 2.50% Scala 27.46% Dockerfile 8.43%
openwhisk apache serverless faas functions-as-a-service cloud serverless-architectures serverless-functions docker functions

openwhisk-runtime-docker's Introduction

Apache OpenWhisk runtimes for docker

License Continuous Integration

Give it a try today

Create a zip action with a exec in the root of the zip

echo \
'#!/bin/bash
echo "{\"message\":\"Hello World\"}"' > exec

For the return result, not only support dictionary but also support array

echo \
'#!/bin/bash
echo '["a", "b"]'' > exec

And support array result for sequence action as well, the first action's array result can be used as next action's input parameter

echo \
'#!/bin/bash
echo $1' > exec
chmod +x exec
zip myAction.zip exec

Create the action using the docker image for the runtime

wsk action update myAction myAction.zip --docker openwhisk/dockerskeleton:1.3.2

This works on any deployment of Apache OpenWhisk

To use on a deployment that contains the runtime deployed

Create action using --native

wsk action update myAction myAction.zip --native

Local development

./gradlew :core:actionProxy:distDocker :sdk:docker:distDocker

This will produce the image whisk/dockerskeleton

Build and Push image

docker login
./gradlew core:actionProxy:distDocker -PdockerImagePrefix=$prefix-user -PdockerRegistry=docker.io

Deploy OpenWhisk using ansible environment that contains the runtime of type blackboxes with name dockerskeleton Assuming you have OpenWhisk already deploy locally and OPENWHISK_HOME pointing to root directory of OpenWhisk core repository.

Set ROOTDIR to the root directory of this repository.

Redeploy OpenWhisk

cd $OPENWHISK_HOME/ansible
ANSIBLE_CMD="ansible-playbook -i ${ROOTDIR}/ansible/environments/local"
$ANSIBLE_CMD setup.yml
$ANSIBLE_CMD couchdb.yml
$ANSIBLE_CMD initdb.yml
$ANSIBLE_CMD wipe.yml
$ANSIBLE_CMD openwhisk.yml

Or you can use wskdev and create a soft link to the target ansible environment, for example:

ln -s ${ROOTDIR}/ansible/environments/local ${OPENWHISK_HOME}/ansible/environments/local-docker
wskdev fresh -t local-docker

To use as docker action push to your own dockerhub account

docker tag whisk/dockerskeleton $user_prefix/dockerskeleton
docker push $user_prefix/dockerskeleton

Then create the action using your image from dockerhub

wsk action update myAction myAction.zip --docker $user_prefix/dockerskeleton

The $user_prefix is usually your dockerhub user id.

openwhisk-runtime-docker's People

Contributors

cbickel avatar chetanmeh avatar csantanapr avatar dgrove-oss avatar dubee avatar eweiter avatar falkzoll avatar fxulusoy avatar ioana-blue avatar jasonpet avatar jeremiaswerner avatar joachimvaldez avatar luke-roy-ibm avatar markusthoemmes avatar mdeuser avatar mrutkows avatar ningyougang avatar nwspeete-ibm avatar paulcastro avatar perryibm avatar pritidesai avatar psuter avatar pwplusnick avatar rabbah avatar rsulzmann avatar sjfink avatar starpit avatar style95 avatar tysonnorris avatar vvraskin avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

openwhisk-runtime-docker's Issues

Add perl to dockerskeleton

adding perl allows for perl actions.
wsk action create action action.pl --native
or
CLI can be updated to handle .pl extensions

wsk action create action action.pl

add mode to disable re-init of an action

The Java proxy does not permit an action to be re-initialized [1]. This isn't true for the docker proxy or Python/Swift runtimes. All the runtimes should behave consistently. The basic action container tests suite will be extended to include a test for re-init, where the first init is expected to succeed but the second should fail. The action proxy will reject the request with status code 403 FORBIDDEN (although any non-20x is acceptable for rejection).

[1] https://github.com/apache/incubator-openwhisk-runtime-java/blob/3657b3889fd1ce03581184fcb07766a8c897a4d8/java8/proxy/src/main/java/openwhisk/java/action/Proxy.java#L72-L75

Making the fix at this level will address python and swift proxies as well.

Some source files miss Apache license headers

Following Apache license header guideline, all human-readable Apache-developed files that are included within a distribution must include the header text with few exceptions. You can find few exceptions here: which files do not require a license header.

I used Apache Rat to check this repository after excluding a few files, and I got this report. We need to add Apache licensing header to those files.

Unapproved licenses:

  openwhisk-runtime-docker/core/actionProxy/Dockerfile
  openwhisk-runtime-docker/tests/dat/blackbox/badaction/Dockerfile
  openwhisk-runtime-docker/tests/dat/blackbox/badaction/README.md
  openwhisk-runtime-docker/tests/dat/blackbox/badproxy/Dockerfile
  openwhisk-runtime-docker/tests/dat/blackbox/badproxy/README.md
  openwhisk-runtime-docker/tests/src/test/resources/application.conf
  openwhisk-runtime-docker/ansible/environments/local/group_vars/all
  openwhisk-runtime-docker/ansible/environments/local/hosts
  openwhisk-runtime-docker/sdk/docker/Dockerfile
  openwhisk-runtime-docker/sdk/docker/example.c

The excluded files are:

**/*.json
**/**.gradle
**/gradlew
**/gradle/**
**/.**
**/templates/**
**/*.j2.*
**/.github/**
**/auth.whisk.system
**/auth.guest
**/i18n_resources.go

Problems with relative directory when using zip actions

TLDR; have the python proxy set current directory to /action/

The current directory is set to default meaning currently is /actionProxy/
When using a zip action the contents of the action is extracted to /action/
If the zip file has more files and the exec binary needs to reads the file the location would be /action/file.txt for example.
I think is better to have the current directory set to /action/ this way the exec can assume the relative directory to exec or zip is the current directory hiding any implementation details of /action and also making testing the action locally easier before build the zip and deploying.

This is already handle in python zip action correctly via os.chdir

Problems with latest version of gevent in python proxy

Tried to use latest version of gevent 1.3.6
It looks like starting with version 1.3 we can't longer import the way is currently from gevent.wsgi import WSGIServer we need to use from gevent.pywsgi import WSGIServer

I propose we update the python code to hande the latest gevent version, and at the same time also update flask to latest.

/action/exec is not executable

Hi,

Following along http://jamesthom.as/blog/2017/01/16/openwhisk-docker-actions/ (section Running Locally), I've been able to quickly iterate on a custom action/runtime, but for a specific issue: /action/exec ends up not being executable as a result of initCodeFromZip.

The local file is 0755, but once pushed within the container as part of a base64 zip, it's 0544 (or 0744 I don't remember ๐Ÿ™ˆ) and belongs to the root user. Therefore POST /init kept failing on this line, specifically the os.X_OK check (which was not obvious at first but the local dev setup turned out great to debug as well).

To work around the issue, I edited both initCode* functions to add os.chmod(self.source, 0755) right before their return statements (could be refactored to DRY things up):

     # initialize code from inlined string
     def initCodeFromString(self, message):
         with codecs.open(self.source, 'w', 'utf-8') as fp:
             fp.write(message['code'])
+            os.chmod(self.source, 0755)
         return True

     # initialize code from base64 encoded archive
     def initCodeFromZip(self, message):
         try:
             bytes = base64.b64decode(message['code'])
             bytes = io.BytesIO(bytes)
             archive = zipfile.ZipFile(bytes)
             archive.extractall(self.zipdest)
             archive.close()
+            os.chmod(self.source, 0755)
             return True
         except Exception as e:
             print('err', str(e))
             return False

I'd like to believe it's a safe move to make, but I'm not sure really. What do you maintainers think? If it sounds about right, I could create a quick-win PR for this of course.

Dev setup: fresh Debian Stretch install, Docker version 18.06.1-ce, using openwhisk/dockerskeleton:latest as build image. Dev source code available here (specifically the Dockerfile).

add git utility to docker actions

Would be useful to have git utility in dockerskeleton
Allows users to build devops actions where they can git clone and build/compile/package some code and deploy

Current master build failing in ansible command

Current master build is failing with following error

fatal: [controller0]: FAILED! => {"failed": true, "msg": "the field 'args' has an invalid value, which appears to include a variable that is undefined. The error was: {u'replicationFactor': u\"{{ kafka_replicationFactor | default((groups['kafkas']|length)|int) }}\", u'version': u'0.11.0.1', u'port': 9092, u'heap': u\"{{ kafka_heap | default('1g') }}\", u'ras': {u'port': 8093}}: 'dict object' has no attribute 'kafkas'\n\nThe error appears to have been in '/home/travis/build/apache/openwhisk/ansible/roles/controller/tasks/deploy.yml': line 77, column 3, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n\n- name: (re)start controller\n  ^ here\n"}

add zip to dockerskeleton

useful to have zip utility, allows to compress a payload, or use it for devops to deploy zip actions.

git clone not working when using ssh git url (add ssh client)

user reported that using a bash script in dockerskeleton they can't git clone a url using ssh scheme

git clone [email protected]:apache/incubator-openwhisk-runtime-docker.git

I'm guessing is because the image is missing the ssh client or some ssh client side config.

We should not enable/install ssh server/deamon/service, but look if it's possible to just add the minimum to make the git clone work over ssh.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.