Giter VIP home page Giter VIP logo

ansible-rails-container's Introduction

rails-container-app

Build Status

Role used to download, configure and run docker container with rails app, before running app role runs migrations

Requirements

Ubuntu 14.04 is tested.

This role uses Ansible's docker module, so requirements are the same.

Role Variables

Here is the list of Required variables with default values:

# Docker repository image and tag
app_docker_image: 'alpine'
app_docker_image_tag: 'latest'

#Name of the container when it's running
app_container_name: 'rails'
# List of exposed ports for container
app_ports_mapping: []
#Command to run in docker
app_command: 'bundle exec rails s'
# Dict of environment variables
app_environment_vars: {}
# Configuration files to deploy on server and mount to image
app_configuration_files: {}

If you pulling image from private docker repository - specify docker credentials:

# Docker credentials for private image
app_docker_login: 'login'
app_docker_password: 'password'
app_docker_email: 'email'

These variables are optional and can be changed if needed

# Environment to run rails
app_environment: production
# Folder with all config files on local machine
app_files_local_folder: './files'
#Force image pull
app_force_image_pull: true
#Docker container restart policy
app_container_restart_policy: always
#Migration command
app_migration_command: 'bundle exec rake db:migrate'
#Container memory limit
container_memory_limit: 1g

Dependencies

No dependencies

Example Playbook

Simpliest playbook can be following:

- hosts: webservers
  roles:
    - role: rails-container-app
      app_docker_image: 'maticinsurace/rails-app'
      app_docker_tag: 'latest'
      app_ports_mapping: ['3000:3000']

This playbook will pull image maticinsurace/rails-app:latest, run migrations bundle exec rake db:migrate and start rails app bundle exec rails s

If you want to specify additional environment variables:

- hosts: webservers
  roles:
    - role: rails-container-app
      app_command: 'bundle exec sidekiq'
      app_environment_vars:
        REDIS_URL: redis://redis.host:6379
        DATABASE_URL: postgress://db.host:5432

THis will execute sidekiq and add redis/postgress variables

If you want custom files to be deployed to the app:

- hosts: webservers
  roles:
    - role: rails-container-app
      app_files_local_folder: './files/webserver'
      app_configuration_files:
        settings.yaml: /app/config/settings.local.yaml
        apns_cert.pem: certs/apns.pem

This will read file from local machine using key as path after app_files_local_folder and mount them to docker image using value as path. E.g ./files/webserver/settings.yaml will be mounted as /app/config/settings.local.yam:ro

The same way you can render Jinja2 templates via app_configuration_templates:

- hosts: webservers
  roles:
    - role: rails-container-app
      app_templates_local_folder: './templates/webserver'
      app_configuration_templates:
        settings.local.yml.j2: /app/config/settings.local.yml

License

MIT

Author Information

Matic is a communication platform that connects lenders and borrowers originating a new home loan. A borrower now knows where they are in the loan process and what they need to do to complete the loan.

ansible-rails-container's People

Contributors

kukunin avatar volodymyr-mykhailyk 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.