-
-
Notifications
You must be signed in to change notification settings - Fork 112
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
Enhance local dev env #900
Conversation
New and removed dependencies detected. Learn more about Socket for GitHub ↗︎
🚮 Removed packages: npm/puppeteer@20.8.2 |
none of that changed you wanker |
What about not mocking and hardcoding a S3 bucket that we will regularly delete and limit the amount the bucket can store if that's possible?1 That would require no code change at all (just an environment setting) and is thus closer to production. The downside would be opening us for bots that scrape for public buckets and then do whatever with them (hence the storage limitation and regular deletion) and that devs would overwrite the images of each other since their local db has no knowledge which id comes next in the bucket (could be fixed with unique, random prefixes).
I still remember my first encounter with them which was here and it blew my mind.2 Maybe if we have something like this it will also blow the minds of contributors? The SquadMC one uses Netlify but for NextJS, we could use Vercel if we want to use some managed solution instead of AWS or VPS. I'd prefer trying to go VPS first (could run on AWS) since this should be as straightforward as what I did here. Footnotes |
I thought of that too but it sounds like more work. We could also add another container that mocks s3: https://github.com/adobe/S3Mock
Agreed. The real hard part is going to be some kind of db multitenancy ... unless we can do something with docker. |
If you have anymore |
Co-authored-by: ekzyis <ek@stacker.news>
Co-authored-by: ekzyis <ek@stacker.news>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this at the stage where it is mergeable. It doesn't do everything we might want it to do but it's already 100x better than what we had before. This is almost at the point where I'd use it over my bespoke local setup.
I can confirm this works as expected on mac. It'd be nice to also confirm it works on linux at least.
Should be pretty straightforward to qa:
./sndev startThen visit localhost:3000 and give it whirl.
Me after running the command:
Works great! Immediately ran install -m=755 sndev ~/.local/bin
so I can simply type sndev
. I might use this over my current setup.
One suggestion (I can do this in another PR): We could add LNbits container for sndev login $nym
.
Not sure if you already know but one approach for logging in as any nym is to use pubkey auth and then move the pubkey to the user you want to impersonate as I did in #905 (probably works very similar with any auth method).
Nostr login with nostr extension worked out of the box.
Also tested funding and withdrawing but noticed that the help message is lacking arguments for these commands. Here is a patch:
patch
diff --git a/sndev b/sndev
index c76fbe36..3d1506cd 100755
--- a/sndev
+++ b/sndev
@@ -123,26 +123,26 @@ USAGE
$ sndev [COMMAND]
COMMANDS
- help show help
+ help show help
env:
- start start env
- stop stop env
- restart restart env
- status status of env
- delete delete env
+ start start env
+ stop stop env
+ restart restart env
+ status status of env
+ delete delete env
lnd:
- fund pay a bolt11 for funding
- withdraw create a bolt11 for withdrawal
+ fund <bolt11> pay a bolt11 for funding
+ withdraw <sats> create a bolt11 for withdrawal
db:
- psql open psql on db
+ psql open psql on db
raw:
- compose docker compose passthrough
- sn_lncli lncli passthrough on sn_lnd
- stacker_lncli lncli passthrough on stacker_lnd
+ compose docker compose passthrough
+ sn_lncli lncli passthrough on sn_lnd
+ stacker_lncli lncli passthrough on stacker_lnd
"
echo "$help"
fi
Tested sn_lncli
and stacker_lncli
by simply running it and expecting the LND help which showed up.
Nice work, this is where bash shines ☀️
# containers can't use localhost, so we need to use the container name | ||
IMGPROXY_URL_DOCKER=http://imgproxy:8080 | ||
MEDIA_URL_DOCKER=http://s3:4566/uploads | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I spent the better part of 10 hours trying to avoid this 😮💨 and all the related changes.
Things that didn't work:
- any kind of normal docker compose configuration that uses the default network
- running a reverse proxy container
- I almost got it working with
imgproxy.localhost
ands3.localhost
and docker composelinks
but after I got that all figured out, I learned macos doesn't support localhost subdomains
- I almost got it working with
- intercepting fetches in the service worker transforming domains, e.g.
imgproxy:3001
->localhost:3001
... I'm not sure what else I could have tried. We more or less need the host, app, worker, s3, and imgproxy to all share some kind of name resolution service. This is easy enough to configure in containers, but we can't reliably alter (nor should we) the host's dns.
I think this is good to merge after I take a breathe and do another once over. I'll add the remaining todos as issues. |
closes #799 #391
I think this at the stage where it is mergeable. It doesn't do everything we might want it to do but it's already 100x better than what we had before. This is almost at the point where I'd use it over my bespoke local setup.
I can confirm this works as expected on mac. It'd be nice to also confirm it works on linux at least.
Should be pretty straightforward to qa:
Then visit localhost:3000 and give it whirl.
./sndev help
To see other stuff you can do.
Just getting started on this, but so far:
sndev
posix shell script for managing all the kinds of things one might want to do in our local dev with commands:sndev start|stop|delete|help
.env.sndev
for docker env which is created from.env.sample
whensndev start
is runTODO:
sndev
sndev login $nym
sndev makeinvoice $all_the_lnd_params
sndev payinvoice $all_the_lnd_params
Am I missing anything? After this I'll try and see if I can get this all working in github codespaces.