├── .dockerdev └── .bashrc ├── .gitignore ├── Dockerfile ├── README.md ├── dip.yml └── docker-compose.yml /.dockerdev/.bashrc: -------------------------------------------------------------------------------- 1 | PS1="[\[\e[31m\]\w\[\e[0m\]] " -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Numerous always-ignore extensions 2 | *.diff 3 | *.err 4 | *.orig 5 | *.log 6 | *.rej 7 | *.swo 8 | *.swp 9 | *.vi 10 | *~ 11 | *.sass-cache 12 | *.iml 13 | .idea/ 14 | 15 | # Sublime 16 | *.sublime-project 17 | *.sublime-workspace 18 | 19 | # OS or Editor folders 20 | .DS_Store 21 | .cache 22 | .project 23 | .settings 24 | .tmproj 25 | Thumbs.db 26 | 27 | .bundle/ 28 | log/*.log 29 | *.gz 30 | *.override.yml 31 | 32 | pkg/ 33 | tmp/ 34 | 35 | ruby/ 36 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | # Based on https://gist.github.com/kirs/3912e1a44b67fda906ab4f6aad09ebaf (from https://kirshatrov.com/2020/01/11/contributing-to-mri/) 2 | FROM ruby:3.1-bullseye 3 | 4 | ENV DEBIAN_FRONTEND=noninteractive 5 | 6 | # tools you need to build MRI 7 | RUN apt-get update && \ 8 | apt-get install -y git autoconf bison gcc make \ 9 | zlib1g-dev libffi-dev libreadline-dev \ 10 | libgdbm-dev libssl-dev build-essential \ 11 | tzdata 12 | 13 | # Configure bundler 14 | ENV LANG=C.UTF-8 \ 15 | BUNDLE_JOBS=4 \ 16 | BUNDLE_RETRY=3 17 | 18 | # Upgrade RubyGems and install required Bundler version 19 | RUN gem update --system && \ 20 | gem install bundler -v "~> 2.0" 21 | 22 | # Install benchmark-driver 23 | RUN gem install benchmark-driver 24 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Ruby MRI development with Docker and Dip 2 | 3 | The repo contains Docker and [Dip][] configuration for developing Ruby MRI. 4 | 5 | ## Usage 6 | 7 | - Clone Ruby to next to this project's folder: 8 | 9 | ```sh 10 | git clone https://github.com/ruby/ruby.git ../ruby 11 | ``` 12 | 13 | If you want to keep Ruby source code in the different location, create a `dip.override.yml` file with following contents: 14 | 15 | ```yml 16 | # dip.override.yml 17 | environment: 18 | RUBY_SRC_PATH: "relative/path/to/ruby" 19 | ``` 20 | 21 | - Install [Dip][] 22 | 23 | - Provision the dev container and volumes: 24 | 25 | ```sh 26 | dip provision 27 | ``` 28 | 29 | - Run make tasks with Dip: 30 | 31 | ```sh 32 | dip make 33 | 34 | # for example, to run pattern matching tests 35 | dip make test-all TESTS='test/ruby/test_pattern_matching.rb' 36 | ``` 37 | 38 | - Login into the container: 39 | 40 | ```sh 41 | dip bash 42 | ``` 43 | 44 | - (Optionally for VS Code users) Run container in the background and connect to it via [Remote Containers](https://code.visualstudio.com/docs/remote/attach-container) feature: 45 | 46 | ```sh 47 | dip up -d dev 48 | 49 | # go to Remote-Container: Attach to Running Container... 50 | # and chooose ruby_dev_1 51 | ``` 52 | 53 | ## Acknowledgments 54 | 55 | Inspired by [@kirs][] post ["Contributing to Ruby MRI"](https://kirshatrov.com/2020/01/11/contributing-to-mri/). 56 | The main difference is that the setup from this repo is IDE-agnostic (and at the same time plays well with VS Code Remote Containers). 57 | 58 | ## Resources 59 | 60 | - [Contributing to Ruby MRI](https://kirshatrov.com/2020/01/11/contributing-to-mri/) 61 | - [Ruby Hack challenge repo](https://github.com/ko1/rubyhackchallenge/tree/master/EN) 62 | - [VM stacks "puts-debugging" gist](https://gist.github.com/palkan/dcab4ed0978dfe6f55f9b6533d3e80a9) 63 | 64 | [Dip]: https://github.com/bibendi/dip 65 | [@kirs]: https://github.com/kirs 66 | -------------------------------------------------------------------------------- /dip.yml: -------------------------------------------------------------------------------- 1 | version: '4' 2 | 3 | environment: 4 | RUBY_SRC_PATH: "../ruby" 5 | 6 | compose: 7 | files: 8 | - docker-compose.yml 9 | project_name: ruby 10 | 11 | interaction: 12 | bash: 13 | description: Open a Bash shell in app's container 14 | service: dev 15 | command: /bin/bash 16 | 17 | make: 18 | description: Run make tasks 19 | service: dev 20 | command: make 21 | 22 | provision: 23 | - dip bash autoconf 24 | - dip bash ./configure 25 | - dip make 26 | -------------------------------------------------------------------------------- /docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: '3' 2 | services: 3 | dev: 4 | build: 5 | dockerfile: Dockerfile 6 | context: ./ 7 | command: sleep infinity 8 | image: ruby-dev:1.2 9 | volumes: 10 | - ${RUBY_SRC_PATH}:/${PWD}/ruby:cached 11 | - .dockerdev/.bashrc:/root/.bashrc:ro 12 | - hist:/usr/hist/:cached 13 | environment: 14 | HISTFILE: /usr/hist/.bash_history 15 | PROMPT_DIRTRIM: 2 16 | PS1: '[\W]\! ' 17 | working_dir: ${PWD}/ruby 18 | tmpfs: 19 | - /tmp 20 | 21 | volumes: 22 | hist: 23 | --------------------------------------------------------------------------------