(outdated) Guide to Setting Up Discourse Development Environment - GitHub Codespace

jordan-violet
Wed, 08 May 2024 10:44:56 +0000
Developers

Discourse core now includes an updated devcontainer configuration, which means the manual steps in the topic are no longer required.

Check out the official docs here: Developing Discourse on GitHub Codespaces

Developing Using GitHub Codespaces

GitHub Codespace is a great development option. It’s great because it’s hosted in the cloud, I can easily ensure that everyone developing here has the same environment, no dealing with local docker installations, easy access to making my local dev instance available publicly, and also just using new technology is fun.

I’m currently re-learning development and decided to pickup GitHub Codespaces in addition to learning some Discourse development, so I made this guide for anyone else looking to develop on Discourse in GitHub Codespace rather than setting up a local environment.

I decided to write this guide after going through a slew of issues getting this working with GitHub Codespace myself:

Issues attempting to run discourse in GitHub Codespaces Dev

Following this post from @cvx on a fresh GitHub codespace install: Running bin/ember-cli -u (FYI for anyone else, you first have to cd into workspace/discourse), nets the following issue: [image]

This guide will assume nothing, so we don’t miss a single step to getting you up and running. I suspect some of this process can be improved at the core repo level for the GitHub Codespace configuration, or at least due to my lack of understanding. Don’t hesitate to point these out.

Fork the Discourse repository

1. Navigate to https://github.com/discourse/discourse

2. Click the Fork button in the top-right of the page and click the green 'Create fork` button on the subsequent page.

3. After a brief moment, you’ll be taken to your new fork of the discourse/discourse repository:

Setup Your GitHub Codespace

1. Click the green <> Code button

2. Switch to the Codespaces tab and click the green Create codoespace on main button.

3. You’ll be taken to a new window where GitHub will start creating your codespace. This should take 1-3 minutes:

4. After a few minutes, you’ll be presented with your GitHub Codespace (which is just VS Code in your browser):

Setup Your Codespace Environment

There are some configurations to make to your codespace environment before you’re up and running.

1. Create a new bash shell by click Ctrl + Shift + backtick on Windows/Linux, or Cmd + Shift + backtick on Mac. Your shell should have you starting int he /var/www/discourse directory.

2. Navigate to the discourse directory:

cd workspace/discourse

3. Install everything from the project Gemfile

bundle install --gemfile ./Gemfile

The command is quite long, but you’ll see something like this:

4. Add a new config.hosts to the development.rb

1. From the directory you’re currently in (/var/www/discourse/workspace/discourse) open the file config/environments/development.rb.

2. Find the line config.hosts << /\A(([a-z0-9-]+)\.)*localhost(\:\d+)?\Z/ and create a new line below it with the following, then save the file:

config.hosts << /^(.*)\.app\.github\.dev$/

The tail-end of your file should look like this (notice line 102 in my screenshot):

5. Back down in your terminal, run bundle exec rake admin:create to create your first admin account. The command will ask you to choose an email and a password (password must be at least 10 characters)

Start Your Engines Server

It will take 1-2 minutes to build and start the server. At this point, you should now have everything you need to run and access your application.

1. In the same terminal you’re in, run the following command to start your server:

bin/ember-cli -u

2. Switch from the Terminal tab to the PORTS tab in your console:

3. Click on the Forwarded Address for port 4200 using Ctrl + click for Windows/Linux, or Cmd + click for Mac and you’ll be greeted with your development environment!

Hopefully this helps someone else in getting started with GitHub Codespaces!

9 messaggi - 6 partecipanti