diff --git a/README.md b/README.md index fb136ea1..728b998a 100644 --- a/README.md +++ b/README.md @@ -25,9 +25,9 @@ This project is part of the OpenFaaS project licensed under the MIT License. | go-armhf | Go | 1.10.4 | Alpine Linux 3.8 | Classic | [Go armhf template](https://github.com/openfaas/templates/tree/master/template/go-armhf) | go | Go | 1.10.4 | Alpine Linux 3.8 | Classic | [Go template](https://github.com/openfaas/templates/tree/master/template/go) |java8 | Java | 8 | OpenJDK Alpine Linux | of-watchdog | [Java template](https://github.com/openfaas/templates/tree/master/template/java8) -| node-arm64 | NodeJS | 8.9.1 | N/A | Classic | [NodeJS arm64 template](https://github.com/openfaas/templates/tree/master/template/node-arm64) -| node-armhf | NodeJS | N/A | Alpine Linux 3.6 | Classic | [NodeJS armhf template](https://github.com/openfaas/templates/tree/master/template/node-armhf) -| node | NodeJS | 8.9.1 | Alpine Linux | Classic | [NodeJS template](https://github.com/openfaas/templates/tree/master/template/node) +| node-arm64 | NodeJS | 10.15.0 | Alpine Linux | Classic | [NodeJS arm64 template](https://github.com/openfaas/templates/tree/master/template/node-arm64) +| node-armhf | NodeJS | 10.15.0 | Alpine Linux | Classic | [NodeJS armhf template](https://github.com/openfaas/templates/tree/master/template/node-armhf) +| node | NodeJS | 10.15.0 | Alpine Linux | Classic | [NodeJS template](https://github.com/openfaas/templates/tree/master/template/node) | php7 | PHP | 7.2 | Alpine Linux | Classic | [PHP 7 template](https://github.com/openfaas/templates/tree/master/template/php7) | python-armhf | Python | 2.7 | Alpine Linux | Classic | [Python 2.7 armhf template](https://github.com/openfaas/templates/tree/master/template/python-armhf) | python | Python | 2.7 | Alpine Linux | Classic | [Python 2.7 template](https://github.com/openfaas/templates/tree/master/template/python) diff --git a/template/node-arm64/Dockerfile b/template/node-arm64/Dockerfile index 025e0e98..fd02e628 100644 --- a/template/node-arm64/Dockerfile +++ b/template/node-arm64/Dockerfile @@ -1,41 +1,51 @@ -FROM arm64v8/node:8.9.1 +FROM node:10.15.0-alpine -RUN apt-get update -qy \ - && apt-get install -qy curl ca-certificates --no-install-recommends \ +RUN addgroup -S app && adduser app -S -G app +RUN apk --no-cache add ca-certificates curl \ && echo "Pulling watchdog binary from Github." \ && curl -sSL https://github.com/openfaas/faas/releases/download/0.9.14/fwatchdog-arm64 > /usr/bin/fwatchdog \ && chmod +x /usr/bin/fwatchdog \ - && apt-get -qy remove curl \ - && apt-get clean \ - && rm -rf /var/lib/apt/lists/* + && apk del curl --no-cache WORKDIR /root/ # Turn down the verbosity to default level. ENV NPM_CONFIG_LOGLEVEL warn +RUN mkdir -p /home/app + # Wrapper/boot-strapper -COPY package.json . -RUN npm i +WORKDIR /home/app +COPY package.json ./ -# Function -COPY index.js . -RUN mkdir -p ./root/function +# This ordering means the npm installation is cached for the outer function handler. +RUN npm i --production -COPY function/*.json ./function/ -WORKDIR /root/function -RUN npm i || : -WORKDIR /root/ -COPY function function -WORKDIR /root/function +# Copy outer function handler +COPY index.js ./ -WORKDIR /root/ +# COPY function node packages and install, adding this as a separate +# entry allows caching of npm install runtime dependencies +WORKDIR /home/app/function +COPY function/*.json ./ +RUN npm i --production || : -ENV cgi_headers="true" +# Copy in additional function files and folders +COPY --chown=app:app function/ . +WORKDIR /home/app/ + +# chmod for tmp is for a buildkit issue (@alexellis) +RUN chmod +rx -R ./function \ + && chown app:app -R /home/app \ + && chmod 777 /tmp + +USER app + +ENV cgi_headers="true" ENV fprocess="node index.js" EXPOSE 8080 HEALTHCHECK --interval=3s CMD [ -e /tmp/.lock ] || exit 1 -CMD ["fwatchdog"] +CMD ["fwatchdog"] \ No newline at end of file diff --git a/template/node-armhf/Dockerfile b/template/node-armhf/Dockerfile index d1d8872e..f391bd9d 100644 --- a/template/node-armhf/Dockerfile +++ b/template/node-armhf/Dockerfile @@ -1,7 +1,7 @@ -FROM arm32v6/alpine:3.6 +FROM node:10.15.0-alpine -RUN apk add --no-cache nodejs nodejs-npm ca-certificates -RUN apk --no-cache add curl \ +RUN addgroup -S app && adduser app -S -G app +RUN apk --no-cache add ca-certificates curl \ && echo "Pulling watchdog binary from Github." \ && curl -sSL https://github.com/openfaas/faas/releases/download/0.9.14/fwatchdog-armhf > /usr/bin/fwatchdog \ && chmod +x /usr/bin/fwatchdog \ @@ -9,22 +9,43 @@ RUN apk --no-cache add curl \ WORKDIR /root/ -COPY package.json . +# Turn down the verbosity to default level. +ENV NPM_CONFIG_LOGLEVEL warn -RUN npm i -COPY index.js . -COPY function function -WORKDIR /root/function +RUN mkdir -p /home/app -ENV NPM_CONFIG_LOGLEVEL warn -RUN npm i || : -WORKDIR /root/ +# Wrapper/boot-strapper +WORKDIR /home/app +COPY package.json ./ -ENV cgi_headers="true" +# This ordering means the npm installation is cached for the outer function handler. +RUN npm i --production + +# Copy outer function handler +COPY index.js ./ + +# COPY function node packages and install, adding this as a separate +# entry allows caching of npm install runtime dependencies +WORKDIR /home/app/function +COPY function/*.json ./ +RUN npm i --production || : +# Copy in additional function files and folders +COPY --chown=app:app function/ . + +WORKDIR /home/app/ + +# chmod for tmp is for a buildkit issue (@alexellis) +RUN chmod +rx -R ./function \ + && chown app:app -R /home/app \ + && chmod 777 /tmp + +USER app + +ENV cgi_headers="true" ENV fprocess="node index.js" EXPOSE 8080 HEALTHCHECK --interval=3s CMD [ -e /tmp/.lock ] || exit 1 -CMD ["fwatchdog"] +CMD ["fwatchdog"] \ No newline at end of file diff --git a/template/node/Dockerfile b/template/node/Dockerfile index 6f390831..498d61ba 100644 --- a/template/node/Dockerfile +++ b/template/node/Dockerfile @@ -1,4 +1,4 @@ -FROM node:8.9.1-alpine +FROM node:10.15.0-alpine RUN addgroup -S app && adduser app -S -G app RUN apk --no-cache add curl \ @@ -48,4 +48,4 @@ EXPOSE 8080 HEALTHCHECK --interval=3s CMD [ -e /tmp/.lock ] || exit 1 -CMD ["fwatchdog"] +CMD ["fwatchdog"] \ No newline at end of file