Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

STREAM-437 - Add serverless-plugin-aws-alerts as npm dependency #30

Merged
merged 4 commits into from
Apr 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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