Github Codespaces is a cloud-based development environment that can be used in-browser or (preferably) with Visual Studio Code. Please join #codespaces for any comments or questions about using Codespaces at VA .
- Visit github.com/codespaces
- Click the
...
link next to a codespace - Select "Open with Codespaces"
- See Getting Started in
vets-website
for more detail.
-
Download and install Visual Studio Code
-
Arch Linux:
yay --sync visual-studio-code-bin
-
Open VS Code and install the Codespaces plugin
-
Go to the main Codespaces page and click the 'New codespace' button
-
Type in the name of your fork of the CMS repo (create one if you haven't already) and choose the main branch. If it doesn't come up in the list you may have to type the full name, e.g.
elijahlynn/va.gov-cms
, not justva.gov-cms
: -
Click "Sign into GitHub", a browser will open authorizing GitHub and VS Code.
-
Click 'Create codespace'
-
You will see this dialog:
- Choose a machine type with at least 64GB of disk space to ensure that you have enough space to run the project.
- Open VS Code, click the 'Remote Explorer' tab on the left, and click the 'Connect to codespace' button (it looks like an electric plug) to choose the codespace you just created:
- After a few seconds, you will be connected to codespaces, and the IDE will function like it is running locally for all intents and purposes.
- The development environment will automatically configure, install and start ddev on creation, which takes ~10-15 minutes because of DB and files importing. To monitor the process, choose 'New Terminal' from the 'Terminal' menu, and run this command:
tail -f ~/post-create.log
. The environment configuration also suggests plugins for linting and code style checking, and sets up the upstream git remote for the main CMS repo. - When the setup process is complete, you will see a welcome message.
- You may want to change your git email address for commits with
git config --global user.email [email protected]
. You can see what is currently listed withgit config --global --list
. - Your development environment is ready to use! Create a new terminal and run the command
ddev describe
. Mouse over the link to localhost, and VS Code will provide instructions to open the site in your browser with automatic port forwarding.
To set up your preferred shell environment, you may create a public 'dotfiles' repo under your own github account. More information is available in the official documentation. If you create and populate a .bash_aliases
file in your dotfiles repository and enable your dotfiles repository for Codespaces, any aliases you add will be available in the codespaces environment.
- In a terminal, run the command
ddev describe
- In the
web
section of the output, hover over one of the localhost addresses, e.g.http://localhost:49161
- Command-click to automatically forward the port and open in your local browser
To debug with Xdebug, follow these steps:
- In a terminal, run the command
ddev xdebug on
- Click the debugging tab on the left, and then the green play button to the left of 'Listen for Xdebug':
- Set a breakpoint and load a page in your browser. Go to town!
The codespaces configuration and setup script are located in the .devcontainer directory of this repo. The main configuration is stored in devcontainer.json
- available properties are documented here.