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

build(webhook-retries): create SQS queue in dev mode (1) #1938

Merged
merged 3 commits into from
May 25, 2021
Merged
Show file tree
Hide file tree
Changes from 2 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
9 changes: 6 additions & 3 deletions Dockerfile.development
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,12 @@ RUN apk update && apk upgrade && \
ttf-freefont \
tini \
# Localstack - these are necessary in order to initialise local S3 buckets
# jq is a package for easily parsing Localstack health endpoint's JSON output
jq \
py-pip && \
npm install --quiet node-gyp -g && \
pip install awscli-local
# [ver1] ensures that the underlying AWS CLI version is also installed
pip install awscli-local[ver1]

# Chinese fonts
RUN echo @edge http://nl.alpinelinux.org/alpine/edge/testing >> /etc/apk/repositories && apk add wqy-zenhei@edge
Expand All @@ -41,5 +44,5 @@ EXPOSE 5000
# tini is the init process that will adopt orphaned zombie processes
# e.g. chromium when launched to create a new PDF
ENTRYPOINT [ "tini", "--" ]
# Create local S3 buckets before building the app
CMD npm run docker-dev
# Create local AWS resources before building the app
CMD sh init-localstack.sh && npm run docker-dev
karrui marked this conversation as resolved.
Show resolved Hide resolved
6 changes: 2 additions & 4 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ services:
- MYINFO_CERT_PATH=./node_modules/@opengovsg/mockpass/static/certs/spcp.crt
- MYINFO_CLIENT_ID=mockClientId
- MYINFO_CLIENT_SECRET=mockClientSecret
- WEBHOOK_SQS_URL=http://localhost:4566/000000000000/local-webhooks-sqs-queue
- GA_TRACKING_ID
- SENTRY_CONFIG_URL
- TWILIO_ACCOUNT_SID
Expand Down Expand Up @@ -105,11 +106,8 @@ services:
depends_on:
- formsg
environment:
- SERVICES=s3
- SERVICES=s3,sqs
- DATA_DIR=/tmp/localstack/data
- ATTACHMENT_S3_BUCKET=local-attachment-bucket
- IMAGE_S3_BUCKET=local-image-bucket
- LOGO_S3_BUCKET=local-logo-bucket
mantariksh marked this conversation as resolved.
Show resolved Hide resolved
volumes:
- './.localstack:/tmp/localstack'
- '/var/run/docker.sock:/var/run/docker.sock'
Expand Down
6 changes: 0 additions & 6 deletions docker-entrypoint-initaws.d/init-localstack.sh

This file was deleted.

18 changes: 18 additions & 0 deletions init-localstack.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/bash
# Wait for all Localstack services to be ready
while [[ "$(curl -s -f http://localhost:4566/health | jq '[.services[] == "running"] | all')" != "true" ]]; do
sleep 5
done
set -x
# Create S3 buckets
awslocal s3 mb s3://$IMAGE_S3_BUCKET
awslocal s3 mb s3://$LOGO_S3_BUCKET
awslocal s3 mb s3://$ATTACHMENT_S3_BUCKET

# Create SQS queue for webhooks
# Extract queue name, which is the part of the queue URL after the final "/"
awslocal sqs create-queue --queue-name ${WEBHOOK_SQS_URL##*/} --attributes '{
"ReceiveMessageWaitTimeSeconds": "20"
}'
mantariksh marked this conversation as resolved.
Show resolved Hide resolved

set +x