Skip to content

Commit

Permalink
Optimize the order for npm / chmod
Browse files Browse the repository at this point in the history
The chmod was taking a very long time for the AWS SDK with
hundreds if not thousands of files being downloaded.

Signed-off-by: Alex Ellis (OpenFaaS Ltd) <alexellis2@gmail.com>
  • Loading branch information
alexellis committed Feb 13, 2021
1 parent 820dc72 commit a7cda77
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions template/node12/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ COPY package.json ./

# This ordering means the npm installation is cached for the outer function handler.
RUN npm i
# chmod for tmp is for a buildkit issue (@alexellis)
RUN chown app:app -R /home/app \
&& chmod 777 /tmp

USER app

# Copy outer function handler
COPY index.js ./
Expand All @@ -31,7 +36,6 @@ COPY index.js ./
# entry allows caching of npm install

WORKDIR /home/app/function

COPY function/*.json ./

RUN npm i || :
Expand All @@ -45,12 +49,6 @@ RUN npm test
# Set correct permissions to use non root user
WORKDIR /home/app/

# chmod for tmp is for a buildkit issue (@alexellis)
RUN chown app:app -R /home/app \
&& chmod 777 /tmp

USER app

ENV cgi_headers="true"
ENV fprocess="node index.js"
ENV mode="http"
Expand Down

0 comments on commit a7cda77

Please sign in to comment.