Skip to content

Instantly share code, notes, and snippets.

@oalders
Created January 6, 2023 20:14
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/7e8029314fe725a5d3bf7414690307e7 to your computer and use it in GitHub Desktop.
Save oalders/7e8029314fe725a5d3bf7414690307e7 to your computer and use it in GitHub Desktop.
Testing Rails apps in Docker (unzip archive in the container)
#!/bin/bash
# Create an empty dir which contains only the .zip file of your app
# 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:/sandbox ruby:3.2.0-bullseye ./sandbox/setup.sh
set -eux
mkdir /app
cd /app
unzip /sandbox/app.zip
# Assuming the zip archive politely unzips into a new child dir
cd some-dir-name
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
# 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