Skip to content

Commit e974e23

Browse files
Add new deployment example to docs: deploy on Ubuntu server (#567)
* First version of Ubuntu deployment * Add images, update some commands
1 parent 62c3ece commit e974e23

5 files changed

Lines changed: 296 additions & 0 deletions

File tree

Lines changed: 296 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,296 @@
1+
# Deploying on an Ubuntu server
2+
3+
## Prerequisites
4+
5+
- An Ubuntu server
6+
- Need terminal (SSH) and HTTP(S) access
7+
- This guide was written using Ubuntu 24.04.2
8+
- A domain name for the server
9+
- This guide assumes you are using the top level of the domain, so e.g. if
10+
your domain name is `example.com`, you won't be able to have Apollo be at
11+
`example.com/apollo`. Subdomains are fine, though, so you could use
12+
`apollo.example.com`
13+
14+
## Set up JBrowse
15+
16+
Before installing anything, just to make sure the repositories are up to date,
17+
run
18+
19+
```sh
20+
sudo apt update
21+
```
22+
23+
Now install the tools we need by running
24+
25+
```sh
26+
sudo apt install -y apache2 unzip
27+
```
28+
29+
This installs:
30+
31+
- apache2, which is the web server we'll use to server JBrowse
32+
- unzip, for decompressing the JBrowse installation files
33+
34+
By default, apache2 serves files located in the `/var/www/html` directory. We'll
35+
add permissions for our user to access that directory and then set up the
36+
JBrowse files there.
37+
38+
```sh
39+
sudo chown -R $(whoami) /var/www/html/
40+
cd /var/www/html/
41+
rm index.html
42+
curl -fsSL https://s3.amazonaws.com/jbrowse.org/code/jb2/latest/jbrowse-web-latest.zip > jbrowse-web.zip
43+
unzip jbrowse-web.zip
44+
rm jbrowse-web.zip
45+
sudo systemctl restart apache2.service
46+
```
47+
48+
Now open the URL of your server. You should see a screen that says "It worked!".
49+
If so, JBrowse has been successfully installed.
50+
51+
![Screen showing "It worked!" message](img/jbrowse_it_worked.png)
52+
53+
## Set up Apollo JBrowse plugin
54+
55+
To add the Apollo plugin, we'll first fetch the plugin source file and place it
56+
in a file called `apollo.js` in the directory with the other JBrowse files.
57+
58+
```sh
59+
curl -fsSL https://registry.npmjs.org/@apollo-annotation/jbrowse-plugin-apollo/ > jpa.json
60+
LATEST_VERSION=$(jq -r '."dist-tags".latest' jpa.json)
61+
TARBALL_URL=$(jq -r ".versions.\"${LATEST_VERSION}\".dist.tarball" jpa.json)
62+
curl -fsSL ${TARBALL_URL} | \
63+
tar --extract --gzip --file=- --strip=2 package/dist/jbrowse-plugin-apollo.umd.production.min.js
64+
mv jbrowse-plugin-apollo.umd.production.min.js apollo.js
65+
rm jpa.json
66+
```
67+
68+
In order to test that this worked, we'll need to create a temporary JBrowse
69+
config file. We'll use the text editor `nano` in this tutorial, but feel free to
70+
use whatever text editor you like.
71+
72+
First install `nano` and use it to open a file
73+
74+
```sh
75+
sudo apt install -y nano
76+
nano config.json
77+
```
78+
79+
That will open the `nano` editor. Paste or type the following into the file:
80+
81+
```json
82+
{
83+
"plugins": [
84+
{
85+
"name": "Apollo",
86+
"url": "apollo.js"
87+
}
88+
]
89+
}
90+
```
91+
92+
To save the file, press <kbd>Ctrl</kbd> + <kbd>O</kbd> and then
93+
<kbd>Enter</kbd>, and to exit `nano`, press <kbd>Ctrl</kbd> + <kbd>X</kbd>.
94+
95+
Now open the same link as before (or refresh the page). You should now see the
96+
JBrowse start screen. Choose an "Empty" session.
97+
98+
![JBrowse start screen](img/jbrowse_start_screen.png)
99+
100+
If Apollo has been installed successfully, you'll see a menu called "Apollo" at
101+
the top of the page.
102+
103+
![Menu bar of JBrowse with an "Apollo" menu](img/apollo_top_menu.png)
104+
105+
You can use some basic Apollo functionality like editing annotations small local
106+
GFF3 files with just the plugin, but to enable the full functionality of Apollo
107+
we'll need to add the last two components. Delete the `config.json` for now, as
108+
we won't need it anymore.
109+
110+
```sh
111+
rm config.json
112+
```
113+
114+
## Set up the database
115+
116+
Apollo uses MongoDB to store its data. In this example we'll set up MongoDB
117+
running on the same server as everything else, but it could just as easily be an
118+
externally managed database.
119+
120+
These installation instructions for MongoDB are based on
121+
[the installation instructions](https://www.mongodb.com/docs/manual/tutorial/install-mongodb-on-ubuntu/)
122+
in the MongoDB documentation.
123+
124+
MongoDB is not available for `apt` to install by default, so we'll need to do
125+
some configuration to enable that. First we'll need to install `gnupg` and use
126+
it to import the MongoDB public key.
127+
128+
```sh
129+
curl -fsSL https://www.mongodb.org/static/pgp/server-8.0.asc | sudo gpg -o /usr/share/keyrings/mongodb-server-8.0.gpg --dearmor
130+
```
131+
132+
Now we can configure `apt` to be able to find MongoDB
133+
134+
```sh
135+
echo "deb [ arch=amd64,arm64 signed-by=/usr/share/keyrings/mongodb-server-8.0.gpg ] https://repo.mongodb.org/apt/ubuntu noble/mongodb-org/8.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-8.0.list
136+
sudo apt update
137+
```
138+
139+
And now install MongoDB
140+
141+
```sh
142+
sudo apt install -y mongodb-org
143+
```
144+
145+
Apollo requires MongoDB to be configured in a replica set configuration. You can
146+
have multiple replicas of your database, but in this example we'll use a single
147+
one. To configure this, we'll edit the file `/etc/mongod.conf`.
148+
149+
```sh
150+
sudo nano /etc/mongod.conf
151+
```
152+
153+
In the file where it says `# replication`, change it to
154+
155+
```conf
156+
replication:
157+
replSetName: rs0
158+
```
159+
160+
Now we can start MongoDB by running
161+
162+
```sh
163+
sudo systemctl start mongod
164+
```
165+
166+
The last step is to initialize the replica set. To do this, run the command
167+
`mongosh` and in the shell that appears, run the command
168+
169+
```js
170+
rs.initiate()
171+
```
172+
173+
Then press <kbd>Ctrl</kbd> + <kbd>D</kbd> or run the `exit` command to exit the
174+
mongosh shell.
175+
176+
## Set up Apollo Collaboration Server
177+
178+
The first step in setting up the collaboration server is to further configure
179+
the apache2 server we installed when setting up JBrowse. We're going to use
180+
apache2 as a "gateway" (a.k.a. "forward and reverse proxy") server. This is so
181+
that the same server can handle requests for the JBrowse static files and
182+
forward requests for the Apollo Collaboration Server to our running server
183+
process (which we will set up shortly). It does this by inspecting the request
184+
and if the path starts with `apollo/` or is for `config.json`, it forwards the
185+
request to the Apollo Collaboration Server, otherwise it handles the request as
186+
a static file server.
187+
188+
To set this up, we first need to enable some mods on our apache2 server.
189+
190+
```sh
191+
sudo a2enmod proxy
192+
sudo a2enmod proxy_http
193+
sudo a2enmod proxy_wstunnel
194+
```
195+
196+
Now we'll configure the proxy by editing the file
197+
`/etc/apache2/sites-available/000-default.conf`.
198+
199+
```sh
200+
sudo nano /etc/apache2/sites-available/000-default.conf
201+
```
202+
203+
Add these lines near the bottom of the file, above the `</VirtualHost>` line.
204+
205+
```txt
206+
ProxyPass "/config.json" "http://localhost:3999/jbrowse/config.json"
207+
ProxyPassReverse "/config.json" "http://localhost:3999/jbrowse/config.json"
208+
ProxyPassMatch "^/apollo/(.*)$" "http://localhost:3999/$1" upgrade=websocket connectiontimeout=3600 timeout=3600
209+
ProxyPassReverse "/apollo/" "http://localhost:3999/"
210+
```
211+
212+
Now we need to restart the apache2 server.
213+
214+
```sh
215+
sudo systemctl restart apache2
216+
```
217+
218+
The next thing we need to do is add a file that defines feature types for
219+
Apollo. This is usally the Sequence Ontology.
220+
221+
```sh
222+
cd /var/www/html/
223+
curl -fsSL https://github.com/The-Sequence-Ontology/SO-Ontologies/raw/refs/heads/master/Ontology_Files/so.json > sequence_ontology.json
224+
```
225+
226+
Now we need to install Node.js on the server. The default Node.js available via
227+
`apt` can have some problems, so we'll configure `apt` to install a different
228+
version.
229+
230+
```sh
231+
curl -fsSL https://deb.nodesource.com/setup_20.x | sudo bash -
232+
sudo apt install -y nodejs
233+
```
234+
235+
Now we'll fetch the Apollo installation files.
236+
237+
```sh
238+
cd ~
239+
curl -fsSL https://api.github.com/repos/GMOD/Apollo3/releases/latest > apollo.json
240+
TARBALL_URL=$(jq -r '.tarball_url' apollo.json)
241+
curl -fsSL ${TARBALL_URL} > apollo.tar.gz
242+
tar xvf apollo.tar.gz
243+
rm apollo.tar.gz apollo.json
244+
mv GMOD-Apollo3-*/ Apollo/
245+
```
246+
247+
To install Apollo, we'll need the tool `yarn`, which can be enabled through
248+
Node.js by running
249+
250+
```sh
251+
sudo corepack enable
252+
```
253+
254+
Then install and build Apollo by running
255+
256+
```sh
257+
cd Apollo/
258+
yarn # Need to answer "Y" to allow Corepack to download yarn
259+
cd packages/apollo-collaboration-server/
260+
yarn build
261+
```
262+
263+
Now that Apollo is installed, we need to configure it before starting it. We can
264+
do that by adding a file called `.env` in the
265+
`packages/apollo-collaboration-server/` directory (e.g. by using `nano`) and
266+
adding these contents to that file. Note that for "URL", you should put the URL
267+
for your server, followed by `/apollo/`.
268+
269+
```env
270+
URL=<forwarded address>/apollo/
271+
NAME=My Apollo Instance
272+
MONGODB_URI=mongodb://localhost:27017/apolloDb?directConnection=true&replicaSet=rs0
273+
FILE_UPLOAD_FOLDER=/home/ubuntu/data/uploads
274+
JWT_SECRET=some-secret-value
275+
SESSION_SECRET=some-other-secret-value
276+
ALLOW_ROOT_USER=true
277+
ROOT_USER_PASSWORD=some-secret-password
278+
ALLOW_GUEST_USER=true
279+
GUEST_USER_ROLE=admin
280+
```
281+
282+
You can find more configuration options in the
283+
[Apollo docs](https://apollo.jbrowse.org/docs/getting-started/deployment/configuration-options).
284+
285+
Now we can start Apollo by running
286+
287+
```sh
288+
yarn start:prod
289+
```
290+
291+
Open the URL of your server. Open an "Empty" session, and then choose "Continue
292+
as Guest" in the dialog that appears.
293+
294+
![Login dialog](img/apollo_login.png)
295+
296+
Congratulations, Apollo is now ready to use!
11 KB
Loading
15.2 KB
Loading
15.7 KB
Loading
63.5 KB
Loading

0 commit comments

Comments
 (0)