wantedly/rid

Name: rid

Owner: Wantedly, Inc.

Description: Run commands in container as if were native. Stress-free dockerized development environment finally arrived

Forked from: creasty/rid

Created: 2017-10-12 05:52:02.0

Updated: 2017-10-12 05:52:03.0

Pushed: 2017-10-12 07:45:26.0

Homepage:

Size: 64

Language: Go

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

rid (run-in-docker)

Build Status codecov GoDoc GitHub release License

Run commands in container as if were native. Stress-free dockerized development environment finally arrived.

What is rid?

With a rid/ directory at the root of a project, any command prefixed by rid is executed within a Docker container.

 ./rid
ig.yml
er-compose.yml
erfile

That is to say, even if your environment is absolutely clean and you have nothing but docker, docker-compose and rid, getting started with a new Rails project from scratch has never been easier.

stall dependencies and setup a database
d cp .env{.sample,}
d bundle install --path vendor/bundle
d rake db:create
d rake db:schema:load

art a server
d rails s
Installation

First, install Docker and Docker Compose. The easiest way to do this on macOS is by installing Docker for Mac.

macOS

You can install rid via Homebrew:

ew install creasty/tools/rid
Linux

Download a binary from here: https://github.com/creasty/rid/releases

Windows

Not supported yet

Usage

rid is a project contextual tool, meaning that it's aware of working directory and automatically finds the root directory of a project by locating a configuration file.

Typical rid directory looks like this:

                   # rid directory at the root of a project (e.g., same level as `.git`'s)
bexec/             # custom sub-commands for rid
nfig.yml           # configuration file for rid
cker-compose.yml   # docker-compose manifest
ckerfile           # dockerfile

Note that rid/config.yml and rid/docker-compose.yml are regardlessly required for rid to work with.

Config file

Configurable parameters of rid/config.yml are the following.

 Config struct {
// ProjectName is used for `docker-compose` in order to distinguish projects in other locations
ProjectName string `json:"project_name" valid:"required"`

// MainService is a service name in `docker-compose.yml`, in which container commands given to rid are executed
// Default is "app"
MainService string `json:"main_service"`

Custom commands

Executables in rid/libexec/ can be run as a sub command.

libexec/
o           # `rid foo` -- this is executed in a container
d-bar       # `rid bar` -- name starts with `rid-` is executed on a host computer
d-bar.txt   # optionally, placing `.txt` file that shares the common basename enables "help" functionality

Help file should have a title in the first line:

 greeting message

e:
rid bar NAME

The title (first line) appears on the help of rid.

d
ute commands via docker-compose

e:
rid COMMAND [args...]
rid COMMAND -h|--help
rid [options]

ons:
-h, --help     Show this
-v, --version  Show rid version
    --debug    Debug context and configuration

ands:
compose  # Execute docker-compose
foo
bar      # Show greeting message

And rid COMMAND -h prints the full contents.

d bar -h
 greeting message

e:
rid bar NAME
Development

Surprise surprise, rid itself is developed by rid!

d glide install  # install dependencies
d make test      # run lint and tests
d make           # compile for darwin/amd64
bin/rid -v       # execute a new binary

This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.