Skip to content

Commit

Permalink
Merge pull request #30 from sleepio/stream-437/add-aws-alerts-plugin
Browse files Browse the repository at this point in the history
STREAM-437 - Add serverless-plugin-aws-alerts as npm dependency
  • Loading branch information
taro-bh authored Apr 12, 2022
2 parents df8cc8f + f464b15 commit 9f80335
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 2 deletions.
40 changes: 38 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"main": "index.js",
"dependencies": {
"serverless-python-requirements": "4.1.1",
"serverless-plugin-aws-alerts": "1.7.4",
"serverless-plugin-scripts": "1.0.2",
"serverless-plugin-datadog": "2.4.0",
"serverless-plugin-log-subscription": "1.4.0",
Expand Down

0 comments on commit 9f80335

Please sign in to comment.