Skip to content

Instantly share code, notes, and snippets.

@marclennox
Last active June 26, 2020 00:44
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save marclennox/2fe7e671eda9ea12935f87133e70077c to your computer and use it in GitHub Desktop.
Save marclennox/2fe7e671eda9ea12935f87133e70077c to your computer and use it in GitHub Desktop.
Using PRY remote seamlessly in a Rails server
# config/docker-compose.yml
...
rails-web:
hostname: rails-web
env_file:
- application.env
environment:
- RAILS_ENV
- PORT=9292
- PRY_LISTEN_ADDRESS=rails-web
- PRY_LISTEN_PORT=9876
image: tenstartups/rails:alpine
command: web
ports:
- 9292
volumes:
- ..:/usr/src/app
- bundler-data:/usr/local/lib/ruby/bundler
depends_on:
- redis
- memcached
- postgresql
- minio
- elasticsearch
- mosquitto
rails-app:
env_file:
- application.env
environment:
- HOME=/usr/src/app
- RAILS_ENV
image: tenstartups/rails:alpine
volumes:
- ..:/usr/src/app
- bundler-data:/usr/local/lib/ruby/bundler
depends_on:
- redis
- memcached
- postgresql
- minio
- elasticsearch
- rails-web
- rails-worker
...
run --rm rails-app bundle exec pry-remote -w -s rails-web
# config/initializers/pry_remote.rb
unless STDIN.tty?
class Object
def pry
PryRemote::Server.new(self, (ENV['PRY_LISTEN_ADDRESS'] || '127.0.0.1'), (ENV['PRY_LISTEN_PORT'] || 9876)).run
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment