Simple usage for newcomers - mtereschenko/simple_ror_environment GitHub Wiki
Here is the very basic usage of the current repository not really as a pattern, but as a tool for start develop a new Ruby On Rails application.
FROM THE SCRATCH.
Probably, you have cloned this repo already, so we can start using it. But as long as you just cloned it and have no application, let's create one.
cd ${PROJECT_PATH}/environment
"environment" - is a directory that holds all of the magic which makes our environment available for our incredible new project. If you are there, that suggests that you are going to interact not really with a project itself, but with an environment. It's like a shell for your project, it protects your app from foreign invasions and holds 100% compatible libraries, operating systems, tools, etc.
You will find there next structure of the folder and files.
Everything starts with editing .env.example. This file contains several initial variables for the new projects, but now we need just PROJECT_NAME.
Change PROJECT_NAME variable to your project name.
Attention here!
PROJECT_NAME should be in snake case with underscores, no spaces, no special chars, and no EOL symbols. Just make it nice_and_clean.
Once the project name was given we can initialize our app.
make init
This command will create your application folder, and prepare your environment to be built. The next things you have to do is build your containers, run the environment, and run an application server.
make build
With this command, your containers will be prepared for running and all packages from rails Gemfile will be installed inside containers. Execution of this command is obligatory if you changed your Gemfile.
make run
With this command, your environment would run, then you can interact with it, but the final step is still forward. To be able to use "rails console" and start "rails server" you have to enter into the environment shell.
make shell
Finally, you can start rails server just as ROR guides
told us to do. But here is the thing, as far as our app running into the docker container we must use --binding=0.0.0.0
, also our nginx server by default listening 3000 port for rails, so we must specify a port with -p 3000
argument.
bin/rails s -p 3000 --binding=0.0.0.0
Once you did it your project will be available by this URL http://${PROJECT_NAME}.localhost. By default, it's http://test_project.localhost.