Last active
June 26, 2020 00:44
-
-
Save marclennox/2fe7e671eda9ea12935f87133e70077c to your computer and use it in GitHub Desktop.
Using PRY remote seamlessly in a Rails server
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 | |
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
run --rm rails-app bundle exec pry-remote -w -s rails-web |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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