Giter Club home page Giter Club logo

grape-skeleton's Introduction

Grape Skeleton

GitHub license

A skeleton for Grape application.

It comes with this gems :

  • grape (of course)
  • puma (for the webserver)
  • dotenv (to get settings from env vars)
  • figaro (to validate env vars presence)
  • settingslogic (to store/retrieve settings)
  • foreman (to have a start command and to export systemd config files)

For the deployment we use :

  • capistrano (to do the deployment)
  • capistrano-rvm (because we use RVM)
  • capistrano-bundler (to install gems on deployment)
  • capistrano-foreman (so we can start/restart the application remotely)
  • capistrano-template (to install configuration files on deployment)

Usage in development

nicolas@desktop: git clone https://github.com/jbox-web/grape-skeleton.git
nicolas@desktop: cd grape-skeleton
nicolas@desktop: bundle install
nicolas@desktop: bin/foreman start

You can then go to your browser and check http://127.0.0.1:5000/api/v1.

Api endpoints are located in lib/grape_skeleton/api/base.rb.

You can customize environment variables by creating a .env file at the root of the project :

RACK_ENV=production
WEB_CONCURRENCY=1
PORT=5000

Create a new app

To create a new application from this repository run the rename.sh script at the root :

nicolas@desktop: ./rename.sh MyProject my_project

The arguments are the new project name in PascalCase then the new project name in snake_case.

The first is to sed string in files, the second to rename lib/grape_skeleton directory.

The script will rename the string GrapeSkeleton to MyProject and will move lib/grape_skeleton directory to lib/my_project.

The rest is up to you! (reinitializing repository, etc...) (do a git status to see the changes)

Deployment

With Docker

You can build a Docker image and run it :

nicolas@desktop: make build
nicolas@desktop: make start

To get the container status :

nicolas@desktop: make status

To stop the container :

nicolas@desktop: make stop

With Capistrano

Or you can deploy in the good old fashion :

  1. Create a grape-skeleton user on a server and install your SSH public key
# As root
root: adduser --disabled-password --home /data/www/grape-skeleton grape-skeleton
root: su - grape-skeleton

# As grape-skeleton user
grape-skeleton: mkdir .ssh
grape-skeleton: vi .ssh/authorized_keys
  1. Install RVM on the server as grape-skeleton user
# As grape-skeleton user
grape-skeleton: gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB
grape-skeleton: \curl -sSL https://get.rvm.io | bash -s stable
  1. Intall Ruby 2.4.2 and Bundler
# As grape-skeleton user
grape-skeleton: rvm install 2.4.2
grape-skeleton: gem install bundler
  1. Create Capistrano config file

On your local computer :

  • Rename config/deploy/production.rb.dist into config/deploy/production.rb and update it to make it point to your server.

  • Deploy with Capistrano

nicolas@desktop: cap production deploy

grape-skeleton's People

Contributors

n-rodriguez avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.