Skip to content
This repository has been archived by the owner on Sep 6, 2022. It is now read-only.

Commit

Permalink
Add Docker-specific rake tasks (#857)
Browse files Browse the repository at this point in the history
* Add Docker-specific rake tasks
- Prevent conflicts with non-Docker setups

* Add :docker namespace
update non-docker task to be more rubyesque

* remove brew from docker dev bootstrap rake task

* Update dockerfile to use new docker namespace

* Add -o 0.0.0.0 to local dev for proper mapping

* use long-form parameter names instead of short
  • Loading branch information
taquitos committed May 14, 2018
1 parent 12fac6d commit be0f2ba
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 9 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ COPY Gemfile Gemfile.lock Rakefile ./
COPY . .
RUN bundle install

CMD ["hosted_prod_test"]
CMD ["docker:prod_test"]
ENTRYPOINT ["bundle", "exec", "rake"]
EXPOSE 8080
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ Currently, Docker deployment is for Linux projects only.

## Development installation

Run the rake task: `rake devbootstrap`.
Run the rake task: `rake dev_bootstrap`.
1. Install all dependencies (ruby, javascript)
2. Add a pre-commit hook

Expand Down
32 changes: 25 additions & 7 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,22 +1,40 @@
task :dev do
sh "bundle exec rackup -o 0.0.0.0 -p 8080 --env development"
sh "bundle exec rackup --host 0.0.0.0 --port 8080 --env development"
end

task :prod do
sh "bundle exec rackup -p 8080 --env production"
sh "bundle exec rackup --host 0.0.0.0 --port 8080 --env production"
end

task :hosted_prod_test do
sh("FASTLANE_CI_ERB_CLIENT=1 DEBUG=1 FASTLANE_CI_DISABLE_REMOTE_STATUS_UPDATE=1 FASTLANE_CI_DISABLE_PUSHES=1 FASTLANE_CI_SKIP_RESTARTING_PENDING_WORK=1 bundle exec rackup --host 0.0.0.0 -p 8080 --env development")
end

task :devbootstrap do
task :dev_bootstrap do
sh("bundle install")
sh("brew install node") unless sh("npm -v")
sh("npm install")
sh("ln -sf ../../.pre-commit .git/hooks/pre-commit")
end

# It seems like mapping ports in Docker requires --host which can break hosting in VMs
# So we'll just keep some docker-specific tasks down here
namespace :docker do
desc "Run in a Docker container in production mode"
task :prod do
sh "bundle exec rackup --host 0.0.0.0 --port 8080 --env production"
end

desc "Run in a Docker container with debugging on, no pushes, and no restarting work to help test config stuff"
task :prod_test do
# rubocop:disable Metrics/LineLength
sh("FASTLANE_CI_ERB_CLIENT=1 DEBUG=1 FASTLANE_CI_DISABLE_REMOTE_STATUS_UPDATE=1 FASTLANE_CI_DISABLE_PUSHES=1 FASTLANE_CI_SKIP_RESTARTING_PENDING_WORK=1 bundle exec rackup --host 0.0.0.0 --port 8080 --env development")
# rubocop:enable Metrics/LineLength
end

desc "Bootstrap for running in a Docker container"
task :dev_bootstrap do
sh("bundle install")
sh("npm install")
end
end

begin
require "rspec/core/rake_task"
RSpec::Core::RakeTask.new(:spec)
Expand Down

0 comments on commit be0f2ba

Please sign in to comment.