|
1 | 1 | # Ruby 1.9.3 Docker Image |
2 | | -A Docker image that contains the latest versions of [RubyGems](https://github.com/rubygems/rubygems), [Bundler](https://bundler.io/), etc that are compatible with Ruby 1.9.3. |
| 2 | +A Docker image that contains the latest versions of [RubyGems](https://github.com/rubygems/rubygems), [Bundler](https://bundler.io/), etc that are compatible with Ruby 1.9.3. So instead of having to create Dockerfiles that looked like: |
| 3 | + |
| 4 | +```dockerfile |
| 5 | +FROM ruby:1.9.3 |
| 6 | + |
| 7 | +# Install stuff |
| 8 | +RUN apt-get update -qq && apt-get install -y build-essential |
| 9 | + |
| 10 | +# Working folder. |
| 11 | +RUN mkdir /app |
| 12 | +WORKDIR /app |
| 13 | +COPY . . |
| 14 | + |
| 15 | +# Install Gems. Use Bundler 1.17.3 as 2+ does not work with |
| 16 | +# Ruby 1.9.3. Also update the rubygems to prevent frozen string |
| 17 | +# errors. Rubygems 2.7.8 is the latest version to support Ruby 1.9.3. |
| 18 | +RUN gem install rubygems-update -v 2.7.8 |
| 19 | +RUN update_rubygems |
| 20 | +RUN gem install bundler -v 1.17.3 |
| 21 | +RUN bundle install |
| 22 | +``` |
| 23 | + |
| 24 | +The files now look like: |
| 25 | + |
| 26 | +```dockerfile |
| 27 | +FROM corigbytes/ruby-1.9.3:1.0.0` |
| 28 | + |
| 29 | +# Working folder. |
| 30 | +RUN mkdir /app |
| 31 | +WORKDIR /app |
| 32 | +COPY . . |
| 33 | + |
| 34 | +# Install Gems. |
| 35 | +RUN bundle install |
| 36 | +``` |
| 37 | + |
| 38 | +# Getting the Image |
| 39 | +You can find the image on DockerHub [here](https://hub.docker.com/r/corgibytes/ruby-1.9.3). To get the latest version, which is not guaranteed to be stable: |
| 40 | + |
| 41 | +`docker pull corgibytes/ruby-1.9.3` |
| 42 | + |
| 43 | +To get a specific version, which is stable: |
| 44 | + |
| 45 | +`docker pull corgibytes/ruby-1.9.3:<version>` |
| 46 | + |
| 47 | +For example: |
| 48 | + |
| 49 | +`docker pull corgibytes/ruby-1.9.3:1.0.0` |
| 50 | + |
| 51 | +Example Dockerfile and Compose to run a Rails app that uses Ruby 1.9.3: |
| 52 | + |
| 53 | +```dockerfile |
| 54 | +# Dockerfile |
| 55 | +FROM corigbytes/ruby-1.9.3:1.0.0` |
| 56 | + |
| 57 | +# Working folder. |
| 58 | +RUN mkdir /app |
| 59 | +WORKDIR /app |
| 60 | +COPY . . |
| 61 | + |
| 62 | +# Install Gems. |
| 63 | +RUN bundle install |
| 64 | +``` |
| 65 | + |
| 66 | +```yml |
| 67 | +# docker-compose.yml |
| 68 | +version: '3.7' |
| 69 | +services: |
| 70 | + web: |
| 71 | + build: . |
| 72 | + command: bundle exec rails s -p 3000 -b '0.0.0.0' |
| 73 | + entrypoint: ./docker-entrypoint.sh |
| 74 | + volumes: |
| 75 | + - .:/app |
| 76 | + - bunlder-data:/user/local/bundle |
| 77 | + ports: |
| 78 | + - "3000:3000" |
| 79 | + depends_on: |
| 80 | + - db |
| 81 | + |
| 82 | + db: |
| 83 | + image: postgres:9.6 |
| 84 | + ports: |
| 85 | + - "5432:5432" |
| 86 | + environment: |
| 87 | + POSTGRES_PASSWORD: password1234 |
| 88 | + volumes: |
| 89 | + - db-data:/var/lib/postgresql/data |
| 90 | + |
| 91 | +volumes: |
| 92 | + db-data: |
| 93 | + bundler-data: |
| 94 | +``` |
| 95 | +
|
| 96 | +```bash |
| 97 | +# docker-entrypoint.sh |
| 98 | +#!/bin/sh |
| 99 | + |
| 100 | +rm -f tmp/pids/server.pid |
| 101 | +exec "$@" |
| 102 | +``` |
| 103 | + |
| 104 | +# Versioning |
| 105 | +This image is setup using DockerHub's automate builds. It will build on every commit to master and tag it as `latest`. It will build also build on every tag that has the format `v.#.#.#` and tag the build as `#.#.#`. For example if a release is tagged as `v.1.0.0` a DockerHub image will be created with the tag `1.0.0`. |
| 106 | + |
| 107 | +The tagged versions are stable where as the latest version is not guaranteed to be stable. |
| 108 | + |
| 109 | +You can find a full list of the built tags on [DockerHub](https://hub.docker.com/r/corgibytes/ruby-1.9.3/tags). |
| 110 | + |
| 111 | +# Contributing |
| 112 | +If you have any questions, notice a bug, or have a suggestion/enhancment please let me know by opening [issue](https://github.com/corgibytes/ruby_193_docker/issues) or [pull request](https://github.com/corgibytes/ruby_193_docker/pulls). |
| 113 | + |
| 114 | +# Acknowledgements |
| 115 | +Thanks to the Ruby team for creating orginial [Ruby Docker images](https://hub.docker.com/_/ruby). |
0 commit comments