Skip to content

Commit

Permalink
Add devcontainers (#391)
Browse files Browse the repository at this point in the history
Fixes RVT-3667, closes RVT-3382, closes RVT-3380
  • Loading branch information
AngelOnFira committed Feb 22, 2024
1 parent 6c7fa7a commit 9bb97db
Show file tree
Hide file tree
Showing 5 changed files with 166 additions and 24 deletions.
10 changes: 10 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
FROM mcr.microsoft.com/devcontainers/base:bullseye

RUN apt-get update \
&& export DEBIAN_FRONTEND=noninteractive \
&& apt-get -y install \
git-lfs \
libssl-dev \
pkg-config \
build-essential \
protobuf-compiler
32 changes: 32 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"name": "Rivet Dev",
"build": {
"dockerfile": "Dockerfile",
"context": "."
},
"remoteUser": "root",
"features": {
"ghcr.io/devcontainers/features/docker-in-docker:2": {
"moby": true,
"azureDnsAutoDetection": true,
"installDockerBuildx": true,
"version": "latest",
"dockerDashComposeVersion": "v2"
},
"ghcr.io/devcontainers/features/nix:1": {
"multiUser": true,
"version": "latest"
},
"ghcr.io/devcontainers/features/rust:1": {
"version": "latest",
"profile": "default"
}
},
"customizations": {
"vscode": {
"extensions": [
"rust-lang.rust-analyzer"
]
}
}
}
10 changes: 10 additions & 0 deletions .vscode/rivet.code-workspace
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"folders": [
{
"path": ".."
},
{
"path": "../lib/bolt"
}
],
}
136 changes: 112 additions & 24 deletions docs/getting_started/DEVELOPMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,59 +15,147 @@
> provide guidance on [Discord](https://discord.gg/BG2vqsJczH) when
> implementing the following issues:
>
> - https://github.com/rivet-gg/rivet/issues/153
> - https://github.com/rivet-gg/rivet/issues/155
> - https://github.com/rivet-gg/rivet/issues/154
> - https://github.com/rivet-gg/rivet/issues/156
> - https://github.com/rivet-gg/rivet/issues/157
> - <https://github.com/rivet-gg/rivet/issues/154>
> - <https://github.com/rivet-gg/rivet/issues/156>
> - <https://github.com/rivet-gg/rivet/issues/157>
## Prerequisites
There are two methods to set up a development environment:

- Using Devcontainers/Codespaces ([instructions](#dev-container))
- Directly on a virtual machine ([instructions](#virtual-machine))

Devcontainers are the primary choice as they're more supported by the
Rivet team. This is because their setup is consistant across Linux, MacOS, and
Windows, since devcontainers run inside of a Docker container. The Devcontainer
spec also allows you to use [GitHub
Codespaces](https://github.com/features/codespaces) if that is easier.

## Dev Container

### Prerequisites

- Visual Studio Code

**Windows Note**: If you're on Windows, you'll also [need WSL
installed](https://learn.microsoft.com/en-us/windows/wsl/install). Because the
default settings only give 16GB of ram to WSL, you'll need to [change the WSL
config](https://learn.microsoft.com/en-us/windows/wsl/wsl-config), and allocate
at least 24GB of ram to WSL. This is needed for the Rivet's source code to build
without running out of memory.

**Codespaces Notes** At this point, you can either run a Devcontainer locally, or set up a GitHub
Codespace. Codespaces cost money to use, but are a zero-configuration
setup in case you might not have good hardware to use. You can start a Codespace from Rivet's main
repo, though you will need to configure it so that it has at least 32GB of ram.

The rest of this section will assist you in setting up a Devcontainer locally.

### Step 1: Install dependencies

#### [Docker](https://docs.docker.com/engine/install/)

_Docker is required to run Rivet services._

See [here](https://docs.docker.com/engine/install/) for install instructions.

### Step 2: Set up Devcontainers

Devcontainers are a feature of Visual Studio Code, so you won't be able to use
them in other editors. To set up your editor to work with Devcontainers, you can
follow [this official
guide](https://code.visualstudio.com/docs/devcontainers/containers)

### Step 3: Clone repository

We need to clone the repository for the Devcontainer configuration to work. Run:

```sh
git clone https://github.com/rivet-gg/rivet.git
```

#### [Git](https://git-scm.com/)

See [here](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git) for
install instructions.

**Windows Note**: If you're on Windows, you'll need to run a script that will
set up symlinks properly. This command needs to be run from inside WSL, or
inside the Devcontainer. Run:

```sh
rm -rf "infra/helm/clickhouse/charts"
ln -s ../charts "infra/helm/clickhouse/charts"

rm -rf "infra/helm/redis/charts"
ln -s ../charts "infra/helm/redis/charts"

rm -rf "infra/helm/redis-cluster/charts"
ln -s ../charts "infra/helm/redis-cluster/charts"
```

### Step 4: Open in Devcontainer

Open the repository in Visual Studio Code. You should see a prompt to "Reopen in
Container". Click this to start the Devcontainer. If you don't see this prompt,
you can open the command palette (Ctrl+Shift+P or Cmd+Shift+P on Mac) and run
and run "Remote-Containers: Reopen in Container".

You can now skip to the [Common steps](#common-steps) section.

## Virtual Machine

### Prerequisites

**The following should be installed in a dedicated VM for Rivet.**

- Debian 11 (other Linux distros untested)
- Accessible from public IP
- Recommended: [Firewalls](/docs/getting_started/DEVELOPMENT_FIREWALLS.md)

## Step 1: Install dependencies
### Step 1: Install dependencies

### [Docker](https://docs.docker.com/engine/install/)
#### [Docker](https://docs.docker.com/engine/install/)

_Docker is required to run Rivet services._

See [here](https://docs.docker.com/engine/install/) for install instructions.

### [Nix package manager](https://nixos.org/download.html)
#### [Nix package manager](https://nixos.org/download.html)

_Nix is required to set up the development environment._

Run:

```
```sh
sh <(curl -L https://nixos.org/nix/install) --daemon
```

### [Git](https://git-scm.com/)

See [here](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git) for install instructions.

## Step 2: Clone repository
### Step 2: Clone repository

Run:

```
```sh
git clone https://github.com/rivet-gg/rivet.git
```

#### [Git](https://git-scm.com/)

See [here](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git) for install instructions.

## Common steps

Now that you have the environment set up either in a Devcontainer or VM, we can
start setting up the Rivet cluster.

> **Warp compatibility**
>
> Warp may have issues with the Nix installer since it does not use the default shell. [Read more.](https://docs.warp.dev/features/ssh)
## Step 3: Boot cluster
### Step 1: Boot cluster

Run:

```
```sh
nix-shell --run "bolt init dev --yes"
```

Expand All @@ -82,31 +170,31 @@ Run this command any time you update to a new version of Rivet.
>
> See the `namespaces/dev.toml` and `secrets/dev.toml` file to see the generated namespace configs.
## Step 4: Boot the Rivet Hub
### Step 2: Boot the Rivet Hub

Now, you have to start the hub frontend.

1. Clone the [Rivet Hub](https://github.com/rivet-gg/hub) with
2. Create a file called `.env` in the root of the `hub` repo
- Set `RIVET_API_ENDPOINT=http://localhost:8080` in the `.env` file
3. Start the hub
4. Visit http://localhost:5080
4. Visit <http://localhost:5080>
5. Register an account with your email

## Step 5: Promote yourself to admin
### Step 3: Promote yourself to admin

```
```sh
nix-shell --run "bolt db sh db-user --query 'UPDATE users SET is_admin = true'"
```

You may need to clear the local cache for this change to appear. ([Related issue](https://github.com/rivet-gg/rivet/issues/152))

_This command sets all users to admin. We're assuming you're the only user in the cluster. Do not run this command again._

## Step 6: Create a developer group
### Step 4: Create a developer group

You should now see a "Create Group" button on the hub. Proceed to create a group and start developing.

## Next steps
### Next steps

Read more about [working with Bolt](/docs/libraries/bolt/README.md) or see other [helpful docs](/README.md#-documentation-overview)
2 changes: 2 additions & 0 deletions lib/bolt/cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ use commands::*;
mod commands;

#[derive(Parser)]
// This will use the version from the Cargo.toml file during compilation
#[clap(version = env!("CARGO_PKG_VERSION"))]
struct Opts {
#[clap(subcommand)]
command: SubCommand,
Expand Down

0 comments on commit 9bb97db

Please sign in to comment.