Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update dependencies and add deployment instructions #61

Merged
merged 3 commits into from
Sep 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## [3.0.1] - 2024-09-23

- Upgraded Rails to version 7.0.8.4
- Added deployment instructions for a custom Zax relay node on [DigitalOcean](https://www.digitalocean.com)
- Updated to the latest versions of Zax Dashboard and refreshed other dependencies

## [3.0.0] - 2024-09-02

- Upgraded to Ruby 3.2
Expand Down
111 changes: 111 additions & 0 deletions DEPLOYMENT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
## 1. Start a new droplet with the pre-installed Ruby

* Navigate to the Digital Ocean dashboard and choose the appropriate project from the left menu.
* Click on _Create > Droplets_ to initiate the setup process.

![Screenshot 2024-02-16 at 11 22 56](https://github.com/vault12/zax/assets/1370944/b1dfd86f-63a5-49bb-939d-a2148bbe4a64)

* 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).

![Screenshot 2024-02-16 at 11 24 53](https://github.com/vault12/zax/assets/1370944/5009c912-e256-4c48-8590-14572d98facf)

* For authentication, choose the _SSH Key_ option and select your preferred SSH key.
* Click _Create Droplet_ and patiently wait for the droplet to be provisioned.
* You can find more details about the package on the [Ruby on Rails Droplet](https://marketplace.digitalocean.com/apps/ruby-on-rails) page.

## 2. SSH into the Droplet

Once the droplet is ready, access it via SSH using the following command:

```bash
ssh root@your_droplet_ip
```

Replace `your_droplet_ip` with the actual IP address of your newly created droplet.

## 3. Install Redis

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:

* **Install Redis package**. Run `apt install redis-server`.
* **Update Redis configuration**. Edit `/etc/redis/redis.conf` and set the `supervised` directive to `systemd`.
* **Restart Redis service**. Run `systemctl restart redis.service` to apply the changes.

## 4. Install and configure Zax

* In the SSH console, sign in as the predefined **rails** user:

```bash
su - rails
```

* Clone [Zax repository](https://github.com/vault12/zax), navigate into the directory and run the script to install dependencies:

```bash
git clone https://github.com/vault12/zax.git
cd zax
./install_dependencies.sh
```

* Whitelist your hostname for production use

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:

```ruby
config.hosts << "zax.example.com" # use your host name
```

* Disable Zax Dashboard to serve as frontend (optional)

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.

```ruby
config.public_file_server.enabled = false
```

* Exit from the **rails** user session by entering `exit`.

## 4. Modify Rails service to serve Zax

* Open `/etc/systemd/system/rails.service` and update the `WorkingDirectory` and `ExecStart` directives as follows:

```bash
WorkingDirectory=/home/rails/zax/
ExecStart=/bin/bash -lc 'rails s --binding=localhost --environment production'
```

Save the changes and exit the editor.

## 5. Add a DNS record for your domain with your registrar

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.

## 6. Configure Nginx and secure it with Let's Encrypt

* **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;`).

* **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:

1. Allow `Nginx Full` through the firewall and delete the rule for `Nginx HTTP`:

```bash
ufw allow 'Nginx Full'
ufw delete allow 'Nginx HTTP'
```

2. Obtain SSL certificate using Certbot with Nginx plugin:

```bash
certbot --nginx -d zax.example.com
```

3. Reload the systemd daemon and restart the Rails service to apply the changes:

```bash
systemctl daemon-reload
systemctl restart rails.service
```

## 7. Verify the installation

Open https://zax.example.com in your browser to ensure Zax Dashboard is served over HTTPS.
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
source 'https://rubygems.org'

gem 'rails', '7.0.7.2'
gem 'rails', '7.0.8.4'

gem 'puma'
# gem "sprockets-rails"
Expand Down
156 changes: 78 additions & 78 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,155 +1,155 @@
GEM
remote: https://rubygems.org/
specs:
actioncable (7.0.7.2)
actionpack (= 7.0.7.2)
activesupport (= 7.0.7.2)
actioncable (7.0.8.4)
actionpack (= 7.0.8.4)
activesupport (= 7.0.8.4)
nio4r (~> 2.0)
websocket-driver (>= 0.6.1)
actionmailbox (7.0.7.2)
actionpack (= 7.0.7.2)
activejob (= 7.0.7.2)
activerecord (= 7.0.7.2)
activestorage (= 7.0.7.2)
activesupport (= 7.0.7.2)
actionmailbox (7.0.8.4)
actionpack (= 7.0.8.4)
activejob (= 7.0.8.4)
activerecord (= 7.0.8.4)
activestorage (= 7.0.8.4)
activesupport (= 7.0.8.4)
mail (>= 2.7.1)
net-imap
net-pop
net-smtp
actionmailer (7.0.7.2)
actionpack (= 7.0.7.2)
actionview (= 7.0.7.2)
activejob (= 7.0.7.2)
activesupport (= 7.0.7.2)
actionmailer (7.0.8.4)
actionpack (= 7.0.8.4)
actionview (= 7.0.8.4)
activejob (= 7.0.8.4)
activesupport (= 7.0.8.4)
mail (~> 2.5, >= 2.5.4)
net-imap
net-pop
net-smtp
rails-dom-testing (~> 2.0)
actionpack (7.0.7.2)
actionview (= 7.0.7.2)
activesupport (= 7.0.7.2)
actionpack (7.0.8.4)
actionview (= 7.0.8.4)
activesupport (= 7.0.8.4)
rack (~> 2.0, >= 2.2.4)
rack-test (>= 0.6.3)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.2.0)
actiontext (7.0.7.2)
actionpack (= 7.0.7.2)
activerecord (= 7.0.7.2)
activestorage (= 7.0.7.2)
activesupport (= 7.0.7.2)
actiontext (7.0.8.4)
actionpack (= 7.0.8.4)
activerecord (= 7.0.8.4)
activestorage (= 7.0.8.4)
activesupport (= 7.0.8.4)
globalid (>= 0.6.0)
nokogiri (>= 1.8.5)
actionview (7.0.7.2)
activesupport (= 7.0.7.2)
actionview (7.0.8.4)
activesupport (= 7.0.8.4)
builder (~> 3.1)
erubi (~> 1.4)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.1, >= 1.2.0)
activejob (7.0.7.2)
activesupport (= 7.0.7.2)
activejob (7.0.8.4)
activesupport (= 7.0.8.4)
globalid (>= 0.3.6)
activemodel (7.0.7.2)
activesupport (= 7.0.7.2)
activerecord (7.0.7.2)
activemodel (= 7.0.7.2)
activesupport (= 7.0.7.2)
activestorage (7.0.7.2)
actionpack (= 7.0.7.2)
activejob (= 7.0.7.2)
activerecord (= 7.0.7.2)
activesupport (= 7.0.7.2)
activemodel (7.0.8.4)
activesupport (= 7.0.8.4)
activerecord (7.0.8.4)
activemodel (= 7.0.8.4)
activesupport (= 7.0.8.4)
activestorage (7.0.8.4)
actionpack (= 7.0.8.4)
activejob (= 7.0.8.4)
activerecord (= 7.0.8.4)
activesupport (= 7.0.8.4)
marcel (~> 1.0)
mini_mime (>= 1.1.0)
activesupport (7.0.7.2)
activesupport (7.0.8.4)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (>= 1.6, < 2)
minitest (>= 5.1)
tzinfo (~> 2.0)
ansi (1.5.0)
base32 (0.3.4)
builder (3.2.4)
builder (3.3.0)
coderay (1.1.3)
concurrent-ruby (1.2.2)
concurrent-ruby (1.3.4)
connection_pool (2.4.1)
crass (1.0.6)
date (3.3.3)
erubi (1.12.0)
date (3.3.4)
erubi (1.13.0)
ffi (1.15.5)
globalid (1.1.0)
activesupport (>= 5.0)
i18n (1.14.1)
globalid (1.2.1)
activesupport (>= 6.1)
i18n (1.14.6)
concurrent-ruby (~> 1.0)
kgio (2.11.4)
loofah (2.21.3)
loofah (2.22.0)
crass (~> 1.0.2)
nokogiri (>= 1.12.0)
mail (2.8.1)
mini_mime (>= 0.1.1)
net-imap
net-pop
net-smtp
marcel (1.0.2)
method_source (1.0.0)
marcel (1.0.4)
method_source (1.1.0)
mini_mime (1.1.5)
mini_portile2 (2.8.6)
minitest (5.19.0)
mini_portile2 (2.8.7)
minitest (5.25.1)
minitest-reporters (1.6.1)
ansi
builder
minitest (>= 5.0)
ruby-progressbar
net-imap (0.3.7)
net-imap (0.4.16)
date
net-protocol
net-pop (0.1.2)
net-protocol
net-protocol (0.2.1)
net-protocol (0.2.2)
timeout
net-smtp (0.3.3)
net-smtp (0.5.0)
net-protocol
nio4r (2.7.0)
nokogiri (1.16.5)
nio4r (2.7.3)
nokogiri (1.16.7)
mini_portile2 (~> 2.8.2)
racc (~> 1.4)
pry (0.14.2)
coderay (~> 1.1)
method_source (~> 1.0)
puma (6.4.2)
puma (6.4.3)
nio4r (~> 2.0)
racc (1.7.3)
rack (2.2.8.1)
racc (1.8.1)
rack (2.2.9)
rack-test (2.1.0)
rack (>= 1.3)
rails (7.0.7.2)
actioncable (= 7.0.7.2)
actionmailbox (= 7.0.7.2)
actionmailer (= 7.0.7.2)
actionpack (= 7.0.7.2)
actiontext (= 7.0.7.2)
actionview (= 7.0.7.2)
activejob (= 7.0.7.2)
activemodel (= 7.0.7.2)
activerecord (= 7.0.7.2)
activestorage (= 7.0.7.2)
activesupport (= 7.0.7.2)
rails (7.0.8.4)
actioncable (= 7.0.8.4)
actionmailbox (= 7.0.8.4)
actionmailer (= 7.0.8.4)
actionpack (= 7.0.8.4)
actiontext (= 7.0.8.4)
actionview (= 7.0.8.4)
activejob (= 7.0.8.4)
activemodel (= 7.0.8.4)
activerecord (= 7.0.8.4)
activestorage (= 7.0.8.4)
activesupport (= 7.0.8.4)
bundler (>= 1.15.0)
railties (= 7.0.7.2)
railties (= 7.0.8.4)
rails-dom-testing (2.2.0)
activesupport (>= 5.0.0)
minitest
nokogiri (>= 1.6)
rails-html-sanitizer (1.6.0)
loofah (~> 2.21)
nokogiri (~> 1.14)
railties (7.0.7.2)
actionpack (= 7.0.7.2)
activesupport (= 7.0.7.2)
railties (7.0.8.4)
actionpack (= 7.0.8.4)
activesupport (= 7.0.8.4)
method_source
rake (>= 12.2)
thor (~> 1.0)
zeitwerk (~> 2.5)
rake (13.0.6)
rake (13.2.1)
rbnacl (7.1.1)
ffi
redis (5.0.7)
Expand All @@ -174,14 +174,14 @@ GEM
redis (>= 4, < 6)
ruby-progressbar (1.13.0)
spring (4.1.1)
thor (1.2.2)
timeout (0.4.0)
thor (1.3.2)
timeout (0.4.1)
tzinfo (2.0.6)
concurrent-ruby (~> 1.0)
websocket-driver (0.7.6)
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.5)
zeitwerk (2.6.11)
zeitwerk (2.6.18)

PLATFORMS
ruby
Expand All @@ -192,7 +192,7 @@ DEPENDENCIES
minitest-reporters
pry (~> 0.14.2)
puma
rails (= 7.0.7.2)
rails (= 7.0.8.4)
rbnacl
redis
redis-rails
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,10 @@ To make Zax accept connections from all hosts:
rails s -p 8080 --binding=0.0.0.0
```

#### Deployment

For instructions on deploying a custom Zax relay node on [Digital Ocean](https://www.digitalocean.com), refer to [DEPLOYMENT.md](DEPLOYMENT.md).

#### Testing Zax

To test groups of tests you can run any of these commands:
Expand Down
Loading