nostream icon indicating copy to clipboard operation
nostream copied to clipboard

Add reverse proxy for local dev

Open kevinsmith opened this issue 2 years ago • 1 comments
trafficstars

Includes locally-trusted TLS certs via mkcert and uses a hostname that already points to 127.0.0.1 without having to modify the hosts file.

Description

This change makes it easy to spin up a local environment for development, both for enhancements to the relay and for use while developing a nostr client. It uses Caddy as the reverse-proxy, mkcert to generate certs for the hostname that are trusted on the developer's machine, and a localtest.me subdomain for the hostname to avoid requiring a change to the machine's host file.

Related Issue

#117

Motivation and Context

Quickly overcomes the barrier to getting the relay working in a local environment. Anything that makes the relay easier to use will help boost adoption and contributions to the project.

How Has This Been Tested?

I was able to reliably spin up the relay from zero state, connect to wss://nostream.localtest.me with WebSocket King, and receive test events from astral.ninja configured to only use wss://nostream.localtest.me.

@Cameri I haven't updated docs or run tests yet because I'm considering this PR a draft. I wanted to check with you on expectations. Is the existing Docker Compose configuration meant for local or prod use? I made changes to it assuming that it was meant for local, but I can easily split these changes off to a dedicated local version if you'd like.

Types of changes

  • [ ] Non-functional change (docs, style, minor refactor)
  • [ ] Bug fix (non-breaking change which fixes an issue)
  • [x] New feature (non-breaking change which adds functionality)
  • [ ] Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • [x] My code follows the code style of this project.
  • [x] My change requires a change to the documentation.
  • [ ] I have updated the documentation accordingly.
  • [x] I have read the CONTRIBUTING document.
  • [ ] I have added tests to cover my code changes.
  • [ ] All new and existing tests passed.

kevinsmith avatar Dec 30 '22 15:12 kevinsmith

Thanks!

I think we should split the docker compose for local and prod. Current one was meant for prod.

Will review the code later today.

cameri avatar Dec 30 '22 15:12 cameri

Alright, made some adjustments so that local is a new, distinct environment that doesn't affect any existing code. All that should be required for local dev in Docker is to run ./scripts/start_local.

I'm not 100% in love with where this code all lives, mostly because there wasn't yet a distinct pattern to follow. I submitted #120 to address it.

kevinsmith avatar Dec 30 '22 19:12 kevinsmith

Alright, made some adjustments so that local is a new, distinct environment that doesn't affect any existing code. All that should be required for local dev in Docker is to run ./scripts/start_local.

I'm not 100% in love with where this code all lives, mostly because there wasn't yet a distinct pattern to follow. I submitted #120 to address it.

It's fine. It just needs to work first, then we can iterate and get it to where it needs to be.

cameri avatar Dec 30 '22 19:12 cameri

Could you please update the README.md to include the mkcert requirement for local development only?

cameri avatar Dec 30 '22 19:12 cameri

Yup, I'll push a docs update here in a bit.

kevinsmith avatar Dec 30 '22 19:12 kevinsmith

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
No Duplication information No Duplication information

sonarqubecloud[bot] avatar Dec 30 '22 19:12 sonarqubecloud[bot]

@Cameri Those readme changes look good to you?

kevinsmith avatar Dec 30 '22 21:12 kevinsmith

@Cameri Those readme changes look good to you?

Yup, tried them and worked well on my local machine

cameri avatar Dec 30 '22 21:12 cameri

:tada: This PR is included in version 1.16.0 :tada:

The release is available on GitHub release

Your semantic-release bot :package::rocket:

github-actions[bot] avatar Dec 30 '22 21:12 github-actions[bot]