Skip to content

Instantly share code, notes, and snippets.

@oalders
Created January 6, 2023 19:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save oalders/70bf0f9e60acadc042fd5a7a5382e17e to your computer and use it in GitHub Desktop.
Save oalders/70bf0f9e60acadc042fd5a7a5382e17e to your computer and use it in GitHub Desktop.
Testing Rails apps in Docker
#!/bin/bash
# Copy this file to your app dir
# Save it as `setup.sh`
# Then run it via:
# docker run --rm -it -p 3000:3000 --volume $PWD:/app ruby:3.2.0-bullseye ./app/setup.sh
set -eux
apt update
apt install -y rbenv
# Ensure later Ruby versions are available
git clone https://github.com/rbenv/ruby-build.git "$(rbenv root)"/plugins/ruby-build
rbenv install 3.0.1
cd /app
# Ensure rbenv env is set up and available
eval "$(rbenv init -)"
# Install application dependencies
bundle install
# Add any instructions required to set up and run the app below here
rails db:create
rails db:migrate
# On MacOS bind to 0.0.0.0 and then visit http://0.0.0.0:3000/
./bin/rails server -b 0.0.0.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment