Skip to content

Commit a2453b3

Browse files
update deployment documentation (#1277)
* describe how to use railway instead of heroku * use voila palette for documentation * indentation issue in docs --------- Co-authored-by: martinRenou <[email protected]>
1 parent 1fa960a commit a2453b3

File tree

2 files changed

+115
-100
lines changed

2 files changed

+115
-100
lines changed

docs/source/_static/main_stylesheet.css

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,12 @@
66
.wy-nav-content img {
77
margin: 5px auto 25px;
88
}
9+
10+
/*use voila palette for title coloring*/
11+
html[data-theme="light"] {
12+
--pst-color-primary: #5dbcaf;
13+
}
14+
15+
html[data-theme="dark"] {
16+
--pst-color-primary: #5dbcaf;
17+
}

docs/source/deploy.rst

Lines changed: 106 additions & 100 deletions
Original file line numberDiff line numberDiff line change
@@ -81,41 +81,48 @@ Customizing Voilà on Binder
8181
To specify different options (such as the theme and template), create a
8282
``jupyter_config.json`` file at the root of the repository with the following content:
8383

84-
.. code:: json
84+
.. code:: json
8585
86-
{
87-
"VoilaConfiguration": {
88-
"theme": "dark",
89-
"template": "gridstack"
90-
}
91-
}
86+
{
87+
"VoilaConfiguration": {
88+
"theme": "dark",
89+
"template": "gridstack"
90+
}
91+
}
9292
9393
9494
An example can be found in the
9595
`voila-demo <https://github.com/maartenbreddels/voila-demo>`__ repository.
9696

9797

98-
Deployment on Heroku
99-
--------------------
98+
Deployment on Railway
99+
---------------------
100+
101+
.. note::
100102

101-
Heroku.com is an attractive option if you want to try out deployment for
102-
free. You have limited computing hours, however the app will also
103-
automatically shutdown if it is idle.
103+
Heroku.com was the suggested option for free deployment but since `November 28th 2022 <https://help.heroku.com/RSBRUH58/removal-of-heroku-free-product-plans-faq>`__, free
104+
product plans have been removed from the platform. The process described in
105+
this section remain valid for other services.
104106

105-
The general steps for deployment at Heroku can be found
106-
`here <https://devcenter.heroku.com/articles/getting-started-with-python>`__.
107+
`Railway.app <https://railway.app>`__ is an attractive option if you want to try
108+
out deployment for free. You have limited computing hours, however the app will
109+
also automatically shutdown if it is idle.
110+
111+
The general steps for deployment at Railway can be found
112+
`here <https://nixpacks.com/docs/providers/python>`__.
107113
High level instructions, specific to Voilà can be found below:
108114

109-
1. Follow the steps of the official documentation to install the heroku
110-
cli and login on your machine.
111-
2. Add a file named runtime.txt to the project directory with a
115+
1. Follow the steps of the official documentation to install the Railway
116+
CLI and login on your machine.
117+
118+
2. Add a file named runtime.txt to the project directory with a
112119
`valid Python runtime <https://devcenter.heroku.com/articles/python-support#supported-runtimes>`__:
113120

114121
.. code:: text
115122
116123
python-3.10.4
117124
118-
3. Add a file named Procfile to the project directory with the
125+
3. Add a file named ``Procfile`` to the project directory with the
119126
following content if you want to show all notebooks:
120127

121128
.. code:: text
@@ -128,7 +135,7 @@ High level instructions, specific to Voilà can be found below:
128135
129136
web: voila --port=$PORT --no-browser --Voila.ip=0.0.0.0 your_notebook.ipynb
130137
131-
4. Initialize your git repo and commit your code. At minimum you need to commit
138+
4. Initialize a git repo and commit your code. At minimum you need to commit
132139
your notebooks, requirements.txt, runtime.txt, and the Procfile.
133140

134141
.. code:: bash
@@ -137,24 +144,23 @@ High level instructions, specific to Voilà can be found below:
137144
git add <your-files>
138145
git commit -m "my message"
139146
140-
5. Create an Heroku instance and push the code.
147+
5. Create an Railway instance and push the code.
141148

142149
.. code:: bash
143150
144-
heroku create
145-
git push heroku master
151+
railway init
146152
147153
6. Open your web app
148154

149155
.. code:: bash
150156
151-
heroku open
157+
railway up --detach
152158
153159
To resolve issues, it is useful to see the logs of your application. You can do this by running:
154160

155-
.. code:: bash
161+
.. code:: bash
156162
157-
heroku logs --tail
163+
railway up
158164
159165
160166
Deployment on Google App Engine
@@ -218,96 +224,96 @@ Steps
218224

219225
1. SSH into the server:
220226

221-
.. code:: text
227+
.. code:: text
222228
223-
ssh ubuntu@<ip-address>
229+
ssh ubuntu@<ip-address>
224230
225231
2. Install nginx:
226232

227-
.. code:: text
233+
.. code:: text
228234
229-
sudo apt install nginx
235+
sudo apt install nginx
230236
231237
3. To check that ``nginx`` is correctly installed:
232238

233-
.. code:: text
239+
.. code:: text
234240
235-
sudo systemctl status nginx
241+
sudo systemctl status nginx
236242
237243
4. Create the file ``/etc/nginx/sites-enabled/yourdomain.com`` with the following content:
238244

239-
.. code:: text
245+
.. code:: text
240246
241-
server {
242-
listen 80;
243-
server_name yourdomain.com;
244-
proxy_buffering off;
245-
location / {
246-
proxy_pass http://localhost:8866;
247-
proxy_set_header Host $host;
248-
proxy_set_header X-Real-IP $remote_addr;
249-
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
250-
251-
proxy_http_version 1.1;
252-
proxy_set_header Upgrade $http_upgrade;
253-
proxy_set_header Connection "upgrade";
254-
proxy_read_timeout 86400;
255-
}
256-
257-
client_max_body_size 100M;
258-
error_log /var/log/nginx/error.log;
259-
}
247+
server {
248+
listen 80;
249+
server_name yourdomain.com;
250+
proxy_buffering off;
251+
location / {
252+
proxy_pass http://localhost:8866;
253+
proxy_set_header Host $host;
254+
proxy_set_header X-Real-IP $remote_addr;
255+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
256+
257+
proxy_http_version 1.1;
258+
proxy_set_header Upgrade $http_upgrade;
259+
proxy_set_header Connection "upgrade";
260+
proxy_read_timeout 86400;
261+
}
262+
263+
client_max_body_size 100M;
264+
error_log /var/log/nginx/error.log;
265+
}
260266
261267
5. Enable and start the ``nginx`` service:
262268

263-
.. code:: text
269+
.. code:: text
264270
265-
sudo systemctl enable nginx.service
266-
sudo systemctl start nginx.service
271+
sudo systemctl enable nginx.service
272+
sudo systemctl start nginx.service
267273
268274
6. Install pip:
269275

270-
.. code:: text
276+
.. code:: text
271277
272-
sudo apt update && sudo apt install python3-pip
278+
sudo apt update && sudo apt install python3-pip
273279
274280
7. Follow the instructions in `Setup an example project`_, and install the dependencies:
275281

276-
.. code:: text
277-
278-
sudo python3 -m pip install -r requirements.txt
279-
280-
8. Create a new systemd service for running Voilà in ``/usr/lib/systemd/system/voila.service``.
281-
The service will ensure Voilà is automatically restarted on startup:
282+
.. code:: text
282283
283-
.. code:: text
284+
sudo python3 -m pip install -r requirements.txt
284285
285-
[Unit]
286-
Description=Voila
286+
8. Create a new systemd service for running Voilà in ``/usr/lib/systemd/system/voila.service``. The service will ensure Voilà is automatically restarted on startup:
287287

288-
[Service]
289-
Type=simple
290-
PIDFile=/run/voila.pid
291-
ExecStart=voila --no-browser voila/notebooks/basics.ipynb
292-
User=ubuntu
293-
WorkingDirectory=/home/ubuntu/
294-
Restart=always
295-
RestartSec=10
288+
.. code:: text
296289
297-
[Install]
298-
WantedBy=multi-user.target
290+
[Unit]
291+
Description=Voila
292+
293+
[Service]
294+
Type=simple
295+
PIDFile=/run/voila.pid
296+
ExecStart=voila --no-browser voila/notebooks/basics.ipynb
297+
User=ubuntu
298+
WorkingDirectory=/home/ubuntu/
299+
Restart=always
300+
RestartSec=10
301+
302+
[Install]
303+
WantedBy=multi-user.target
299304
300305
In this example Voilà is started with ``voila --no-browser voila/notebooks/basics.ipynb`` to serve a single notebook.
301306
You can edit the command to change this behavior and the notebooks Voilà is serving.
302307

303308
9. Enable and start the ``voila`` service:
304309

305-
.. code:: text
310+
.. code:: text
306311
307-
sudo systemctl enable voila.service
308-
sudo systemctl start voila.service
312+
sudo systemctl enable voila.service
313+
sudo systemctl start voila.service
309314
310315
.. note::
316+
311317
To check the logs for Voilà:
312318

313319
.. code:: text
@@ -322,45 +328,45 @@ Enable HTTPS with Let's Encrypt
322328

323329
1. Install ``certbot``:
324330

325-
.. code:: text
331+
.. code:: text
326332
327-
sudo add-apt-repository ppa:certbot/certbot
328-
sudo apt update
329-
sudo apt install python-certbot-nginx
333+
sudo add-apt-repository ppa:certbot/certbot
334+
sudo apt update
335+
sudo apt install python-certbot-nginx
330336
331337
2. Obtain the certificates from Let's Encrypt. The ``--nginx`` flag will edit the nginx configuration automatically:
332338

333-
.. code:: text
334-
335-
sudo certbot --nginx -d yourdomain.com
339+
.. code:: text
340+
341+
sudo certbot --nginx -d yourdomain.com
336342
337343
3. ``/etc/nginx/sites-enabled/yourdomain.com`` should now contain a few more entries:
338344

339-
.. code :: text
340-
341-
$ cat /etc/nginx/sites-enabled/yourdomain.com
345+
.. code :: text
342346
343-
...
344-
listen 443 ssl; # managed by Certbot
345-
ssl_certificate /etc/letsencrypt/live/yourdomain.com/fullchain.pem; # managed by Certbot
346-
ssl_certificate_key /etc/letsencrypt/live/yourdomain.com/privkey.pem; # managed by Certbot
347-
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
348-
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
349-
...
347+
$ cat /etc/nginx/sites-enabled/yourdomain.com
348+
349+
...
350+
listen 443 ssl; # managed by Certbot
351+
ssl_certificate /etc/letsencrypt/live/yourdomain.com/fullchain.pem; # managed by Certbot
352+
ssl_certificate_key /etc/letsencrypt/live/yourdomain.com/privkey.pem; # managed by Certbot
353+
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
354+
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
355+
...
350356
351357
4. Visit ``yourdomain.com`` to access the Voilà applications over HTTPS.
352358

353359
5. To automatically renew the certificates (they expire after 90 days), open the ``crontab`` file:
354360

355-
.. code :: text
361+
.. code :: text
356362
357-
crontab -e
363+
crontab -e
358364
359-
And add the following line:
365+
And add the following line:
360366

361-
.. code :: text
367+
.. code :: text
362368
363-
0 12 * * * /usr/bin/certbot renew --quiet
369+
0 12 * * * /usr/bin/certbot renew --quiet
364370
365371
For more information, you can also follow `the guide on the nginx blog <https://www.nginx.com/blog/using-free-ssltls-certificates-from-lets-encrypt-with-nginx/>`__.
366372

0 commit comments

Comments
 (0)