Skip to content

Commit

Permalink
add docker development files (#4)
Browse files Browse the repository at this point in the history
* [skip travis] add docker development files

* move entrypoint to compose file

* [skip travis] exclude dev from spec.files

* use a docker managed volume for bundler

avoids permission issues with non-root user
  • Loading branch information
NgariNdungu authored Oct 31, 2020
1 parent 6681394 commit 64b6754
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 2 deletions.
15 changes: 14 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,20 @@ After checking out the repo, run `bin/setup` to install dependencies. Then, run

To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).

### With Docker

You will find docker files in the `dev` directory. Edit the `docker-compose.yaml` to suit your existing setup.
To build the image, run;
```
docker-compose build
```
Then open a shell into the container with;
```
docker-compose run air bash
```
`docker-compose up` will run the tests and exit.

## Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/active_interaction_rails.
Bug reports and pull requests are welcome on GitHub at https://github.com/NgariNdungu/active_interaction_rails.

2 changes: 1 addition & 1 deletion active_interaction_rails.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Gem::Specification.new do |spec|
# Specify which files should be added to the gem when it is released.
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features|dev)/}) }
end
spec.bindir = "exe"
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
Expand Down
7 changes: 7 additions & 0 deletions dev/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
FROM ruby:2.7.0-slim-buster
RUN apt-get update \
&& apt-get install -yq --no-install-recommends build-essential libsqlite3-dev git curl \
&& rm -rf /var/lib/apt/lists/*
RUN adduser dev --system --group --uid 1000
USER dev:dev
RUN gem install rails --version '~> 6.0' --no-document
17 changes: 17 additions & 0 deletions dev/docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
version: "3.7"
services:
air:
build:
context: ../
dockerfile: dev/Dockerfile
image: ngarindungu/rails-dev
entrypoint: ["/bin/bash", "dev/entrypoint.sh"]
command: "bundle exec rake"
working_dir: /home/dev/active_interaction_rails
volumes:
- ../:/home/dev/active_interaction_rails
- bundle:/usr/local/bundle

volumes:
bundle:
9 changes: 9 additions & 0 deletions dev/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash
# clear pid before starting server
rm -f tmp/pids/server.pid
# check if Gemfile has changed and bundle
if [[ -e "Gemfile" ]]; then
bundle check || bundle install
fi
# execute commands
exec "$@"

0 comments on commit 64b6754

Please sign in to comment.