Git Product home page Git Product logo

rails5-docker-alpine's Introduction

rails5-docker-alpine

This is a very lightweight Docker image based on Ruby Alpine to run a Rails 5 application. I also provide a docker-compose file to run your project using a PostgreSQL database.

Trying out the image

Clone the repository:

git clone [email protected]:pacuna/rails5-docker-alpine.git

Create a new Rails application under the repository directory

cd rails-docker-alpine
rails new . --database=postgresql

Modify your database configuration to use the postgresql container configuration:

default: &default
  adapter: postgresql
  encoding: unicode
  # For details on connection pooling, see rails configuration guide
  # http://guides.rubyonrails.org/configuring.html#database-pooling
  pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
  host: db
  username: postgres

Build the project:

docker-compose build

Create the database and run the migrations:

docker-compose run --rm web bin/rails db:create
docker-compose run --rm web bin/rails db:migrate

Run the app:

docker-compose up -d

Visit your application at localhost:3000.

Tested with:

  • Ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-linux]
  • Rails 5.2.2 (to create the new application)
  • Docker version 18.09.0, build 4d60db4
  • docker-compose version 1.23.1, build b02f1306

rails5-docker-alpine's People

Contributors

jameschevalier avatar pacuna avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

rails5-docker-alpine's Issues

Reasoning behind tmp folder usage

I'm still fairly new to Docker, and I'm wondering if there's a bit I can learn from your process. I'm referring to these lines in the Dockerfile:

WORKDIR /tmp
ADD Gemfile /tmp/
ADD Gemfile.lock /tmp/
RUN bundle install --jobs 4 --retry 3

# Copy the application into the container
COPY . /usr/src/app
WORKDIR /usr/src/app

Whereas my approach is usually:

WORKDIR /app
COPY Gemfile /app/
COPY Gemfile.lock /app/
RUN bundle install --jobs 4 --retry 3
COPY . /app

Is there a benefit of your approach over my approach?
Is my approach more/less efficient?
Does my approach have issues that I haven't uncovered yet?

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.