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

fix(dev): fix hot reloading and Localstack port #324

Merged
merged 4 commits into from
Sep 16, 2020
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
2 changes: 1 addition & 1 deletion Dockerfile.development
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,4 @@ EXPOSE 5000
# e.g. chromium when launched to create a new PDF
ENTRYPOINT [ "tini", "--" ]
# Create local S3 buckets before building the app
CMD sh init-localstack.sh && npm run docker-dev
CMD npm run docker-dev
12 changes: 9 additions & 3 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ services:
- /opt/formsg/node_modules
ports:
- '5000:5000'
- '4572:4572' # localstack ports
- '4566:4566' # localstack ports
- '5156:5156' # mockpass ports
- '9229:9229' # Node debugger port
environment:
Expand All @@ -29,6 +29,7 @@ services:
- AWS_ACCESS_KEY_ID=fakeKey
- AWS_SECRET_ACCESS_KEY=fakeSecret
- SESSION_SECRET=thisisasecret
- AWS_ENDPOINT=http://localhost:4566
- GA_TRACKING_ID
- SENTRY_CONFIG_URL
- TWILIO_ACCOUNT_SID
Expand Down Expand Up @@ -64,7 +65,6 @@ services:
- IS_SP_MAINTENANCE
- IS_CP_MAINTENANCE
- AGGREGATE_COLLECTION
- AWS_ENDPOINT=http://localhost:4572

mockpass:
build: https://github.com/opengovsg/mockpass.git
Expand Down Expand Up @@ -99,10 +99,16 @@ services:
environment:
- SERVICES=s3
- DATA_DIR=/tmp/localstack/data
- ATTACHMENT_S3_BUCKET=local-attachment-bucket
- IMAGE_S3_BUCKET=local-image-bucket
- LOGO_S3_BUCKET=local-logo-bucket
volumes:
- './.localstack:/tmp/localstack'
- '/var/run/docker.sock:/var/run/docker.sock'
network_mode: 'service:formsg' # reuse formsg service's network stack so that it can resolve localhost:4572 to localstack:4572
# This is where we add scripts to initialise AWS resources.
# Docs: https://github.com/localstack/localstack#initializing-a-fresh-instance
- './docker-entrypoint-initaws.d:/docker-entrypoint-initaws.d'
mantariksh marked this conversation as resolved.
Show resolved Hide resolved
network_mode: 'service:formsg' # reuse formsg service's network stack so that it can resolve localhost:4566 to localstack:4566

volumes:
mongodata:
6 changes: 6 additions & 0 deletions docker-entrypoint-initaws.d/init-localstack.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash
set -x
awslocal s3 mb s3://$IMAGE_S3_BUCKET
awslocal s3 mb s3://$LOGO_S3_BUCKET
awslocal s3 mb s3://$ATTACHMENT_S3_BUCKET
set +x
10 changes: 0 additions & 10 deletions init-localstack.sh

This file was deleted.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"build-frontend-dev:watch": "webpack --config webpack.dev.js --watch",
"start": "node dist/backend/server.js",
"dev": "docker-compose up --build",
"docker-dev": "npm run build-frontend-dev:watch & ts-node-dev --respawn --transpileOnly --inspect=0.0.0.0 -- src/server.ts",
"docker-dev": "npm run build-frontend-dev:watch & ts-node-dev --respawn --transpileOnly --inspect=0.0.0.0 --exit-child -- src/server.ts",
"test-backend": "npm run test-backend-jasmine && npm run test-backend-jest",
"test-backend-jest": "env-cmd -f tests/.test-full-env jest --coverage --maxWorkers=2",
"test-backend-jest:watch": "env-cmd -f tests/.test-full-env jest --watch",
Expand Down
2 changes: 1 addition & 1 deletion tests/.test-basic-env
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ AWS_ACCESS_KEY_ID=fakeAccessKeyId
AWS_SECRET_ACCESS_KEY=fakeSecretAccessKey
SESSION_SECRET=sandcrawler-138577

AWS_ENDPOINT=http://localhost:4572
AWS_ENDPOINT=http://localhost:4566
2 changes: 1 addition & 1 deletion tests/.test-full-env
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,4 @@ MOCK_WEBHOOK_PORT=4000
AWS_ACCESS_KEY_ID=fakeAccessKeyId
AWS_SECRET_ACCESS_KEY=fakeSecretAccessKey

AWS_ENDPOINT=http://localhost:4572
AWS_ENDPOINT=http://localhost:4566