Coder Social home page Coder Social logo

lightweight_rails_app's Introduction

Dockerized Lightweight Rails app

Skinny rails app built using some example that can be found on the internets. Modified to actually do some work that you'll find in a common rails app:

  • database integration
  • ActiveRecord-based models
  • views
  • controllers
  • specs
  • rake tasks to manage db

The idea of the app: Render quotes randomly from database

Docker integration

This repo includes few files that will help you get started with running it on docker:

  • Dockerfile - contains definition of the base image for this app (rails:onbuild)
  • docker-compose.yml - file that includes dependency services required for application to run, i.e. mysql
  • docker-compose.development.yml - this is same file as docker-compose.yml, but tailored for execution of specs and running service in development environment. By setting volume from your current directory into container's directory, so that you always have latest code as soon as you save the change in the file.

Prerequisites

To get up and running on your machine, you'd need to install:

  • docker
  • docker-machine (to provision docker hosts on your local or in the cloud)
  • docker-compose (to orchestrate containers)

If you want to learn more and don't know where to start, check out this excellent guide on Getting started with docker-compose for Development environment

Running (deploying) with Docker

  1. Clone repo
  2. Create docker host on your laptop docker-machine create -d virtualbox --virtualbox-memory "2048" quotes
  3. Inside repo, start application: docker-compose up -d It will pull, build and then launch mysql and web containers defined in docker-compose.yml file
  4. Create database and seed initial data: docker-compose run web rake db:reset Be careful, if it's 2nd time you're running it - your database will be deleted, created again and schema with data reloaded.

Running specs

docker-compose -f docker-compose.development.yml run -e RAILS_ENV=test web rspec

This command will launch container and execute specs.

Deploying without Docker

Of course this rails application like any other can be deployed to any PAAS product, i.e. heroku.

Application structure

  1. Controllers and Models are located in app.rb file
  2. Views are located in views directory
  3. Specs are in their normal location - spec directory
  4. Database configuration is in db/database.yml (vs config/database.yml with default rails structure)
  5. Database migrations and seeds are in db direcotry

Why?

To have a lightweight example of rails app to play with different options for deployment. It must have traits similar to common rails app:

  • integration with external services (i.e. database)
  • tests
  • views

lightweight_rails_app's People

Contributors

akurkin avatar

Watchers

James Cloos avatar Yas 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.