Skip to content

Commit 04ffda8

Browse files
committed
Update README and add deployment instructions
1 parent a7a4e30 commit 04ffda8

File tree

2 files changed

+115
-0
lines changed

2 files changed

+115
-0
lines changed

DEPLOYMENT.md

+111
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
## 1. Start a new droplet with the pre-installed Ruby
2+
3+
* Navigate to the Digital Ocean dashboard and choose the appropriate project from the left menu.
4+
* Click on _Create > Droplets_ to initiate the setup process.
5+
6+
![Screenshot 2024-02-16 at 11 22 56](https://github.com/vault12/zax/assets/1370944/b1dfd86f-63a5-49bb-939d-a2148bbe4a64)
7+
8+
* Under _Choose an Image_, select _Marketplace_ and then opt for the _Ruby On Rails_ image. Ensure it's the appropriate version (e.g., Version 7.0.4.2, OS Ubuntu 22.04).
9+
10+
![Screenshot 2024-02-16 at 11 24 53](https://github.com/vault12/zax/assets/1370944/5009c912-e256-4c48-8590-14572d98facf)
11+
12+
* For authentication, choose the _SSH Key_ option and select your preferred SSH key.
13+
* Click _Create Droplet_ and patiently wait for the droplet to be provisioned.
14+
* You can find more details about the package on the [Ruby on Rails Droplet](https://marketplace.digitalocean.com/apps/ruby-on-rails) page.
15+
16+
## 2. SSH into the Droplet
17+
18+
Once the droplet is ready, access it via SSH using the following command:
19+
20+
```bash
21+
ssh root@your_droplet_ip
22+
```
23+
24+
Replace `your_droplet_ip` with the actual IP address of your newly created droplet.
25+
26+
## 3. Install Redis
27+
28+
Install Redis on the server by following the Digital Ocean guide [How To Install and Secure Redis on Ubuntu 20.04](https://www.digitalocean.com/community/tutorials/how-to-install-and-secure-redis-on-ubuntu-20-04). Here are the summarized steps:
29+
30+
* **Install Redis package**. Run `apt install redis-server`.
31+
* **Update Redis configuration**. Edit `/etc/redis/redis.conf` and set the `supervised` directive to `systemd`.
32+
* **Restart Redis service**. Run `systemctl restart redis.service` to apply the changes.
33+
34+
## 4. Install and configure Zax
35+
36+
* In the SSH console, sign in as the predefined **rails** user:
37+
38+
```bash
39+
su - rails
40+
```
41+
42+
* Clone [Zax repository](https://github.com/vault12/zax), navigate into the directory and run the script to install dependencies:
43+
44+
```bash
45+
git clone https://github.com/vault12/zax.git
46+
cd zax
47+
./install_dependencies.sh
48+
```
49+
50+
* Whitelist your hostname for production use
51+
52+
By default, Rails 6 applications reject all requests that are not made to the configured host. So you need to uncomment and modify line 11 in the [production configuration file](https://github.com/vault12/zax/blob/main/config/environments/production.rb#L11) `config/environments/production.rb`, uncomment the following line and insert your own URL to allow access to the app from your host:
53+
54+
```ruby
55+
config.hosts << "zax.example.com" # use your host name
56+
```
57+
58+
* Disable Zax Dashboard to serve as frontend (optional)
59+
60+
If you want to disable access to the [Zax Dashboard](https://github.com/vault12/zax-dashboard) which provides a convenient UI, set the `public_file_server` variable on line 64 in the [production configuration file](https://github.com/vault12/zax/blob/main/config/environments/production.rb#L64) (`config/environments/production.rb`) to `false`. This action will prevent the Ruby server from serving files from the `public/` directory.
61+
62+
```ruby
63+
config.public_file_server.enabled = false
64+
```
65+
66+
* Exit from the **rails** user session by entering `exit`.
67+
68+
## 4. Modify Rails service to serve Zax
69+
70+
* Open `/etc/systemd/system/rails.service` and update the `WorkingDirectory` and `ExecStart` directives as follows:
71+
72+
```bash
73+
WorkingDirectory=/home/rails/zax/
74+
ExecStart=/bin/bash -lc 'rails s --binding=localhost --environment production'
75+
```
76+
77+
Save the changes and exit the editor.
78+
79+
## 5. Add a DNS record for your domain with your registrar
80+
81+
To configure DNS for your domain, log in to your domain registrar's website and access the DNS management section. Add an A record by specifying your domain name and your droplet's IP address. Save the changes and wait for DNS propagation, which may take some time.
82+
83+
## 6. Configure Nginx and secure it with Let's Encrypt
84+
85+
* **Edit the Nginx configuration file**. In `/etc/nginx/sites-available/rails`), replace `server_name _;` with the correct host name (e.g. `server_name zax.example.com;`).
86+
87+
* **Secure Nginx with Let's Encrypt**. Follow the instructions in the Digital Ocean tutorial [How To Secure Nginx with Let's Encrypt on Ubuntu 20.04](https://www.digitalocean.com/community/tutorials/how-to-secure-nginx-with-let-s-encrypt-on-ubuntu-20-04) to obtain and install SSL/TLS certificates for your domain. Here are the summarized steps:
88+
89+
1. Allow `Nginx Full` through the firewall and delete the rule for `Nginx HTTP`:
90+
91+
```bash
92+
ufw allow 'Nginx Full'
93+
ufw delete allow 'Nginx HTTP'
94+
```
95+
96+
2. Obtain SSL certificate using Certbot with Nginx plugin:
97+
98+
```bash
99+
certbot --nginx -d zax.example.com
100+
```
101+
102+
3. Reload the systemd daemon and restart the Rails service to apply the changes:
103+
104+
```bash
105+
systemctl daemon-reload
106+
systemctl restart rails.service
107+
```
108+
109+
## 7. Verify the installation
110+
111+
Open https://zax.example.com in your browser to ensure Zax Dashboard is served over HTTPS.

README.md

+4
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,10 @@ To make Zax accept connections from all hosts:
132132
rails s -p 8080 --binding=0.0.0.0
133133
```
134134

135+
#### Deployment
136+
137+
For instructions on deploying a custom Zax relay node on [Digital Ocean](https://www.digitalocean.com), refer to [DEPLOYMENT.md](DEPLOYMENT.md).
138+
135139
#### Testing Zax
136140

137141
To test groups of tests you can run any of these commands:

0 commit comments

Comments
 (0)