Rails API on AWS – part 1: Local server setup

Tutorial presents how to create API-only Rails application with Postgresql and PostGIS database, using Nginx, Puma and Docker. Application will be deployed to AWS Elastic Beanstalk and exposed by AWS API Gateway.

 

List of Posts:

  1. part 1: Local server setup
  2. part 2: Basic Rails App with PostGIS
  3. part 3: Docker
  4. part 4: AWS setup
  5. part 5: AWS setup & deploy

 

PART 1

  1. Introduction
  2. Ruby installation
  3. Rails installation
  4. Database installation
  5. Docker installation
  6. NGINX Installation
  7. Git setup
  8. Cheatsheet

 

1. Introduction

First part is about setting up a development machine, installing required components and creating very basic Rails application. My local server has following configuration:

OS:                Ubuntu 16.04 LTS
Ruby:             2.4.1
Rails:             5.1.3
PostgreSQL:  9.6
PostGIS:        2.3
Docker:
Docker-compose:  1.15

 

Following Ruby, Rails and Postgresql setup instructions comes from this article. You can find there more details and instructions for other OS, Ruby and Rails versions.

 

2. Ruby installation

 

3. Rails installation

 

 

4. Database installation

In mentioned article, you can find instructions how to setup MySQL and PostgreSQL databases. I use PostgreSQL extended with PostGIS.

PostgreSQL installation:

 

Create a new user (replace myusername):

Set password for user and exit:

 

PostGIS installation:

 

5. Docker installation

You can make a test:

Additional configuration:

 

Docker Compose installation:

 

6. NGINX installation

 

7. Git setup

First, you should create account on Github, Bitbucket or Gitlab.

Copy following output…

… and add to your SSH keys on Github / Bitbucket / Gitlab accounts.

 

I’d like to recommend you Bash Git Prompt. It styles and decorates shell prompt with some basic information about your local git.

 

8. Cheatsheet

 

Ruby and Rails

PostgreSQL

PostgreSQL console:

Docker

 

Tomasz Antas

Ruby on Rails developer and Web designer.
The area of his interest includes Popular Science, Internet of Things, Wearables, AI and Virtual/Augmented Reality.

Latest posts by Tomasz Antas (see all)

Thanks for reading!