Git Product home page Git Product logo

docker-bootstrap's Introduction

docker-bootstrap

Bootstrapper for Docker-based projects using Rails with nginx and PostgreSQL DB.

GitHub Actions

Requires

  • docker v19.03.8
  • docker-compose v1.25.5

Usage

The following steps will create the Docker images and setup a Rails project using the PostgreSQL DB.

# shallow clone bootstrap files and re-init the repo
$ git clone --depth 1 [email protected]:jurisgalang/docker-bootstrap.git project-name
$ cd project-name/
$ rm -rf .git .github
$ git init

# build images
$ docker-compose build

# install rails in web container and create a project using postgresql 
$ docker-compose run --rm web gem install bundler rails
$ docker-compose run --rm web rails new . -d postgresql --skip-test

# create posgresql db config
$ tee ./web/config/database.yml << 'EOF'
default: &default
  adapter: postgresql
  encoding: unicode
  username: <%= ENV['DATABASE_USERNAME'] %>
  password: <%= ENV['DATABASE_PASSWORD'] %>
  host: <%= ENV['DATABASE_HOST'] %>
  pool: <%= ENV.fetch('RAILS_MAX_THREADS') { 5 } %>

development:
  <<: *default
  database: app_development

test:
  <<: *default
  database: app_test

production:
  <<: *default
  database: app_production
EOF

# initialize project db
$ docker-compose run --rm web rake db:create
$ docker-compose run --rm web rake db:migrate
$ docker-compose run --rm web rake db:setup

# spin-up web app and test
$ docker-compose run --rm --service-ports web
$ curl -I http://localhost:3000/ 

# spin-up nginx to serve the web app and test
$ docker-compose run --rm --service-ports nginx
$ curl -I http://localhost/ 

The Rails project resides at ./web; after the setup and verification its Dockerfile will need to be updated for project specific requirements and to make it suitable for deployment.

Housekeeping

To clear all containers, images, and volume:

$ docker-compose down
$ docker system prune -a
$ docker volume prune

docker-bootstrap's People

Contributors

jurisgalang avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.