docker-compose-rails-startup's People
docker-compose-rails-startup's Issues
Updated README
@deathbyjer I've updated the README with a few more steps as well as adding the instructions for setting up a test environment in case you wish to point people here in the future. I couldn't open a PR due to access restrictions. This should cover most places where I got stuck, but I may have missed a step or two. Later this week I'll try this again to ensure accuracy!
`Startup a Docker-Compose project with Rails
This is a quickly updated version of the startup portion from https://docs.docker.com/samples/rails/
Purpose
There has been confusion using the sample provided by docker-compose, so I resolved to provide an easy-to-use skeleton that can be quickly booted up.
The two main items I edited was bumping the Rails version to 6 and making the Dockerfile expecting the its directory to also be the Rails directory.
Steps
- Clone this repo
- Change folder name to the name of the app you wish to create.
- Within
Dockerfile
be sure to replace all instances ofmyapp
with your intended application name. - Run
docker-compose run --no-deps web rails new . --force --database=postgresql
within the directory. (This will setup Rails) - Run
docker-compose run --no-deps web chown -R 1000:1000 *
(This will reset the permissioning on the generated files so you can work on them locally) - Run
docker-compose build web
(This will ensure that everything is appropriate built off the Rails-generated Gemfile - Run
docker-compose up
(to start the service!) - While that is running hit
cmd+t
(on mac,ctrl+t
on widowns) in terminal to open a new terminal tab. - Within that tab run
docker-compose run web rake db:create
to create you docker db.
Be advised that some of these commands can take 3-7 minutes, depending on your system.
Testing Database Setup
If you wish to set up a database for docker as well as one for testing the following is recommended.
Again, making sure to replace myapp
with your applications name!
- Change
docker-compose.yml
to the following.
version: "3.9"
services:
db:
image: postgres
volumes:
- ./tmp/db:/var/lib/postgresql/data
environment:
POSTGRES_PASSWORD: password
web:
build: .
command: bash -c "rm -f tmp/pids/server.pid && bundle exec rails s -p 3000 -b '0.0.0.0'"
volumes:
- .:/myapp
- ./docker/database.yml:/myapp/config/database.yml #New directory for docker!
ports:
- "3000:3000"
depends_on:
- db
This will point docker towards one db and your tests towards another as to avoid any conflicts.
- In
config/database.yml
copy and paste the following.
default: &default
adapter: postgresql
encoding: unicode
host: localhost # Local db for testing
username: postgres
password: password
pool: 5
development:
<<: *default
database: myapp_development
test:
<<: *default
database: myapp_test
- Create your new docker folder in your main application directory and place the following
database.yml
.
default: &default
adapter: postgresql
encoding: unicode
host: db #Local db for Docker
username: postgres
password: password
pool: 5
development:
<<: *default
database: myapp_list_development
test:
<<: *default
database: myapp_list_test
- Rerun
docker-compose up
.
`
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.