Skip to content

Commit 9fd3a7d

Browse files
committed
Initial commit
0 parents  commit 9fd3a7d

File tree

18 files changed

+532
-0
lines changed

18 files changed

+532
-0
lines changed

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
/doc/
2+
/libs/
3+
/.crystal/
4+
/.shards/
5+
/dip

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
language: crystal

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2016 Michail Merkushin
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in
13+
all copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21+
THE SOFTWARE.

README.md

Lines changed: 162 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,162 @@
1+
# DIP
2+
3+
Docker Interaction Process
4+
5+
CLI utility for straightforward provisioning and interacting with application configured by docker-compose.
6+
7+
DIP also contains commands for running support containers such as ssh agent and dns server.
8+
9+
## Installation
10+
11+
```sh
12+
curl -L https://github.com/bibendi/dip/releases/download/0.1.0/dip-`uname -s`-`uname -m` > /usr/local/bin/dip
13+
chmod +x /usr/local/bin/dip
14+
```
15+
16+
## Usage
17+
18+
```sh
19+
dip --help
20+
dip SUBCOMMAND --help
21+
```
22+
23+
### dip compose
24+
25+
Run docker-compose commands that is configured according with application dip.yml
26+
27+
```sh
28+
dip compose COMMAND [OPTIONS]
29+
```
30+
31+
### dip ssh
32+
33+
Runs ssh agent container base on https://github.com/whilp/ssh-agent with your ~/.ssh/id_rsa.
34+
It creates a named volume `ssh_data` with ssh socket.
35+
An applications docker-compose.yml should define environment variable `SSH_AUTH_SOCK=/ssh/auth/sock` and connect to external volume `ssh_data`.
36+
37+
```sh
38+
dip ssh add
39+
```
40+
41+
docker-compose.yml
42+
43+
```yml
44+
services:
45+
web:
46+
environment:
47+
- SSH_AUTH_SOCK=/ssh/auth/sock
48+
volumes:
49+
- ssh-data:/ssh:ro
50+
51+
volumes:
52+
ssh-data:
53+
external:
54+
name: ssh_data
55+
```
56+
57+
## dip dns
58+
59+
Runs DNS server container based on https://github.com/aacebedo/dnsdock
60+
61+
```sh
62+
dip dns up
63+
```
64+
65+
### Installation
66+
67+
#### Ubuntu
68+
69+
TODO
70+
71+
#### Mac OS X
72+
73+
First, let's start by configuring the default Docker service DNS server to IP where the DNS server will run (`172.17.0.1`). Currently, this requires SSH'ing into the VM and editing `/etc/default/docker`
74+
75+
```sh
76+
77+
78+
vi /etc/default/docker
79+
# Add the DNS server static IP via `--bip` and `--dns`
80+
# Change DOCKER_ARGS to:
81+
DOCKER_ARGS="-H unix:///var/run/docker.sock -H tcp://0.0.0.0:2375 -s btrfs --bip=172.17.0.1/24 --dns=172.17.0.1"
82+
# save :x
83+
84+
exit
85+
86+
dlite stop && dlite start
87+
```
88+
89+
Lastly, configure OSX so that all `.docker` requests are forwarded to Docker's DNS server. Since routing has already been taken care of, just create a custom resolver under `/etc/resolver/docker` with the following content:
90+
91+
```
92+
nameserver 172.17.0.1
93+
```
94+
95+
Then restart OSX's own DNS server:
96+
97+
```sh
98+
sudo killall -HUP mDNSResponder
99+
```
100+
101+
By default, Docker creates a virtual interface named `docker0` on the host machine that forwards packets between any other network interface.
102+
103+
However, on OSX, this means you are not able to access the Docker network directly. To be able to do so, you need add a route and allow traffic from any host on the interface that connects to the VM.
104+
105+
Run the following commands on your OSX machine:
106+
107+
```sh
108+
sudo route -n add 172.17.0.0/8 local.docker
109+
DOCKER_INTERFACE=$(route get local.docker | grep interface: | cut -f 2 -d: | tr -d ' ')
110+
DOCKER_INTERFACE_MEMBERSHIP=$(ifconfig ${DOCKER_INTERFACE} | grep member: | cut -f 2 -d: | cut -c 2-4)
111+
sudo ifconfig "${DOCKER_INTERFACE}" -hostfilter "${DOCKER_INTERFACE_MEMBERSHIP}"
112+
```
113+
114+
Check:
115+
116+
```sh
117+
ping dnsdock.docker
118+
```
119+
120+
# Docker
121+
122+
## Installation
123+
124+
### Ubuntu
125+
126+
TODO
127+
128+
### Mac OS X
129+
130+
```
131+
sudo brew install docker
132+
sudo brew switch docker 1.12.1
133+
```
134+
135+
#### dlite
136+
137+
Download https://github.com/nlf/dlite/releases/download/1.1.5/dlite
138+
139+
```sh
140+
sudo dlite install -c 2 -m 4 -d 20 -S $HOME
141+
```
142+
143+
##### Simple
144+
145+
- `dlite stop`
146+
- download `bzImage` and `rootfs.cpio.xz` https://github.com/bibendi/dhyve-os/releases/tag/2.3.1
147+
- move in `~/.dlite/`
148+
- `dlite start`
149+
150+
##### or Advanced (for other docker version)
151+
152+
```sh
153+
git clone https://github.com/nlf/dhyve-os.git
154+
cd dhyve-os
155+
git checkout legacy
156+
vi Dockerfile
157+
# find the DOCKER_VERSION and replace with needed version
158+
make
159+
dlite stop
160+
cp output/{bzImage,rootfs.cpio.xz} ~/.dlite/
161+
dlite start
162+
```

dip.yml.sample

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
environment:
2+
COMPOSE_EXT: development
3+
RAILS_ENV: development
4+
RAILS_32: "0"
5+
RUBY_VERSION: "1.9.3"
6+
JOBS: "3"
7+
CACHE: ""
8+
PROFILE: ""
9+
PROJECT: docker
10+
DEPLOY: development
11+
BUNDLE_PATH: /bundle
12+
13+
compose:
14+
files:
15+
- docker/docker-compose.yml
16+
- docker/docker-compose.$COMPOSE_EXT.yml
17+
project_name: pulscen$RAILS_ENV
18+
19+
interaction:
20+
exec:
21+
service: app
22+
23+
bundle:
24+
service: app
25+
command: bundle
26+
27+
rails:
28+
service: app
29+
commands:
30+
server:
31+
alias: s
32+
service: web
33+
34+
console:
35+
alias: c
36+
start: bundle exec rails c
37+
38+
psql:
39+
service: pg
40+
command: psql -h localhost -U postgres pulscen
41+
42+
provision:
43+
- docker volume create --name bundle_data
44+
- dip exec ./script/config_env
45+
- dip compose up -d pg redis
46+
- dip bundle install
47+
- dip bundle exec rake db:migrate --trace > /dev/null

shard.lock

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
version: 1.0
2+
shards:
3+
cli:
4+
github: mosop/cli
5+
version: 0.2.3
6+
7+
optarg:
8+
github: mosop/optarg
9+
version: 0.3.1
10+
11+
stdio:
12+
github: mosop/stdio
13+
version: 0.1.3
14+
15+
string_inflection:
16+
github: mosop/string_inflection
17+
version: 0.1.5
18+

shard.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
name: dip
2+
version: 0.1.0
3+
4+
authors:
5+
- Michail Merkushin <[email protected]>
6+
7+
license: MIT
8+
9+
dependencies:
10+
cli:
11+
github: mosop/cli

spec/dip_spec.cr

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
require "./spec_helper"
2+
3+
describe Dip do
4+
# TODO: Write tests
5+
6+
it "works" do
7+
false.should eq(true)
8+
end
9+
end

spec/spec_helper.cr

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
require "spec"
2+
require "../src/dip"

src/dip.cr

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
require "cli"
2+
require "./dip/version"
3+
require "./dip/cli"
4+
require "./dip/config"
5+
require "./dip/environment"
6+
7+
module Dip
8+
def self.config
9+
@@config ||= Config.from_yaml(File.read(config_path))
10+
end
11+
12+
def self.config_path
13+
ENV.fetch("DIP_FILE", "./dip.yml")
14+
end
15+
16+
def self.env
17+
@@env ||= Environment.new(config.environment)
18+
end
19+
end
20+
21+
exit Dip::Cli.run(ARGV).as(Int32)

0 commit comments

Comments
 (0)