https://github.com/x1wins/docker-postgres-rails
Docker postgresql init, run with rake in rails project
https://github.com/x1wins/docker-postgres-rails
docker docker-postgres docker-postgres-rails postgresql rails rake
Last synced: 5 months ago
JSON representation
Docker postgresql init, run with rake in rails project
- Host: GitHub
- URL: https://github.com/x1wins/docker-postgres-rails
- Owner: x1wins
- Created: 2019-12-13T18:51:31.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2023-01-19T16:30:26.000Z (about 3 years ago)
- Last Synced: 2025-10-07T16:12:16.166Z (5 months ago)
- Topics: docker, docker-postgres, docker-postgres-rails, postgresql, rails, rake
- Language: Ruby
- Homepage:
- Size: 67.4 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 9
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## README
When we begin new rails project,
always need easy, fast database setting
Docker-postgres-rails gem easy, fast run PostgreSql database by docker without docker command and many environment var
## Required
* Your OS must be macOS or linux (Not support window, because using mkdir)
* Installed Docker
* Rails project must use PostgreSql (You can create new project using postgresql by this command : ```$ rails new [PORJECT_NAME] -d postgresql``` )
* Your must input values of database, username, password, port in config/database.yml file (docker will use these values)
## Getting Started
1. Add gem in Gemfile
https://rubygems.org/gems/docker-postgres-rails
```yaml
gem 'docker-postgres-rails', '~> 0.0.1'
```
OR
```yaml
gem 'docker-postgres-rails', :git => "git://github.com/x1wins/docker-postgres-rails.git"
```
2. Generate docker_pg.rake
```bash
$ rails generate docker_pg
identical lib/tasks/docker_pg.rake
```
3. Set database, username, password, port in database.yml,
Docker will use database, username, password, port in database.yml
```yaml
database: docker_postgres_rails_development
username: docker_postgres_rails
password: mysecretpassword
host: localhost
port: 5432
```
4. Create database volume path
```bash
$ rake docker:pg:init
```
5. Run dockerized PostgreSQL
```bash
$ rake docker:pg:run
```
```bash
$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
4ec621c7914b postgres "docker-entrypoint.s…" 17 minutes ago Up 17 minutes 0.0.0.0:5432->5432/tcp docker_postgres_rails_development
```
## It's all