Make default node-env use alpine. List envs in documentation. (#354)
closes #319 * Make default node-env use alpine, and support separate debian env. List envs in documentation. * Copy ONBUILD base image commands into node Dockerfiles * Copy more commands from onbuild image * Tidy dockerfiles
This commit is contained in:
@@ -24,7 +24,7 @@ Language-neutral components:
|
||||
|
||||
Language-specific components:
|
||||
|
||||
* Environment container
|
||||
* Environment container(s)
|
||||
|
||||
|
||||
Controller
|
||||
@@ -112,13 +112,13 @@ Environment Container
|
||||
---------------------
|
||||
|
||||
Environment containers run user-defined functions. Environment
|
||||
containers are language specific. They must contain an HTTP server
|
||||
and a loader for functions.
|
||||
containers are language specific. Each environment container must
|
||||
contain an HTTP server and a loader for functions.
|
||||
|
||||
Poolmgr deploys the environment container into a pod with fetcher
|
||||
(fetcher is a simple utility that can fetch an HTTP url to a file at a
|
||||
configured location). This pod forms a "generic pod", because it can
|
||||
be loaded with any function.
|
||||
be loaded with any function in that language.
|
||||
|
||||
When poolmgr needs to create a service for a function, it calls
|
||||
fetcher to fetch the function. Fetcher downloads the function into a
|
||||
@@ -134,7 +134,7 @@ Following is a diagram describe how log service works:
|
||||
|
||||

|
||||
|
||||
1. Pool manager choose a pod from pool to execute user function
|
||||
1. Pool manager chooses a pod from the pool to execute user function
|
||||
2. Pool manager makes a HTTP POST to logger helper, once helper receives
|
||||
the request it creates a symlink to container log for fluentd.
|
||||
3. Fluentd reads log from symlink and pipes to influxdb
|
||||
|
||||
@@ -45,8 +45,24 @@ A _function_ is a piece of code that follows the fission function
|
||||
interface.
|
||||
|
||||
An _environment_ contains the language- and runtime-specific parts of
|
||||
running a function. Fission comes with NodeJS and Python
|
||||
environments; you can also extend environments or create entirely new
|
||||
running a function.
|
||||
|
||||
The following environments are currently available:
|
||||
|
||||
| Environment | Image |
|
||||
| ------------------------------------ | ------------------------- |
|
||||
| Binary (for executables or scripts) | `fission/binary-env` |
|
||||
| Go | `fission/go-env` |
|
||||
| .NET | `fission/dotnet-env` |
|
||||
| .NET 2.0 | `fission/dotnet20-env` |
|
||||
| NodeJS (Alpine) | `fission/node-env` |
|
||||
| NodeJS (Debian) | `fission/node-env-debian` |
|
||||
| Perl | `fission/perl-env` |
|
||||
| PHP 7 | `fission/php-env` |
|
||||
| Python 3 | `fission/python-env` |
|
||||
| Ruby | `fission/ruby-env` |
|
||||
|
||||
You can also extend environments or create entirely new
|
||||
ones if you want. (An environment is essentially just a container
|
||||
with a webserver and dynamic loader.)
|
||||
|
||||
|
||||
@@ -1,7 +1,18 @@
|
||||
# A docker image for the func container.
|
||||
|
||||
FROM node:8-onbuild
|
||||
# default variant is the official alpine node image (much smaller than the standard image)
|
||||
FROM node:8-alpine
|
||||
|
||||
ADD server.js /usr/src/app/server.js
|
||||
ARG NODE_ENV
|
||||
ENV NODE_ENV $NODE_ENV
|
||||
|
||||
EXPOSE 8888
|
||||
RUN mkdir -p /usr/src/app
|
||||
WORKDIR /usr/src/app
|
||||
|
||||
COPY package.json /usr/src/app/
|
||||
RUN npm install && npm cache clean --force
|
||||
COPY server.js /usr/src/app/server.js
|
||||
|
||||
CMD [ "npm", "start" ]
|
||||
|
||||
EXPOSE 8888
|
||||
@@ -0,0 +1,18 @@
|
||||
# A docker image for the func container.
|
||||
|
||||
# debian variant is the official standard node image (larger than the alpine image)
|
||||
FROM node:8
|
||||
|
||||
ARG NODE_ENV
|
||||
ENV NODE_ENV $NODE_ENV
|
||||
|
||||
RUN mkdir -p /usr/src/app
|
||||
WORKDIR /usr/src/app
|
||||
|
||||
COPY package.json /usr/src/app/
|
||||
RUN npm install && npm cache clean --force
|
||||
COPY server.js /usr/src/app/server.js
|
||||
|
||||
CMD [ "npm", "start" ]
|
||||
|
||||
EXPOSE 8888
|
||||
@@ -2,12 +2,19 @@
|
||||
|
||||
This directory contains several examples to get you started using Node.js with Fission.
|
||||
|
||||
## Environment
|
||||
|
||||
Before running any of these functions, make sure you have created a `nodejs` Fission environment:
|
||||
|
||||
```
|
||||
$ fission env create --name nodejs --image fission/node-env
|
||||
```
|
||||
|
||||
Note: The default `fission/node-env` image is based on Alpine, which is much smaller than the main Debian Node image (65MB vs 680MB) while still being suitable for most use cases.
|
||||
If you need to use the full Debian image use the `fission/node-env-debian` image instead.
|
||||
See the [official Node docker hub repo](https://hub.docker.com/_/node/) for considerations
|
||||
relating to this choice.
|
||||
|
||||
## Function signature
|
||||
|
||||
Every Node.js function has the same basic form:
|
||||
|
||||
+28
-14
@@ -96,17 +96,29 @@ push_fetcher_image() {
|
||||
build_and_push_env_image() {
|
||||
version=$1
|
||||
envdir=$2
|
||||
imgname=$3
|
||||
imgnamebase=$3
|
||||
imgvariant=$4
|
||||
|
||||
echo "Building $envdir -> $imgname:$version"
|
||||
if [ -z "$imgvariant" ]
|
||||
then
|
||||
# no variant specified, just use the base name
|
||||
imgname=$imgnamebase
|
||||
dockerfile="Dockerfile"
|
||||
else
|
||||
# variant specified - append variant to image name and assume dockerfile
|
||||
# exists with same suffix (e.g. image node-env-debian built from Dockerfile-debian)
|
||||
imgname="$imgname-$imgvariant"
|
||||
dockerfile="Dockerfile-$imgvariant"
|
||||
fi
|
||||
echo "Building $envdir -> $imgname:$version using $dockerfile"
|
||||
|
||||
pushd $DIR/environments/$envdir
|
||||
if [ -f build.sh ]
|
||||
then
|
||||
./build.sh
|
||||
fi
|
||||
docker build -t fission/$imgname:$version .
|
||||
docker tag fission/$imgname:$version fission/$imgname:latest
|
||||
fi
|
||||
docker build -t fission/$imgname:$version -f $dockerfile .
|
||||
docker tag fission/$imgname:$version fission/$imgname:latest
|
||||
docker push fission/$imgname:$version
|
||||
docker push fission/$imgname:latest
|
||||
popd
|
||||
@@ -115,15 +127,17 @@ build_and_push_env_image() {
|
||||
build_and_push_all_envs() {
|
||||
version=$1
|
||||
|
||||
build_and_push_env_image $version nodejs node-env
|
||||
build_and_push_env_image $version binary binary-env
|
||||
build_and_push_env_image $version dotnet dotnet-env
|
||||
build_and_push_env_image $version dotnet20 dotnet20-env
|
||||
build_and_push_env_image $version go go-env
|
||||
build_and_push_env_image $version perl perl-env
|
||||
build_and_push_env_image $version php7 php-env
|
||||
build_and_push_env_image $version python3 python-env
|
||||
build_and_push_env_image $version ruby ruby-env
|
||||
# call with version, env dir, image name base, image name variant
|
||||
build_and_push_env_image "$version" "nodejs" "node-env" ""
|
||||
build_and_push_env_image "$version" "nodejs" "node-env" "debian"
|
||||
build_and_push_env_image "$version" "binary" "binary-env" ""
|
||||
build_and_push_env_image "$version" "dotnet" "dotnet-env" ""
|
||||
build_and_push_env_image "$version" "dotnet20" "dotnet20-env" ""
|
||||
build_and_push_env_image "$version" "go" "go-env" ""
|
||||
build_and_push_env_image "$version" "perl" "perl-env" ""
|
||||
build_and_push_env_image "$version" "php7" "php-env" ""
|
||||
build_and_push_env_image "$version" "python3" "python-env" ""
|
||||
build_and_push_env_image "$version" "ruby" "ruby-env" ""
|
||||
}
|
||||
|
||||
build_charts() {
|
||||
|
||||
Reference in New Issue
Block a user