DEV Community

Discussion on: Create new Rails 6 project with Docker

Collapse
 
almokhtar profile image
almokhtar bekkour

What if i don't want to install rails in my machine and just pull it from source ? how to do that ?

Collapse
 
leonardogrtt profile image
Leonardo Girotto

I think when he runs gem install rails command, he is inside a temporary container, that is just used to scaffold the project.
As he said:
"After creating the project, close your container with exit. Your container will be closed and removed. And you'll end up with a shiny new Rails install, without having Rails, Ruby, etc. on your computer."

Collapse
 
leonardogrtt profile image
Leonardo Girotto

Here is my Dockerfile for Rails 6

FROM ruby:3.0.0-preview2-buster

# Move to workspace
WORKDIR /usr/src/app

# Update packages
RUN apt update -qq

# Install packages
RUN apt install -y curl \
                vim \
                wget \
                zip \
                unzip \
                build-essential


# Install NodeJS LTS
RUN sh -c "curl -sL https://deb.nodesource.com/setup_lts.x | bash -"
RUN apt install -y nodejs

# Install Yarn package
RUN sh -c "npm install yarn --global"

# Install gems 'bundler' and 'rails'
RUN sh -c "gem install bundler && gem install rails -v 6.1"
Enter fullscreen mode Exit fullscreen mode


`