forked from ipanousis/docker-serverless
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #30 from sleepio/stream-437/add-aws-alerts-plugin
STREAM-437 - Add serverless-plugin-aws-alerts as npm dependency
- Loading branch information
Showing
2 changed files
with
39 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,8 @@ MAINTAINER Yannis Panousis <[email protected]> | |
# https://github.com/serverless/serverless/pull/7694 changed back -> collision | ||
ARG SERVERLESS_VERSION=1.70.0 | ||
|
||
ARG NPM_MAX_RETRY=5 | ||
|
||
RUN apk update | ||
RUN apk upgrade | ||
RUN apk add ca-certificates && update-ca-certificates | ||
|
@@ -33,11 +35,45 @@ RUN rm /var/cache/apk/* | |
WORKDIR /var/task | ||
|
||
RUN npm install -g try-thread-sleep | ||
RUN npm install -g serverless@${SERVERLESS_VERSION} --ignore-scripts spawn-sync | ||
|
||
# NOTE (TS, April 11, 2022): Added retries to circumvent the socket timeout | ||
# issue on concurrent npm package downloads discussed in | ||
# https://github.com/npm/cli/issues/3078. The ticket is marked closed as of | ||
# writing of this comment, but the actual issue remains unresolved. Check back | ||
# on that ticket thread to see the status, and remove the retry after the | ||
# resolution. Also, see https://github.com/sleepio/docker-serverless/pull/30 for | ||
# more context. | ||
RUN for retry in `seq 1 ${NPM_MAX_RETRY}` ; do \ | ||
if npm install -g serverless@${SERVERLESS_VERSION} --registry=https://registry.npmjs.org --prefer-offline=true --fetch-retries=5 --fetch-timeout=600000 --ignore-scripts spawn-sync ; \ | ||
then echo "Install serverless@${SERVERLESS_VERSION} successful" ; break ; \ | ||
else \ | ||
echo "Install serverless@${SERVERLESS_VERSION} retry ${retry}/${NPM_MAX_RETRY}..." ; \ | ||
if [ "$retry" -eq "$NPM_MAX_RETRY" ]; then \ | ||
echo "= BEG serverless@${SERVERLESS_VERSION} install error log ====" ; \ | ||
cat /root/.npm/_logs/*-debug.log ; \ | ||
echo "= END serverless@${SERVERLESS_VERSION} install error log ====" ; \ | ||
exit 1 ; \ | ||
fi ; \ | ||
fi ; \ | ||
done | ||
|
||
COPY . /var | ||
|
||
RUN cd /var && npm install | ||
# See the note by TS on `npm install` above. | ||
RUN cd /var && \ | ||
for retry in `seq 1 ${NPM_MAX_RETRY}` ; do \ | ||
if npm install --registry=https://registry.npmjs.org --prefer-offline=true --fetch-retries=5 --fetch-timeout=600000 ; \ | ||
then echo "Install npm packages for ${SERVERLESS_VERSION} successful" ; break ; \ | ||
else \ | ||
echo "Install npm packages for ${SERVERLESS_VERSION} retry ${retry}/${NPM_MAX_RETRY}..." ; \ | ||
if [ "$retry" -eq "$NPM_MAX_RETRY" ]; then \ | ||
echo "= BEG npm packages for ${SERVERLESS_VERSION} install error log ====" ; \ | ||
cat /root/.npm/_logs/*-debug.log ; \ | ||
echo "= END npm packages for ${SERVERLESS_VERSION} install error log ====" ; \ | ||
exit 1 ; \ | ||
fi ; \ | ||
fi ; \ | ||
done | ||
|
||
ENV NODE_PATH=/var | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters