Skip to content

Instantly share code, notes, and snippets.

@DoZator
Last active April 12, 2021 07:39
Show Gist options
  • Save DoZator/84629c047c0b81b2a3f61bc664086d52 to your computer and use it in GitHub Desktop.
Save DoZator/84629c047c0b81b2a3f61bc664086d52 to your computer and use it in GitHub Desktop.
Run old Rails 3.2 (Ruby 1.9.3) app for Development with Docker
Run MySQL container (MySQL 5.5.54)
    docker run --name mysql_db -e MYSQL_ALLOW_EMPTY_PASSWORD=yes -p 127.0.0.1:3306:3306 -d mysql:5.5.54
Restore MySQL backup
    cat backup.sql | docker exec -i CONTAINER mysql -u root --password=root DATABASE_NAME
Build image
    docker build -t rails_service .
Run docker container (in the app directory!)
    docker run --name rails_app -p 127.0.0.1:3000:3000 -v /$(pwd):/app --link mysql_db:database -d rails_service
FROM ruby:1.9.3
MAINTAINER DoZator <[email protected]>
# Create app directory
RUN mkdir -p /app
WORKDIR /app
COPY Gemfile /app/
COPY Gemfile.lock /app/
# Install dependencies
RUN apt-get update && apt-get install -qq -y build-essential nodejs npm
RUN gem install rails -v 3.2.13
RUN bundle install
# Default command to run
CMD ["rails", "s"]
EXPOSE 3000
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment