How to Use ngrok
ngrok allows you to serve your dev environment on the public internet. This may sound like a Bad Idea, but it's useful to testing webhooks or demoing what you are working on.
To server your Brut app on ngrok:
Sign up for ngrok - you can do everything here witih the free plan.
Get your authtoken, which is available from the Dashboard.
Stop your dev environment and edit
Dockerfile.dxto install ngrok. Locate the section that sets up the local user. There is a large comment explaining this and the first directive will be something likeARG user_uid=xxxxx. Before this directive, add (this is based on ngrok's documentation:RUN curl -sSL https://ngrok-agent.s3.amazonaws.com/ngrok.asc | \ tee /etc/apt/trusted.gpg.d/ngrok.asc >/dev/null && \ echo "deb https://ngrok-agent.s3.amazonaws.com bookworm main" | \ tee /etc/apt/sources.list.d/ngrok.list && \ apt update && \ apt install --yes ngrokRebuild your dev environment with
dx/build.Start your dev environment and set up your app:
dx/start- [in another termianl]
dx/exec bin/setup
Make your authtoken available inside your docker container
dx/exec ngrok config add-authtoken <<YOUR_AUTHTOKEN>>
Add this line to
Procfile.development:ngrok: ngrok http 6502Allow ngrok's domain to be served. In
app/src/app.rb, find theinitializemethod ofAppand add this at the end:rubyBrut.container.override("local_hostname",".ngrok-free.dev")
Now, when you run dx/exec bin/dev your app is on the public internet. Go to the (confusingly titled) Agents page to see your app. You'll need to click into it to find the URL.
To always use that URL, modify Procfile.development:
ngrok: ngrok http 6502 --url <<whatever that url was>>>Brut doesn't provide more automation than this, but you can make this easier by modifying bin/setup as needed.