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

[WIP] Add localstack and cf-mock for local development #4349

Open
wants to merge 11 commits into
base: main
Choose a base branch
from

Conversation

drewbo
Copy link
Contributor

@drewbo drewbo commented Dec 22, 2023

High-level PR intent

I'd like this PR to close #4326 by allowing all (or most) of the application functionality to be run locally in some capacity. There are some functions that are likely too difficult to replicate locally noted below.

Notes on Github

If AWS and CloudFoundry are mocked, the only "real" service that this will connect to locally is Github. I see two potential options on how to handle the Github connection:

  • Continue connecting to the "real" Github, knowing that certain functionality (e.g. build webhooks) cannot be replicated on a local application and will fail.
  • Develop a mock Github API to catch all requests. There does seem to be some prior art on this (like the wonderfully named Moctokit) but I didn't find anything immediately that would satisfy our need for a standalone server

Functionality Replication List (WIP)

  • Add site*
  • Site build*
  • Remove site*
  • Read archived build logs
  • List published files/branches
  • Provision/delete domain
  • Read build task artifacts (includes presigned S3 URL)
  • Invite user

*Require Github

Known Issues to write more about or solve

  • To work with localstack, our S3Client needs to be initialized with forcePathStyle: true. This is currently conditionally set via NODE_ENV but will break development because both the local application and the development environment use NODE_ENV=development. More info: https://docs.localstack.cloud/user-guide/integrations/sdks/javascript/
  • Localstack doesn't support persistence of data without a paid account. That's mostly okay because we can use the SDK to initialize our application with the necessary data. To do this, the localstack-setup service reads data from the local database to create the necessary buckets, development objects, etc. This generally works well with one exception: to create archived build logs, it actually deletes the corresponding items from the database, so on a new docker compose up, those items won't appear again without re-running docker compose run --rm app yarn create-dev-data
  • There is a potential (though not currently occurring) race condition in that the localstack-setup service requires both localstack and db for the wait-for-it.sh can only easily wait for one port to be available.
  • Localstack needs the Zscaler cert to be added in the local directory to work. Add documentation
  • Needs /etc/hosts change to resolve localstack host in browser. Add documentation

Changes proposed in this pull request:

security considerations

None, all services are running locally and don't expose external ports

cf-mock/routers/oauth.js Dismissed Show dismissed Hide dismissed
@drewbo drewbo requested a review from a team January 3, 2024 17:21
@drewbo
Copy link
Contributor Author

drewbo commented Jan 3, 2024

Marking this as ready for WIP review to test it out and comment on the known issues

@drewbo
Copy link
Contributor Author

drewbo commented Feb 28, 2024

Noting the latest plans:

  • Currently functionality list is fine, ticket out user invites/domain work separately
  • Future consideration as to separating out cf-mock into another repo and/or using it to replace current test mocks
  • Rewrite dev data creation to create all of AWS/CF/DB resources simultaneously rather than linking them in a fragile fashion

(captured in linked epic below)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Run AWS and CF API locally
1 participant