8000 Split onbuild and base in to two images · Issue #5 · heroku/docker-ruby · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
This repository was archived by the owner on Oct 16, 2024. It is now read-only.

Split onbuild and base in to two images #5

Open
jmervine opened this issue Aug 25, 2015 · 4 comments
Open

Split onbuild and base in to two images #5

jmervine opened this issue Aug 25, 2015 · 4 comments

Comments

@jmervine
Copy link

For local development, where someone doesn't want to build their code in to a container, 8000 but rather mount their code in, it could awesome if we could split these in to two images...

This will allow for people to do things like: docker run --rm -it -v $(pwd):. heroku/ruby-base:2.2.2 bash and enter a development environment, without building their code in. Super useful to me, not sure about everyone else.

Something like (but untested):

base: heroku/ruby-base:{ruby_version}

# file:Dockerfile-base
FROM heroku/cedar:14
MAINTAINER Terence Lee <terence@heroku.com>

ENV RUBY_VERSION=2.2.3
ENV RUBY_MAJOR=2.2.2
ENV NODE_VERSION=0.12.7

RUN mkdir -p /app/user
WORKDIR /app/user

ENV GEM_PATH /app/heroku/ruby/bundle/ruby/${RUBY_MAJOR}
ENV GEM_HOME /app/heroku/ruby/bundle/ruby/${RUBY_MAJOR}
RUN mkdir -p /app/heroku/ruby/bundle/ruby/${RUBY_MAJOR}

# Install Ruby
RUN mkdir -p /app/heroku/ruby/ruby-${RUBY_VERSION}
RUN curl -s --retry 3 -L https://heroku-buildpack-ruby.s3.amazonaws.com/cedar-14/ruby-${RUBY_VERSION}.tgz | tar xz -C /app/heroku/ruby/ruby-${RUBY_VERSION}
ENV PATH /app/heroku/ruby/ruby-${RUBY_VERSION}/bin:$PATH

# Install Node
RUN curl -s --retry 3 -L http://s3pository.heroku.com/node/v${NODE_VERSION}/node-v${NODE_VERSION}-linux-x64.tar.gz | tar xz -C /app/heroku/ruby/
RUN mv /app/heroku/ruby/node-v${NODE_VERSION}-linux-x64 /app/heroku/ruby/node-${NODE_VERSION}
ENV PATH /app/heroku/ruby/node-${NODE_VERSION}/bin:$PATH

# Install Bundler
RUN gem install bundler -v 1.9.10 --no-ri --no-rdoc
ENV PATH /app/user/bin:/app/heroku/ruby/bundle/ruby/${RUBY_MAJOR}/bin:$PATH

onbuild: heroku/ruby:{ruby_version}

# file:Dockerfile
FROM heroku/ruby-base:latest

ENV BUNDLE_APP_CONFIG /app/heroku/ruby/.bundle/config

# Run bundler to cache dependencies
ONBUILD COPY ["Gemfile", "Gemfile.lock", "/app/user/"]
ONBUILD RUN bundle install --path /app/heroku/ruby/bundle --jobs 4
ONBUILD ADD . /app/user

# How to conditionally `rake assets:precompile`?
ONBUILD ENV RAILS_ENV production
ONBUILD ENV SECRET_KEY_BASE $(openssl rand -base64 32)
ONBUILD RUN bundle exec rake assets:precompile

# export env vars during run time
RUN mkdir -p /app/.profile.d/
RUN echo "cd /app/user/" > /app/.profile.d/home.sh
ONBUILD RUN echo "export PATH=\"$PATH\" GEM_PATH=\"$GEM_PATH\" GEM_HOME=\"$GEM_HOME\" RAILS_ENV=\"\${RAILS_ENV:-$RAILS_ENV}\" SECRET_KEY_BASE=\"\${SECRET_KEY_BASE:-$SECRET_KEY_BASE}\" BUNDLE_APP_CONFIG=\"$BUNDLE_APP_CONFIG\"" > /app/.profile.d/ruby.sh

COPY ./init.sh /usr/bin/init.sh
RUN chmod +x /usr/bin/init.sh

ENTRYPOINT ["/usr/bin/init.sh"]
@jmervine jmervine changed the title Split onbuild and base in to two containers... Split onbuild and base in to two images Aug 25, 2015
@paulodiovani
Copy link

👍

@itsmeduncan
Copy link

Would this allow developers also to add pre-requisites to their Dockerfile? For local development, we need to run capybara-webkit which has an upstream dependency on qt5. There is currently no way to do this today... #10 😭

@paulodiovani
Copy link

@itsmeduncan No. This PR is to allow running a container without building an image.

@paulodiovani
Copy link

@itsmeduncan Docker does not allow to change ONBUILD steps neither add extra steps before they.
If you need different dependencies/steps, the solution if to create your own Dockerfile from heroku/cedar:14, as I did in paulodiovani/docker-heroku-ruby

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants
0