Lordnibbler / railsblog

My personal website
http://benradler.com
0 stars 0 forks source link

benradler.com

This is a Ruby on Rails 7 app. It does the following:

Development

Follow these instructions to get the app running locally.

# install dependencies
brew bundle

# create a YAML file to stub environment variables
$ mv config/env.yml.example config/env.yml
$ vi config/env.yml

# set up database
$ rails db:setup

# install dependencies
$ bundle
$ yarn

# start the rails web server
$ rails s

# start the webpack dev server
$ ./bin/shakapacker-dev-server

# start the guard watcher for tests and code formatting
$ guard

Architecture

This is a Rails app, deployed on Heroku.

Persistence

postgresql

It uses Heroku Postgresql, configured via DATABASE_URL env var. The schema can be found in db/schema.rb.

redis

It uses redis-to-go, configured via REDISCLOUD_URL env var. Redis backs the cache for the photography gallery.

Cron

It uses Heroku Scheduler add on to run two recurring jobs:

CDN

Cloudflare

Cloudflare is used for DDoS protection, a basic cache, and CDN.

NOTE: Caching of .mp4 files is explicitly disabled in a custom page rule due to issues with Cloudflare changing HTTP 206 to 200, and causing Safari to not load .mp4 files. See this issue in Cloudflare forums for more information.

Cloudfront

AWS Cloudfront creates a CDN distribution mirroring the website. The rails ASSET_HOST env var is set to cause asset helper functions to use the Cloudfront host instead of the main domain.

Images

Images are stored on AWS S3 by way of ActiveStorage in Rails. There are custom CDN routes defined, which allow for use of url helpers such as cdn_image_url.

Email

Sendgrid is used to send emails from the contact forms.

HTTPS

Cloudflare provides HTTPS via Let's Encrypt. The Rails application layer is configured to force an SSL connection.

Frontend

The frontend of the site is built using Webpacker.

The technologies used are:

Testing

Static Code Analysis

Observability

NewRelic

For observing performance data about the rails application.

LogDNA

For observing stderr and stdout logs emitted by the rails application.