If you are using OrbStack (not affiliated) on your local macOS environment, and want to run Discourse on HTTPS with a custom domain, update your devcontainer.json
with following additions:
- Give a name to the container.
- Add
.orb.local
wildcard domain toRAILS_DEVELOPMENT_HOSTS
environment variable (hostnames must be separated by a comma).
--- a/.devcontainer/devcontainer.json
+++ b/.devcontainer/devcontainer.json
@@ -13,10 +13,11 @@
],
"remoteUser": "discourse",
"remoteEnv": {
- "RAILS_DEVELOPMENT_HOSTS": ".app.github.dev",
+ "RAILS_DEVELOPMENT_HOSTS": ".app.github.dev,.orb.local", // Step 2
"PGUSER": "discourse",
"SELENIUM_FORWARD_DEVTOOLS_TO_PORT": "9229",
},
+ "runArgs": ["--name","discourse"], // Step 1
"mounts": [
"source=${localWorkspaceFolderBasename}-node_modules,target=${containerWorkspaceFolder}/node_modules,type=volume",
"source=${localWorkspaceFolderBasename}-pg,target=/shared/postgres_data,type=volume",
p.s. please let me know, if you know how I can set the *.orb.local
hostname and the container name dynamically, as it is defined for GitHub Codespaces. Setting the value as .app.github.dev,.orb.local
didn’t work for me.
Update: Somehow, I was missing a record in my /etc/hosts
file. After adding this line, I was able to use .orb.local
wildcard domain in step 2.
With these changes in the devcontainer.json
file, now I can run my local Discourse instance at https://discourse.orb.local/
/etc/hosts
Add this line to your /etc/hosts
file if you don’t already have it.
##
# Docker and OrbStack
##
127.0.0.1 host.docker.internal
Bonus tip 1
If somehow your network settings, or your company VPN network, etc conflicts with OrbStack’s Container IP ranges, update your OrbStack with a different range.
Bonus tip 2
If you omit the step 1, OrbStack will create a randomly named container, but you will still be able use HTTPS without appending any port number. Downside is the container name, thus the domain name will be refreshed every time you rebuild the container.