Skip to content

Commit 542f3fb

Browse files
committed
Create a prototype for generating the Rails application using Docker
The goal of this project is to allow developers to generate a new Rails application without having to install Ruby on their machine. This is achieved by using Docker to generate the Rails application.
0 parents  commit 542f3fb

File tree

3 files changed

+42
-0
lines changed

3 files changed

+42
-0
lines changed

Dockerfile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
ARG RUBY_VERSION=3.2.3
2+
FROM ruby:${RUBY_VERSION}
3+
ARG RAILS_VERSION
4+
# Install Rails based on the version specified but if not specified, install the latest version.
5+
RUN if [ -z "$RAILS_VERSION" ] ; then gem install rails ; else gem install rails -v $RAILS_VERSION ; fi

README.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
You can use this repository to generate a new Rails application without having to install Ruby on your machine.
2+
3+
It works by using Docker to generate the Rails application for you. Docker takes care of installing the right Ruby and
4+
Rails versions for you, so you don't have to worry about it.
5+
6+
## Prerequisites
7+
8+
You need to have Docker installed on your machine. You can find instructions on how to install Docker on your machine
9+
[here](https://docs.docker.com/engine/install/).
10+
11+
## Usage
12+
13+
To generate a new Rails application, you can run the following command:
14+
15+
```bash
16+
bin/rails-new myapp
17+
```

bin/rails-new

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/usr/bin/env bash
2+
3+
# This script is to generate a new Rails application using the Dockerfile in this repository.
4+
5+
# The first argument is the name of the new Rails application.
6+
7+
# Ruby version variable
8+
RUBY_VERSION=3.2.3
9+
10+
# Rails version variable
11+
RAILS_VERSION=7.1.3
12+
13+
# Build the image
14+
docker build \
15+
--build-arg RUBY_VERSION=$RUBY_VERSION \
16+
--build-arg RAILS_VERSION=$RAILS_VERSION \
17+
-t rails-new-$RUBY_VERSION-$RAILS_VERSION .
18+
19+
# Run the image
20+
docker run -v $(pwd):/$(pwd) -w $(pwd) rails-new-$RUBY_VERSION-$RAILS_VERSION rails new $1

0 commit comments

Comments
 (0)