Developing Discourse using a Dev Container

For those who are not married to vscode, this is the process to do devcontainers with just the devcontainers cli.
Assuming you have devcontainers installed already:

Build Container

git clone https://github.com/discourse/discourse && cd discourse
devcontainer build
devcontainer up --workspace-folder .
devcontainer exec bash

Once inside the container you need to build the deps

pnpm install
bundle install
SKIP_MULTISITE=1 SKIP_TEST_DATABASE=1 bin/rake db:create db:migrate
DISCOURSE_DEV_ALLOW_ANON_TO_IMPERSONATE=1 bin/ember-cli -u > /dev/null 2>&1 &
  • Change /dev/null to a different file if you want logs
  • If you want to leave it running while disconnected from the shell run disown

Access discourse

docker inspect <name> | jq '.[0].NetworkSettings.Networks.bridge.IPAddress'

This will reveal the ipaddress assigned to the container.
In your browser open http://<ipaddress>:4200

Cleanup

To delete your devcontainer (the down/delete options are not developed)
Retrieve the name of the container
docker ps
stop and delete the container:
docker stop <name> && docker rm <name>
delete the volumes:
docker volume rm discourse-node_modules discourse-pg discourse-redis

2 Likes