├── .github └── workflows │ └── build.yml ├── .gitignore ├── Dockerfile ├── Dockerfile-glibc ├── LICENSE ├── README.md └── gemrc /.github/workflows/build.yml: -------------------------------------------------------------------------------- 1 | name: Build and Push Docker Images 2 | 3 | on: 4 | push: 5 | workflow_dispatch: 6 | # schedule: 7 | # - cron: '0 0 * * *' # runs every day at midnight 8 | # 9 | defaults: 10 | run: 11 | shell: bash -euo pipefail {0} 12 | 13 | jobs: 14 | build-and-push: 15 | runs-on: ubuntu-latest 16 | concurrency: 17 | group: ${{ github.repository }}-${{ github.workflow_ref }}-${{ matrix.alpine_version }}-build 18 | cancel-in-progress: false 19 | timeout-minutes: 60 20 | strategy: 21 | max-parallel: 64 22 | fail-fast: false 23 | matrix: 24 | alpine_version: 25 | - latest 26 | - edge 27 | - 3.8 28 | - 3.9 29 | - 3.10 30 | - 3.11 31 | - 3.12 32 | - 3.13 33 | - 3.14 34 | - 3.15 35 | - 3.16 36 | - 3.17 37 | - 3.18 38 | - 3.19 39 | 40 | steps: 41 | - name: Check out code 42 | uses: actions/checkout@v4 43 | 44 | - name: Set up Docker Buildx 45 | uses: docker/setup-buildx-action@v3 46 | 47 | - name: Login to Docker Hub 48 | run: docker login -u andrius -p ${{ secrets.DOCKERHUB_TOKEN }} 49 | 50 | - name: Build and push image 51 | run: | 52 | if [ -f "Dockerfile-${{ matrix.alpine_version }}" ]; then 53 | DOCKERFILE="Dockerfile-${{ matrix.alpine_version }}" 54 | else 55 | DOCKERFILE="Dockerfile" 56 | fi 57 | 58 | docker buildx build \ 59 | --push \ 60 | --platform linux/amd64,linux/arm64 \ 61 | --tag andrius/alpine-ruby:${{ matrix.alpine_version }} \ 62 | --build-arg ALPINE_VERSION=${{ matrix.alpine_version }} \ 63 | --file $DOCKERFILE \ 64 | . 65 | 66 | - name: Build and push glibc image 67 | run: | 68 | if [ -f "Dockerfile-${{ matrix.alpine_version }}" ]; then 69 | DOCKERFILE="Dockerfile-glibc-${{ matrix.alpine_version }}" 70 | else 71 | DOCKERFILE="Dockerfile-glibc" 72 | fi 73 | 74 | docker buildx build \ 75 | --push \ 76 | --platform linux/amd64 \ 77 | --tag andrius/alpine-ruby:${{ matrix.alpine_version }} \ 78 | --build-arg ALPINE_VERSION=${{ matrix.alpine_version }} \ 79 | --file $DOCKERFILE \ 80 | . 81 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.gem 2 | *.rbc 3 | /.config 4 | /coverage/ 5 | /InstalledFiles 6 | /pkg/ 7 | /spec/reports/ 8 | /spec/examples.txt 9 | /test/tmp/ 10 | /test/version_tmp/ 11 | /tmp/ 12 | 13 | ## Specific to RubyMotion: 14 | .dat* 15 | .repl_history 16 | build/ 17 | 18 | ## Documentation cache and generated files: 19 | /.yardoc/ 20 | /_yardoc/ 21 | /doc/ 22 | /rdoc/ 23 | 24 | ## Environment normalization: 25 | /.bundle/ 26 | /vendor/bundle 27 | /lib/bundler/man/ 28 | 29 | # for a library or gem, you might want to ignore these files since the code is 30 | # intended to run in multiple environments; otherwise, check them in: 31 | # Gemfile.lock 32 | # .ruby-version 33 | # .ruby-gemset 34 | 35 | # unless supporting rvm < 1.11.0 or doing something fancy, ignore this: 36 | .rvmrc 37 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | # vim:set fenc=utf-8 ts=2 sw=2 sts=2 et ft=dockerfile: 2 | ARG ALPINE_VERSION 3 | FROM alpine:${ALPINE_VERSION} 4 | 5 | LABEL "org.opencontainers.image.authors"="Andrius Kairiukstis " 6 | LABEL "org.opencontainers.image.source"="https://github.com/andrius/alpine-ruby" 7 | LABEL "org.opencontainers.image.description"="Minimal dockerized ruby based on Alpine Linux" 8 | 9 | RUN apk --no-cache add bash 10 | 11 | SHELL ["/bin/bash", "-c"] 12 | 13 | RUN apk --no-cache add \ 14 | ca-certificates \ 15 | less \ 16 | libressl \ 17 | ruby \ 18 | ruby-bigdecimal \ 19 | ruby-etc \ 20 | ruby-io-console \ 21 | ruby-irb 22 | 23 | COPY gemrc /root/.gemrc 24 | 25 | # The following is needed for nokogiri 26 | ENV NOKOGIRI_USE_SYSTEM_LIBRARIES=1 27 | 28 | # It tries to install ruby bundler with failback to apk version and nokoiri 29 | RUN <&1); 32 | if [[ $ERR =~ \`(.+)\` ]]; then 33 | eval "${BASH_REMATCH[1]} 2>&1" 34 | fi || apk add ruby-bundler 35 | gem install json 36 | bundle config build.nokogiri --use-system-libraries 37 | bundle config git.allow_insecure true 38 | gem cleanup 39 | rm -rf /usr/lib/ruby/gems/*/cache/* 40 | apk del .build-dependencies 41 | EOF 42 | 43 | -------------------------------------------------------------------------------- /Dockerfile-glibc: -------------------------------------------------------------------------------- 1 | # vim:set fenc=utf-8 ts=2 sw=2 sts=2 et ft=dockerfile: 2 | ARG ALPINE_VERSION 3 | FROM frolvlad/alpine-glibc:alpine-${ALPINE_VERSION} 4 | 5 | LABEL "org.opencontainers.image.authors"="Andrius Kairiukstis " 6 | LABEL "org.opencontainers.image.source"="https://github.com/andrius/alpine-ruby" 7 | LABEL "org.opencontainers.image.description"="Minimal dockerized ruby based on frolvlad/alpine Linux (Alpine with GNU C library - glibc)" 8 | 9 | RUN apk --no-cache add bash 10 | 11 | SHELL ["/bin/bash", "-c"] 12 | 13 | RUN apk --no-cache add \ 14 | ca-certificates \ 15 | less \ 16 | libressl \ 17 | ruby \ 18 | ruby-bigdecimal \ 19 | ruby-etc \ 20 | ruby-io-console \ 21 | ruby-irb 22 | 23 | COPY gemrc /root/.gemrc 24 | 25 | # The following is needed for nokogiri 26 | ENV NOKOGIRI_USE_SYSTEM_LIBRARIES=1 27 | 28 | # It tries to install ruby bundler with failback to apk version and nokoiri 29 | RUN <&1); 32 | if [[ $ERR =~ \`(.+)\` ]]; then 33 | eval "${BASH_REMATCH[1]} 2>&1" 34 | fi || apk add ruby-bundler 35 | gem install json 36 | bundle config build.nokogiri --use-system-libraries 37 | bundle config git.allow_insecure true 38 | gem cleanup 39 | rm -rf /usr/lib/ruby/gems/*/cache/* 40 | apk del .build-dependencies 41 | EOF 42 | 43 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 Andrius Kairiukstis 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Ruby Docker image 2 | 3 | The smallest Docker image with Ruby, is based on Alpine Linux image, which is only a 5MB image. It does only include ruby and bundler gem. 4 | 5 | - [Github link](//github.com/andrius/alpine-ruby/) 6 | - [Docker hub link](//hub.docker.com/r/andrius/alpine-ruby/) 7 | 8 | ## Support 9 | 10 | This is minimal image with only necessary packages, to run your app in production. Image build by using only official applications from Alpine linux, and supported AS IS. 11 | 12 | ## Tags 13 | 14 | Tags referring Alpine ruby version, not ruby version. 15 | 16 | ## Usage Example 17 | 18 | Check ruby version: 19 | 20 | ``` 21 | docker run -ti --rm andrius/alpine-ruby:latest ruby -v 22 | ``` 23 | 24 | Hello, world: 25 | 26 | ```bash 27 | docker run -ti --rm andrius/alpine-ruby ruby -e "puts 'Hello, world!'" 28 | ``` 29 | 30 | Once you have run this command you will get printed 'Hello World' from Ruby! 31 | 32 | ## Development packages 33 | 34 | Sometimes you could need to install various gems, where development packages is mandatory. 35 | 36 | Usually it's enough to install following packages: 37 | 38 | ```bash 39 | apk add --update ruby-dev build-base \ 40 | libxml2-dev libxslt-dev pcre-dev libffi-dev \ 41 | mariadb-dev postgresql-dev 42 | ``` 43 | 44 | ## About nokogiri installation 45 | 46 | In order to install nokogiri, you could use alpine's version: 47 | 48 | ```bash 49 | apk add --update ruby-nokogiri 50 | ``` 51 | 52 | However you could need specific version or want to follow version from Gemfile, you could install it: 53 | 54 | ```bash 55 | # installing *dev stuff 56 | apk add --update ruby-dev build-base 57 | 58 | bundle install 59 | # or you could install gem directly 60 | gem install nokogiri -- --use-system-libraries 61 | 62 | # removing *dev stuff 63 | apk del ruby-dev build-base 64 | ``` 65 | -------------------------------------------------------------------------------- /gemrc: -------------------------------------------------------------------------------- 1 | --- 2 | gem: --no-ri --no-rdoc --no-document --suggestions 3 | install: --no-rdoc --no-ri 4 | update: --no-rdoc --no-ri 5 | 6 | :benchmark: false 7 | 8 | :verbose: true 9 | 10 | :backtrace: true 11 | 12 | :update_sources: true 13 | sources: 14 | - http://gems.rubyforge.org/ 15 | - http://rubygems.org/ 16 | --------------------------------------------------------------------------------