# Development Container Setup

## Development Container Setup

A [development container](https://containers.dev/) is a [quasi-standard](https://github.com/devcontainers/spec) way to configure a development environment in a Docker container and install an agent that communicates with the IDE running on the host machine. The container can run locally or on a remote host.

This configuration solution is an option for students who are unable to configure their local environment via the existing Maven and JDK setup infrastructure and/or need to build on a remote host due to system constraints.

## Requirements

### Docker

Install [Docker](https://www.docker.com/) on the machine running the build container, i.e. your laptop or personal computer.

We recommend that you run the build container on the host machine (a personal device); however, it is possible to run the container elsewhere, though course staff is unlikely to support alternate methods.

### IDE

We recommend using IntelliJ IDEA due to its debugging capabilities and are unlikely to support other IDEs. If you prefer a different IDE, see below for instructions to run a development container via Visual Studio Code (VS Code) or GitHub Codespaces.

#### IntelliJ IDEA Ultimate

*Note that this version is different from IntelliJ IDEA CE (Community Edition); however, both can remain installed and be used on your device simultaneously.*

Development containers are currently supported only in the [Ultimate edition](https://www.jetbrains.com/idea/) of IntelliJ IDEA. You may obtain a free, non-commercial license [here](https://www.jetbrains.com/community/education/#students) on a new or existing JetBrains account using your university address (@berkeley.edu). Note that if you have an existing JetBrains account linked to a different email address, you may need to [link](https://sales.jetbrains.com/hc/en-gb/articles/7654171906706-Linking-multiple-email-addresses-to-your-JetBrains-Account) your personal email to your university email JetBrains account.

#### Other IDEs

Install your preferred IDE. Note that course staff will only support IntelliJ IDEA Ultimate (recommended), VS Code, and GitHub Codespaces.

## Creating the Dev Container

### IntelliJ IDEA Ultimate

IntelliJ is currently configured to use the [EAP](https://www.jetbrains.com/idea/nextversion/) (early access) version of its IDE to connect to the container by default. The EAP version is the beta version of the IDE that is both less stable and on a license which expires after 30-45 days. To disable this, go to `Settings > Advanced Settings` and uncheck the box "Always use the latest backend" (see [here](https://youtrack.jetbrains.com/articles/SUPPORT-A-551) for the article).

![Screenshot - Uncheck "Always use the latest backend.".png](https://678656433-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MFVQnrLlCBowpNWJo1E%2Fuploads%2Fgit-blob-e44fd03a4d2a15f5cbf810ec4cd60bc1b23d4b29%2Fdc-0.png?alt=media)

Start the IDE and navigate to "Dev Containers":

![Screenshot - Select Dev Containers](https://678656433-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MFVQnrLlCBowpNWJo1E%2Fuploads%2Fgit-blob-84484cc566607ddee640f15ff1f8f37ffcfd2d70%2Fdc-1.png?alt=media)

Create a "New Dev Container":

![Screenshot - Select New Dev Container](https://678656433-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MFVQnrLlCBowpNWJo1E%2Fuploads%2Fgit-blob-4fdf80595387ea00610b8d4079ed4b1993b85e0a%2Fdc-2.png?alt=media)

Use the HTTPS address of the rookiedb repository for the relevant project. For example, a student with GitHub username `oski` working on Project 0 would use the repository address `https://github.com/cs186-student/sp25-proj0-oski.git`:

![Screenshot - Add Repository and Branch information](https://678656433-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MFVQnrLlCBowpNWJo1E%2Fuploads%2Fgit-blob-769d098e24608da90ca62f0aaf326309dbce8dc9%2Fdc-6.png?alt=media)

Click "Build Container and Continue" and wait for Docker to download and build the image (this will take a few minutes).

#### Troubleshooting

**GitHub Authentication**

GitHub [deprecated password-based authentication](https://github.blog/security/application-security/token-authentication-requirements-for-git-operations/) in July 2020, which means that your password no longer works for command-line authentication. If asked to authenticate your GitHub account via IntelliJ, create a [Personal Access Token (PAT)](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens#creating-a-personal-access-token-classic), which you may use to set up each of your dev containers. Ensure that you save your token securely, as it cannot be accessed again via your account.

**SSH Repository URL**

If you're creating a dev container using the SSH URL instead of the HTTPS URL, you may need to run `ssh-add -k` locally to add your private SSH key to your device. You may run `ssh-add -l` to see the SSH keys currently on your device.

### Visual Studio Code (VS Code) (local)

Select ![Remote Explorer](https://678656433-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MFVQnrLlCBowpNWJo1E%2Fuploads%2Fgit-blob-5978cb5ea5e3d59f3711fc14836bc45ec65bdeea%2Fdc-4.png?alt=media) and click the ![plus icon](https://678656433-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MFVQnrLlCBowpNWJo1E%2Fuploads%2Fgit-blob-9baa4345176eeb0c21f5c9b52d8210e05370fda0%2Fdc-5.png?alt=media) to create a new dev container.

Then select `Clone Repository in Container Volume` and follow prompts to clone the repository into the container.

### Codespaces (VS Code or web browser)

A [GitHub Codespace](https://github.com/features/codespaces) runs the build container in Azure, either in a browser or through the VS Code application.

Either open VS Code or the web-based editor for the repository, `https://github.dev/cs186-student/sp25-projX-username`, by navigating through `github.dev` instead of `github.com`.

Select ![Remote Explorer](https://678656433-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MFVQnrLlCBowpNWJo1E%2Fuploads%2Fgit-blob-5978cb5ea5e3d59f3711fc14836bc45ec65bdeea%2Fdc-4.png?alt=media) and click on "Create Codespace."

Please consult the documentation for latest pricing information. GitHub currently provides 120 core-hours (60 hours in the least-capable image) per month to all users for free. If you elect to run in this or another remote configuration, course staff may be unable to provide support.

##

CS 186 Spring 2025

Authors: Chris Douglas, Janani Sriram
