From 28a0115253b3427c253613ae1c1e7af0c06f4146 Mon Sep 17 00:00:00 2001 From: Russell Jew Date: Fri, 15 Jun 2018 14:10:20 -0700 Subject: [PATCH] Image build fails when runtime deps fail to download. --- README.md | 2 +- function-template/Dockerfile | 6 +++--- image-template/Dockerfile | 6 +++--- version.txt | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index ccb8d05..53a1491 100644 --- a/README.md +++ b/README.md @@ -59,7 +59,7 @@ module.exports = function (context, payload) { ``` ```bash -$ dispatch create function nodejs-mylibs math-js ./demo.js +$ dispatch create function math-js ./demo.js --image=nodejs-mylibs --handler=demo.js ``` Make sure the function status is `READY` (it normally goes from `INITIALIZED` to `READY`): diff --git a/function-template/Dockerfile b/function-template/Dockerfile index 55b29a1..c50021b 100644 --- a/function-template/Dockerfile +++ b/function-template/Dockerfile @@ -10,9 +10,9 @@ COPY . . # Create handler file if passed in otherwise assume default handler RUN echo -n ${HANDLER} > /tmp/handler -RUN [ -z "${HANDLER}" ] && \ - [ $(ls *.js | wc -l) -eq "1" ] && \ - ls *.js > /tmp/handler || : +RUN if [ -z "${HANDLER}" ]; then \ + ([ $(ls *.js | wc -l) -eq "1" ] || (echo "Exactly 1 source file needed when HANDLER is empty" >&2 && exit 1)) && \ + ls *.js > /tmp/handler; fi # Validate function file and given handler RUN node /validator/validator.js ${WORKDIR}/$(cat /tmp/handler) || (echo "Invalid function file or handler" >&2 && exit 1) \ No newline at end of file diff --git a/image-template/Dockerfile b/image-template/Dockerfile index b37bd9f..edf8ace 100644 --- a/image-template/Dockerfile +++ b/image-template/Dockerfile @@ -8,12 +8,12 @@ ARG SYSTEM_PACKAGES_FILE=system-packages.txt COPY ${SYSTEM_PACKAGES_FILE} . RUN packages=$(cat ${SYSTEM_PACKAGES_FILE} | sed 's/ /-/' | uniq | paste -d' ' -); \ - [ -n "${packages}" ] && tdnf install -y ${packages} || : + if [ -n "${packages}" ]; then tdnf install -y ${packages}; fi -WORKDIR ${WORKDIR}/.. +WORKDIR / ARG PACKAGES_FILE=packages.txt COPY ${PACKAGES_FILE} package.json -RUN pj=$(cat package.json); [ -n "${pj}" ] && npm install || : +RUN pj=$(cat package.json); if [ -n "${pj}" ]; then npm install; fi diff --git a/version.txt b/version.txt index 429d94a..b0a1227 100644 --- a/version.txt +++ b/version.txt @@ -1 +1 @@ -0.0.9 \ No newline at end of file +0.0.10 \ No newline at end of file