2017-10-29 02:02:58 +01:00
|
|
|
# Create a remote Zulip dev server
|
|
|
|
|
|
|
|
This guide is for mentors who want to help create remote Zulip dev servers
|
|
|
|
for hackathon, GCI, or sprint participants.
|
|
|
|
|
|
|
|
The machines (droplets) have been generously provided by
|
2020-07-30 02:09:05 +02:00
|
|
|
[DigitalOcean](https://www.digitalocean.com/) to help Zulip contributors
|
|
|
|
get up and running as easily as possible. Thank you DigitalOcean!
|
2017-10-29 02:02:58 +01:00
|
|
|
|
2020-07-30 02:09:05 +02:00
|
|
|
The `create.py` create uses the DigitalOcean API to quickly create new virtual
|
2017-10-29 02:02:58 +01:00
|
|
|
machines (droplets) with the Zulip dev server already configured.
|
|
|
|
|
2020-07-30 02:09:05 +02:00
|
|
|
## Step 1: Join Zulip DigitalOcean team
|
2017-10-29 02:02:58 +01:00
|
|
|
|
2020-07-30 02:09:05 +02:00
|
|
|
We have created a team on DigitalOcean for Zulip mentors. Ask Rishi or Tim
|
|
|
|
to be added. You need access to the team so you can create your DigitalOcean
|
2017-10-29 02:02:58 +01:00
|
|
|
API token.
|
|
|
|
|
2020-07-30 02:09:05 +02:00
|
|
|
## Step 2: Create your DigitalOcean API token
|
2017-10-29 02:02:58 +01:00
|
|
|
|
|
|
|
Once you've been added to the Zulip team,
|
docs: Add missing space to compound verbs “log in”, “set up”, etc.
Noun: backup, checkout, cleanup, login, logout, setup, shutdown, signup,
timeout.
Verb: back up, check out, clean up, log in, log out, set up, shut
down, sign up, time out.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-04-25 23:05:38 +02:00
|
|
|
[log in](https://cloud.digitalocean.com/droplets) to the DigitalOcean control
|
2017-10-29 02:02:58 +01:00
|
|
|
panel and [create your personal API token][do-create-api-token]. **Make sure
|
|
|
|
you create your API token under the Zulip team.** (It should look something
|
|
|
|
like [this][image-zulip-team]).
|
|
|
|
|
|
|
|
Copy the API token and store it somewhere safe. You'll need it in the next
|
|
|
|
step.
|
|
|
|
|
|
|
|
## Step 3: Configure create.py
|
|
|
|
|
|
|
|
In `tools/droplets/` there is a sample configuration file `conf.ini-template`.
|
|
|
|
|
|
|
|
Copy this file to `conf.ini`:
|
|
|
|
|
|
|
|
```
|
|
|
|
$ cd tools/droplets/
|
|
|
|
$ cp conf.ini-template conf.ini
|
|
|
|
```
|
|
|
|
|
|
|
|
Now edit the file and replace `APITOKEN` with the personal API token you
|
|
|
|
generated earlier.
|
|
|
|
|
|
|
|
```
|
|
|
|
[digitalocean]
|
|
|
|
api_token = APITOKEN
|
|
|
|
```
|
|
|
|
|
|
|
|
Now you're ready to use the script.
|
|
|
|
|
|
|
|
## Usage
|
|
|
|
|
|
|
|
`create.py` takes two arguments
|
|
|
|
|
2021-08-20 21:45:39 +02:00
|
|
|
- GitHub username
|
|
|
|
- Tags (Optional argument)
|
2017-10-29 02:02:58 +01:00
|
|
|
|
|
|
|
```
|
|
|
|
$ python3 create.py <username>
|
|
|
|
$ python3 create.py <username> --tags <tag>
|
|
|
|
$ python3 create.py <username> --tags <tag1> <tag2> <tag3>
|
|
|
|
```
|
2021-08-20 22:54:08 +02:00
|
|
|
|
2017-10-29 02:02:58 +01:00
|
|
|
Assigning tags to droplets like `GCI` can be later useful for
|
|
|
|
listing all the droplets created during GCI.
|
|
|
|
[Tags](https://www.digitalocean.com/community/tutorials/how-to-tag-digitalocean-droplets)
|
|
|
|
may contain letters, numbers, colons, dashes, and underscores.
|
|
|
|
|
|
|
|
You'll need to run this from the Zulip development environment (e.g. in
|
|
|
|
Vagrant).
|
|
|
|
|
2017-11-28 16:58:51 +01:00
|
|
|
The script will also stop if a droplet has already been created for the
|
|
|
|
user. If you want to recreate a droplet for a user you can pass the
|
2017-11-23 16:29:08 +01:00
|
|
|
`--recreate` flag.
|
|
|
|
|
|
|
|
```
|
|
|
|
$ python3 create.py <username> --recreate
|
|
|
|
```
|
2021-08-20 22:54:08 +02:00
|
|
|
|
2017-11-23 16:29:08 +01:00
|
|
|
This will destroy the old droplet and create a new droplet for
|
|
|
|
the user.
|
|
|
|
|
2017-10-29 02:02:58 +01:00
|
|
|
In order for the script to work, the GitHub user must have:
|
|
|
|
|
|
|
|
- forked the [zulip/zulip][zulip-zulip] repository, and
|
2020-10-23 02:43:28 +02:00
|
|
|
- created an SSH key pair and added it to their GitHub account.
|
2017-10-29 02:02:58 +01:00
|
|
|
|
|
|
|
(Share [this link][how-to-request] with students if they need to do these
|
|
|
|
steps.)
|
|
|
|
|
2020-10-23 02:43:28 +02:00
|
|
|
The script will stop if it can't find the user's fork or SSH keys.
|
2017-10-29 02:02:58 +01:00
|
|
|
|
|
|
|
Once the droplet is created, you will see something similar to this message:
|
|
|
|
|
|
|
|
```
|
|
|
|
Your remote Zulip dev server has been created!
|
|
|
|
|
|
|
|
- Connect to your server by running
|
|
|
|
`ssh zulipdev@<username>.zulipdev.org` on the command line
|
|
|
|
(Terminal for macOS and Linux, Bash for Git on Windows).
|
2020-10-23 02:43:28 +02:00
|
|
|
- There is no password; your account is configured to use your SSH keys.
|
2019-01-10 01:30:44 +01:00
|
|
|
- Once you log in, you should see `(zulip-py3-venv) ~$`.
|
2023-03-04 02:17:54 +01:00
|
|
|
- To start the dev server, `cd zulip` and then run `./tools/run-dev`.
|
2017-10-29 02:02:58 +01:00
|
|
|
- While the dev server is running, you can see the Zulip server in your browser
|
|
|
|
at http://<username>.zulipdev.org:9991.
|
|
|
|
|
|
|
|
See [Developing
|
2017-11-16 19:54:24 +01:00
|
|
|
remotely](https://zulip.readthedocs.io/en/latest/development/remote.html) for tips on
|
2017-10-29 02:02:58 +01:00
|
|
|
using the remote dev instance and [Git & GitHub
|
2017-11-24 01:24:00 +01:00
|
|
|
Guide](https://zulip.readthedocs.io/en/latest/git/index.html) to learn how to
|
2017-10-29 02:02:58 +01:00
|
|
|
use Git with Zulip.
|
|
|
|
```
|
|
|
|
|
|
|
|
Copy and paste this message to the user via Zulip chat. Be sure to CC the user
|
|
|
|
so they are notified.
|
|
|
|
|
|
|
|
[do-create-api-token]: https://www.digitalocean.com/community/tutorials/how-to-use-the-digitalocean-api-v2#how-to-generate-a-personal-access-token
|
|
|
|
[image-zulip-team]: http://cdn.subfictional.com/dropshare/Screen-Shot-2016-11-28-10-53-24-X86JYrrOzu.png
|
|
|
|
[zulip-zulip]: https://github.com/zulip/zulip
|
|
|
|
[python-digitalocean]: https://github.com/koalalorenzo/python-digitalocean
|
2017-11-28 17:00:25 +01:00
|
|
|
[how-to-request]: https://zulip.readthedocs.io/en/latest/development/request-remote.html
|
2017-10-29 02:02:58 +01:00
|
|
|
|
|
|
|
## Updating the base image
|
|
|
|
|
2022-04-28 03:31:25 +02:00
|
|
|
1. Switch to the Zulip organization.
|
|
|
|
1. Create a new droplet, with:
|
|
|
|
- "Regular with SSD" / "2GB RAM / 1 CPU"
|
|
|
|
- Select your SSH key; this will not be built into the image, and
|
|
|
|
is only for access to debug if the build does not succeed.
|
|
|
|
- Check "Monitoring", "IPv6", and "User data"
|
|
|
|
- Paste the contents of `tools/droplets/new-droplet-image` into the
|
|
|
|
text box which says `Enter user data here...`
|
2024-03-25 20:45:58 +01:00
|
|
|
- Name it e.g. `base-ubuntu-22-04.zulipdev.org`
|
2022-04-28 03:31:25 +02:00
|
|
|
1. Wait for the host to boot.
|
2024-05-30 19:53:26 +02:00
|
|
|
1. Wait for the host to complete provisioning and shut down; this will take
|
|
|
|
about 15 minutes.
|
2022-04-28 03:31:25 +02:00
|
|
|
1. Go to the Snapshots tab on the image, and "Take a Snapshot".
|
|
|
|
1. Wait for several minutes for it to complete.
|
2022-04-28 03:33:57 +02:00
|
|
|
1. "Add to region" the snapshot into `NYC3`, `SFO3`, `BLR1`, and `FRA1`.
|
2022-04-28 03:31:25 +02:00
|
|
|
1. `curl -u <API_KEY>: https://api.digitalocean.com/v2/snapshots | jq .`
|
2017-10-29 02:02:58 +01:00
|
|
|
1. Replace `template_id` in `create.py` in this directory with the
|
2020-05-01 21:41:43 +02:00
|
|
|
appropriate `id`.
|
2022-04-28 03:31:25 +02:00
|
|
|
1. Clean up by destroying the droplet (but _leaving_ all "associated
|
|
|
|
resources"), and removing the DNS entry for `base.zulipdev.org`
|
|
|
|
1. Open a PR with the updated `template_id`.
|
2017-11-28 21:11:44 +01:00
|
|
|
|
|
|
|
## Remotely debugging a droplet
|
|
|
|
|
|
|
|
To SSH into a droplet, first make sure you have a SSH key associated with your
|
2020-10-23 02:43:28 +02:00
|
|
|
GitHub account, then ask the student to run the following in their
|
2017-11-28 21:11:44 +01:00
|
|
|
VM:
|
|
|
|
|
|
|
|
```
|
|
|
|
$ python3 ~/zulip/tools/droplets/add_mentor.py <your username>
|
|
|
|
```
|
|
|
|
|
|
|
|
You should now be able to connect to it using:
|
|
|
|
|
|
|
|
```
|
|
|
|
$ ssh zulipdev@<their username>.zulipdev.org
|
|
|
|
```
|
|
|
|
|
|
|
|
They can remove your SSH keys by running:
|
|
|
|
|
|
|
|
```
|
|
|
|
$ python3 ~/zulip/tools/droplets/add_mentor.py <your username> --remove
|
|
|
|
```
|
2021-03-17 20:03:43 +01:00
|
|
|
|
|
|
|
# Creating a production droplet
|
|
|
|
|
|
|
|
`create.py` can also create a production droplet quickly for testing purposes.
|
|
|
|
|
|
|
|
```
|
|
|
|
$ python3 create.py <username> --production
|
|
|
|
```
|