Skip to content

Commit 7ba3295

Browse files
committed
Move delivery system from Docker to RubyGems
Over time `nib` has evolved from a suite of bash scripts into a Ruby based project wrapped up in a [GLI](https://github.com/davetron5000/gli) gem. When we had bash scripts using Docker to distribute them was very convenient however now that we have a gem let's take advantage of the ecosystem around delivering (`gem install nib`) and updating them (`gem update nib`).
1 parent 72fa870 commit 7ba3295

37 files changed

+69
-374
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,5 @@ tmp/*
66
spec/examples.txt
77
spec/dummy/**/tmp
88
spec/dummy/**/log
9+
coverage/
10+
pkg/

Dockerfile

Lines changed: 16 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,24 @@
1-
FROM ruby:alpine
1+
FROM ruby
22

3-
ENV COMPOSE_VERSION 1.7.1
3+
ENV COMPOSE_VERSION 1.10.0
44

55
RUN \
6-
apk add --update \
7-
openssl \
8-
py-pip \
9-
py-yaml && \
10-
pip install -U docker-compose==${COMPOSE_VERSION} && \
11-
rm /var/cache/apk/* && \
12-
rm -rf `find / -regex '.*\.py[co]' -or -name apk`
6+
gem install rainbow -v '2.2.1' && \
7+
curl -fsSL https://get.docker.com/ | sh && \
8+
curl -L https://github.com/docker/compose/releases/download/$COMPOSE_VERSION/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose && \
9+
chmod +x /usr/local/bin/docker-compose
1310

14-
# RUN gem install nib
11+
WORKDIR /usr/src/app
1512

16-
# this is not ideal because these files will remain as part of the image,
17-
# we should explore a build pipline that compile the gem first and then leaves
18-
# an artifact to be installed by the next step in the process
19-
COPY . /usr/src/app
13+
COPY Gemfile* ./
14+
COPY VERSION ./VERSION
15+
COPY lib/nib/version.rb ./lib/nib/version.rb
16+
COPY nib.gemspec ./nib.gemspec
2017

2118
RUN \
22-
cd /usr/src/app && \
23-
rake build && \
24-
cp -r pkg /usr/local/pkg && \
25-
cd /usr/local/pkg && \
26-
gem install nib* && \
27-
rm -rf /usr/src/app && \
28-
rm -rf /usr/local/pkg
19+
gem install bundler && \
20+
bundle install -j4
2921

30-
ENTRYPOINT ["nib"]
31-
CMD ["--help"]
22+
COPY . .
23+
24+
CMD rspec spec

Dockerfile.test

Lines changed: 0 additions & 31 deletions
This file was deleted.

Gemfile.lock

Lines changed: 0 additions & 61 deletions
This file was deleted.

README.md

Lines changed: 9 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,14 @@
55

66
`nib` is a `docker-compose` wrapper geared towards Ruby/Rails development.
77

8+
## Install
9+
10+
To install:
11+
12+
```sh
13+
> gem install nib
14+
```
15+
816
## Usage
917

1018
`nib` can be used as a replacement for `docker-compose` any commands that it does not recognize will be delegated to `docker-compose`.
@@ -20,7 +28,7 @@ root@fd80bbc4ab5a:/usr/src/app#
2028
1. `nib` will also hook up a history file for your shell session (relative to the current project). This means that you will be able to use the history (up arrow) in future shell sessions, something that is not available with vanilla docker/docker-compose!
2129
1. Finally `nib` will ensure that the container is removed after you finish with the shell session
2230

23-
Some commands can have their behavior changed relative to a particiulair project. As an example - `nib console` expects a Ruby like environment (`rails console` or `pry` etc) by default but it can be augmented by adding a custom script on the host system (`$pwd/bin/console`)
31+
Some commands can have their behavior changed relative to a particular project. As an example - `nib console` expects a Ruby like environment (`rails console` or `pry` etc) by default but it can be augmented by adding a custom script on the host system (`$pwd/bin/console`)
2432

2533
Other commands like `nib rake` or `nib guard` behave as expected without the option to change the behavior.
2634

@@ -30,40 +38,6 @@ For additional information and a list of [supported commands](./docs/commands.md
3038
> nib help
3139
```
3240

33-
## Install
34-
35-
1. The most convenient way to use nib is by creating an alias or shell function. Here is an alias you can add to your profile that will make `nib` appear as a command.
36-
37-
```sh
38-
alias nib='
39-
docker run \
40-
-it \
41-
--rm \
42-
-v $(pwd):$(pwd) \
43-
-w $(pwd) \
44-
-v $HOME/.docker:/root/.docker:ro \
45-
-v /var/run/docker.sock:/var/run/docker.sock \
46-
-e "DOCKER_HOST_URL=$DOCKER_HOST" \
47-
technekes/nib'
48-
```
49-
50-
1. Start a new bash session and run `nib help` to see the available commands (there may be a brief pause as the image is pulled from docker hub)
51-
52-
## Updates
53-
54-
To get the latest version of `nib` use the `update` command. This just pulls the latest version of `technekes/nib:latest` from the Docker Hub.
55-
56-
```sh
57-
❯ nib update
58-
latest: Pulling from technekes/nib
59-
03e1855d4f31: Already exists
60-
a3ed95caeb02: Already exists
61-
8bfa9c6cbe2e: Already exists
62-
48868f5a50c8: Already exists
63-
Digest: sha256:47a8796f7f4f35fef13c67f14e275273927130c9bad72a09822aa4723bbdffa2
64-
Status: Image is up to date for technekes/nib:latest
65-
```
66-
6741
## Debugging
6842

6943
nib can help facilitate remote debugging of a running byebug server inside of a rails application. In order to make this work there are a couple of steps you'll need to take first.
@@ -101,39 +75,6 @@ Once all of this is in place and the web service is up and running (`nib up`) yo
10175
> nib debug web
10276
```
10377

104-
## Development
105-
106-
While making changes to `nib` it can be helpful to run a development version to test out commands. One way to accomplish this is by building the image and creating an extra alias for the local copy.
107-
108-
Make a change and build:
109-
110-
```
111-
cd /path/to/technekes/nib
112-
# make some changes
113-
docker build --tag nibdev:latest .
114-
```
115-
116-
Development alias:
117-
118-
```sh
119-
alias nibdev='
120-
docker run \
121-
-it \
122-
--rm \
123-
-v $(pwd):$(pwd) \
124-
-w $(pwd) \
125-
-v $HOME/.docker:/root/.docker:ro \
126-
-v /var/run/docker.sock:/var/run/docker.sock \
127-
-e "DOCKER_HOST_URL=$DOCKER_HOST" \
128-
nibdev:latest'
129-
```
130-
131-
Try out your command:
132-
133-
```sh
134-
nibdev shell web
135-
```
136-
13778
## Running Specs
13879

13980
This project includes [rspec](http://rspec.info/) and [serverspec](http://serverspec.org/) to help facilitate execution of automated tests. Running the tests is as simple as:

Rakefile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ begin
1313

1414
desc 'Run integration specs'
1515
RSpec::Core::RakeTask.new(:integration) do |task|
16-
ENV['INTEGRATION'] = 'true'
1716
task.rspec_opts = "--pattern '#{pattern}'"
1817
end
1918
end

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.1.0
1+
1.2.0

bin/nib

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -180,11 +180,4 @@ command :shell do |c|
180180
end
181181
end
182182

183-
desc 'Download the latest version of the nib tool'
184-
command :update do |c|
185-
c.action do |global, options, args|
186-
Nib::Update.execute(args)
187-
end
188-
end
189-
190183
exit run(ARGV)

bin/release

Lines changed: 1 addition & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -39,32 +39,4 @@ Please update the VERSION file, it currently matches the previous release"
3939
exit 1
4040
fi
4141

42-
case $1 in
43-
--pre)
44-
echo "pre-release, not publishing \"latest\" tag"
45-
46-
release_type="beta"
47-
;;
48-
*)
49-
if [[ $(git symbolic-ref --short -q HEAD) != "master" ]]; then
50-
echo "Tried to release from a branch other than master without --pre"
51-
exit 0
52-
fi
53-
relase_type="latest"
54-
;;
55-
esac
56-
57-
# delete local "latest" tag
58-
git tag -d "${release_type}"
59-
60-
# delete remote "latest" tag
61-
git push origin ":refs/tags/${release_type}"
62-
63-
# tag current commit with "latest"
64-
git tag "${release_type}"
65-
66-
# tag with version from VERSION
67-
git tag "v$(cat VERSION)"
68-
69-
# push to origin
70-
git push origin HEAD --tag
42+
rake release

codeship-services.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
app:
2-
build:
3-
context: .
4-
dockerfile: Dockerfile.test
2+
build: .
53
volumes:
64
- /var/run/docker.sock:/var/run/docker.sock
75
encrypted_env_file: codeship.env.encrypted

0 commit comments

Comments
 (0)