Skip to content

Instantly share code, notes, and snippets.

@helstern
Last active September 4, 2019 13:31
Show Gist options
  • Select an option

  • Save helstern/99f858c04264b71de157579b9f0f1809 to your computer and use it in GitHub Desktop.

Select an option

Save helstern/99f858c04264b71de157579b9f0f1809 to your computer and use it in GitHub Desktop.

Revisions

  1. helstern revised this gist Sep 4, 2019. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion Makefile
    Original file line number Diff line number Diff line change
    @@ -5,7 +5,7 @@ PROJECT_NAME := $(basename $(PROJECT_ROOT))
    docker-build-2.5:
    docker build --tag rhelstern-ruby:2.5.5 --file ruby-2.5.Dockerfile .

    docker-build-2.5:
    docker-build-2.3:
    docker build --tag rhelstern-ruby:2.3.3 --file ruby-2.3.Dockerfile .

    docker-run-2.5:
  2. helstern created this gist Sep 4, 2019.
    31 changes: 31 additions & 0 deletions Makefile
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,31 @@
    mkfile_path := $(abspath $(lastword $(MAKEFILE_LIST)))
    PROJECT_ROOT := $(dir $(mkfile_path))
    PROJECT_NAME := $(basename $(PROJECT_ROOT))

    docker-build-2.5:
    docker build --tag rhelstern-ruby:2.5.5 --file ruby-2.5.Dockerfile .

    docker-build-2.5:
    docker build --tag rhelstern-ruby:2.3.3 --file ruby-2.3.Dockerfile .

    docker-run-2.5:
    docker run --rm \
    --network host \
    --volume ${PROJECT_ROOT}:/home/ruby/${PROJECT_NAME} \
    --volume $$HOME/.ssh:/home/ruby/.ssh \
    -w=/home/ruby/${PROJECT_NAME} \
    --user 1000 \
    -it rhelstern-ruby:2.5.5 \
    /bin/bash

    docker-run-2.3:
    docker run --rm \
    --network host \
    --volume ${PROJECT_ROOT}:/home/ruby/${PROJECT_NAME} \
    --volume $$HOME/.ssh:/home/ruby/.ssh \
    -w=/home/ruby/${PROJECT_NAME} \
    --user 1000 \
    -it rhelstern-ruby:2.3.3 \
    /bin/bash

    .PHONY: docker-run-2.5 docker-run-2.3 docker-build-2.5 docker-build-2.3
    43 changes: 43 additions & 0 deletions ruby-2.3.Dockerfile
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,43 @@
    FROM ruby:2.3.3-alpine

    RUN apk add --no-cache bash gawk sed grep bc coreutils git less openssh curl jq

    RUN addgroup -g 1000 ruby \
    && adduser \
    -S \
    -h /home/ruby \
    -G ruby \
    -u 1000 \
    ruby

    RUN apk add --no-cache \
    # gem 'oj', 'puma', 'byebug'
    make gcc libc-dev \

    # gem 'nokogiri'
    # bundle config --global build.nokogiri --use-system-libraries && \
    # apk --no-cache add make libxml2 libxslt-dev g++ && \
    make libxml2 libxslt-dev g++ \

    # gem 'rb-readline'
    ncurses \

    # gem 'ffi'
    libffi-dev \

    # gem 'mysql2'
    mysql-dev \

    # gem 'unf_ext'
    g++ \

    # gem 'tiny_tds'
    freetds-dev \

    # if you want to run git or something that requires ssl dependencies
    ca-certificates git \

    alpine-sdk build-base

    # we don't want bundler > 2, perhaps should go with gem install bundler -v '< 2'
    RUN gem uninstall -i /usr/local/lib/ruby/gems/2.3.0 --force bundler; gem install bundler -v '1.17.3'
    41 changes: 41 additions & 0 deletions ruby-2.5.Dockerfile
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,41 @@
    FROM ruby:2.5.5-alpine3.10

    RUN apk add --no-cache bash gawk sed grep bc coreutils git less openssh curl jq \
    && addgroup --gid 1000 ruby \
    && adduser \
    --disabled-password \
    --gecos "" \
    --home /home/ruby \
    --ingroup ruby \
    --uid 1000 \
    ruby

    RUN gem uninstall --force bundler

    RUN \
    # gem 'oj', 'puma', 'byebug'
    apk add --no-cache make gcc libc-dev && \

    # gem 'nokogiri'
    bundle config --global build.nokogiri --use-system-libraries && \
    apk add --no-cache make libxml2 libxslt-dev g++ && \

    # gem 'rb-readline'
    apk add --no-cache ncurses && \

    # gem 'ffi'
    apk add --no-cache libffi-dev && \

    # gem 'mysql2'
    apk add --no-cache mysql-dev && \

    # gem 'unf_ext'
    apk add --no-cache g++ && \

    # gem 'tiny_tds'
    apk add --no-cache freetds-dev && \

    # app dependencies
    apk add --no-cache ca-certificates git && \

    apk add --no-cache alpine-sdk build-base