Created Install Tracks 2.5.1 on Ubuntu 20.04 LTS on AWS with SSL support (markdown)

Ivan Habernal 2021-07-31 15:10:07 +02:00
parent 9228db0732
commit fb2134260a

@ -0,0 +1,108 @@
Installing Tracks 2.5.1 on a clean server (Ubuntu 20.04 LTS) running on Amazon Web Services with a Let's encrypt SSL certificate for a secure HTTPS access.
## Install all required dependencies
```bash
$ sudo apt-get install git nano wget ruby ruby-dev build-essential libsqlite3-dev shared-mime-info -y
```
This command has also installed a default `bundler` but we have to replace it with a newer version due to a [bug in the package served with Ubuntu](https://bugs.launchpad.net/ubuntu/+source/ruby-thor/+bug/1885424).
```bash
$ bundler2.7 --version
Bundler version 2.1.2
```
Install a newer version
```bash
$ sudo gem install bundler
Fetching bundler-2.2.25.gem
```
So now we have a newer version installed
```bash
$ bundle --version
Bundler version 2.2.25
```
## Download tracks
```bash
$ wget https://github.com/TracksApp/tracks/archive/v2.5.1.zip
$ unzip v2.5.1.zip
$ cd tracks-2.5.1/
$ rm Gemfile.lock
```
Edit `Gemfile`, I'm using `nano`
```bash
$ nano Gemfile
```
Comment out unused backends
```
# gem "mysql2", "~> 0.5.3", group: :mysql
# gem "pg", "~> 1.2.3", group: :postgresql
```
```bash
$ cp config/database.yml.tmpl config/database.yml
$ nano config/database.yml
```
Change to use `sqlite` backend
```
production:
# adapter: mysql2
# database: tracks
# set this if you are storing utf8 in your mysql database to handle strings
# like "Réné".Not needed for sqlite. For PostgreSQL use encoding: unicode
# encoding: utf8
# host: localhost
# username: root
# password:
# The following is an example to configure Tracks to use sqlite
#production:
adapter: sqlite3
database: db/tracks-20-blank.sqlite3.db
pool: 5
timeout: 5000
```
```bash
$ cp config/site.yml.tmpl config/site.yml
$ nano config/site.yml
```
Change `change-me` in `secret_token` to some random value. Then compile packages (takes some time).
## Install using bundler
We will be installing all Ruby packages into this local folder for not messing up with other possible system-wider libraries
```bash
$ bundle config set --local path 'vendor/bundle'
$ export RAILS_SERVE_STATIC_FILES=true
$ bundle install
```
Compile static assets
```bash
$ bundle exec rake assets:precompile RAILS_ENV=production
```
I have the following script for launching Tracks properly with SSL:
```
#!/bin/sh
export RAILS_SERVE_STATIC_FILES=true
bundle exec puma -e production -b 'ssl://0.0.0.0:3000?key=/etc/letsencrypt/live/myserver.com/privkey.pem&cert=/etc/letsencrypt/live/myserver.com/cert.pem'
```