Skip to content

Commit dfe8d1e

Browse files
committed
docs: add dogfooding guide
1 parent 5b78251 commit dfe8d1e

File tree

1 file changed

+143
-0
lines changed

1 file changed

+143
-0
lines changed

docs/dogfooding.md

Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
# Dogfooding
2+
3+
This guide explains how to dogfood coder for employees at Coder.
4+
5+
## How to
6+
7+
The following explains how to do certain things related to dogfooding.
8+
9+
### Dogfood using Coder's Deployment
10+
11+
1. Go to [https://dev.coder.com](https://dev.coder.com/)
12+
- If you see a dialog/pop-up, hit "Cancel"
13+
2. Sign in with GitHub
14+
3. Clone the repo: `git clone git@github.com:coder/coder.git`
15+
4. Run `make bin`. The binaries will be created in the `./dist` folder.
16+
17+
<aside>
18+
💡 We usually rename the `coder` binary to `coderv2` so it doesn’t clash with the old version!
19+
20+
</aside>
21+
22+
5. `coder login https://dev.coder.com`
23+
6. `coder template create` - create a new template from the current directory
24+
1. e.g. `coder template create docker -d ./examples/templates/docker`
25+
7. `coder create` - create a new workspace
26+
1. e.g. `coder create my-workspace -t docker`
27+
8. `coder config-ssh` - configure local SSH settings
28+
29+
<aside>
30+
⚠️ If you create a new workspace, you need to re-run this command.
31+
32+
</aside>
33+
34+
9. There are two options from here:
35+
1. Option 1: ssh into workspace and start coding with vim
36+
2. Option 2: use VS Code - [Remote SSH extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-ssh)
37+
38+
### Run Coder in your Coder Workspace
39+
40+
1. Clone the Git repo `[https://github.com/coder/coder](https://github.com/coder/coder)` and `cd` into it
41+
2. Run `sudo apt update` and then `sudo apt install -y netcat`
42+
- skip this step if using the `coder` template
43+
3. Run `make bin`
44+
45+
<aside>
46+
💡 If you run into the following error:
47+
48+
```js
49+
pg_dump: server version: 13.7 (Debian 13.7-1.pgdg110+1); pg_dump version: 11.16 (Ubuntu 11.16-1.pgdg20.04+1)
50+
pg_dump: aborting because of server version mismatch
51+
```
52+
53+
Don’t fret! This is a known issue. To get around it:
54+
55+
1. Add `export DB_FROM=coderdb` to your `.bashrc` (make sure you `source ~/.bashrc`)
56+
2. Run `sudo service postgresql start`
57+
3. Run `sudo -u postgres psql` (this will open the PostgreSQL CLI)
58+
4. Run `postgres-# alter user postgres password 'postgres';`
59+
5. Run `postgres-# CREATE DATABASE coderdb;`
60+
6. Run `postgres-# grant all privileges on database coderdb to postgres;`
61+
7. Run `exit` to exit the PostgreSQL terminal
62+
8. Try `make bin` again.
63+
</aside>
64+
65+
4. Run `./scripts/develop.sh` which will start *two* separate processes:
66+
1. `[http://localhost:3000](http://localhost:3000)` — backend API server 👈 Backend devs will want to talk to this
67+
2. `[http://localhost:8080](http://localhost:8080)`Node.js dev server 👈 Frontend devs will want to talk to this
68+
69+
<aside>
70+
💡 If you’re dogfooding on v1, add a DevURL to port 8080, HTTP
71+
If you’re dogfooding on v2, either:
72+
- Use `coder tunnel 8080 8080`
73+
- Use VSCode’s built-in port forwarding. See: [https://code.visualstudio.com/docs/remote/ssh](https://code.visualstudio.com/docs/remote/ssh)
74+
75+
</aside>
76+
77+
5. Ensure that you’re logged in: `./scripts/coder-dev.sh list` — should return no workspace. If this returns an error, double-check the output of running `scripts/develop.sh`.
78+
6. A template named `docker-amd64` (or `docker-arm64` if you’re on ARM) will have automatically been created for you. If you just want to create a workspace quickly, you can run `./scripts/coder-dev.sh create myworkspace -t docker-amd64` and this will get you going quickly!
79+
7. To create your own template, you can do: `./scripts/coder-dev.sh templates init` and choose your preferred option.
80+
For example, choosing “Develop in Docker” will create a new folder `docker` that contains the bare bones for starting a Docker workspace template.
81+
Then, enter the folder that was just created and customize as you wish.
82+
83+
<aside>
84+
💡 **For all Docker templates:**
85+
This step depends on whether you are developing on a Coder v1 workspace, versus a Coder v2 workspace, versus a VM, versus locally. In any case, check the output of the command `docker context ls` to determine where your Docker daemon is listening. Then open `./docker/main.tf` and check inside the block `provider "docker"` that the variable `"host"` is set correctly.
86+
87+
</aside>
88+
89+
## Troubleshooting
90+
91+
### What if I'm having trouble because I have the old coder CLI installed?
92+
93+
Move `coder` to `coderv2`:
94+
```shell
95+
sudo mv coder /usr/local/bin/coderv2
96+
coderv2 config-ssh
97+
```
98+
99+
### My Docker containers keep failing and I have no idea what's going on!
100+
101+
```shell
102+
✔ Queued [236ms]
103+
✔ Setting up [5ms]
104+
⧗ Starting workspace
105+
Terraform 1.1.9
106+
coder_agent.dev: Plan to create
107+
docker_volume.home_volume: Plan to create
108+
docker_container.workspace[0]: Plan to create
109+
Plan: 3 to add, 0 to change, 0 to destroy.
110+
coder_agent.dev: Creating...
111+
coder_agent.dev: Creation complete after 0s [id=b2f132bd-9af1-48a7-81dc-187a18ee00d5]
112+
docker_volume.home_volume: Creating...
113+
docker_volume.home_volume: Creation complete after 0s [id=coder-maf-mywork-root]
114+
docker_container.workspace[0]: Creating...
115+
docker_container.workspace[0]: Creation errored after 0s
116+
Error: container exited immediately
117+
118+
✘ Starting workspace [2045ms]
119+
terraform apply: exit status 1
120+
Run 'coder create --help' for usage.
121+
```
122+
123+
Check the output of `docker ps -a`
124+
- If you see a container with the status `Exited` run `docker logs <container name>` and see what the issue with the container output is
125+
126+
Enable verbose container logging for Docker:
127+
```shell
128+
sudo cp /etc/docker/daemon.json /etc/docker/daemon.json.orig
129+
sudo cat > /etc/docker/daemon.json << EOF
130+
{
131+
"debug": true,
132+
"log-driver": "journald"
133+
}
134+
EOF
135+
sudo systemctl restart docker
136+
# You should now see container logs in journald.
137+
# Try starting a workspace again and see what the actual error is!
138+
sudo journalctl -u docker -f
139+
```
140+
141+
### Help! I'm still blocked
142+
143+
Post in the #dogfood Slack channel internally or open a Discussion on GitHub and tag @jsjoeio or @bpmct

0 commit comments

Comments
 (0)