Last active
March 22, 2016 09:27
-
-
Save kimihito/210f70c9e69af22983c8 to your computer and use it in GitHub Desktop.
Docker images for deploying Heroku to use npm
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
web: | |
build: . | |
command: 'bash -c ''bundle exec puma -C config/puma.rb''' | |
working_dir: /app/user | |
environment: | |
RAILS_ENV: 'production' | |
RACK_ENV: 'production' | |
PORT: 8080 | |
DATABASE_URL: 'postgres://postgres:@herokuPostgresql:5432/postgres' | |
ports: | |
- '8080:8080' | |
links: | |
- herokuPostgresql | |
shell: | |
build: . | |
command: bash | |
working_dir: /app/user | |
environment: | |
PORT: 8080 | |
DATABASE_URL: 'postgres://postgres:@herokuPostgresql:5432/postgres' | |
ports: | |
- '8080:8080' | |
links: | |
- herokuPostgresql | |
volumes: | |
- '.:/app/user' | |
herokuPostgresql: | |
image: postgres |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# cf: https://hub.docker.com/r/heroku/ruby/~/dockerfile/ | |
FROM heroku/cedar:14 | |
RUN mkdir -p /app/user | |
WORKDIR /app/user | |
ENV GEM_PATH /app/heroku/ruby/bundle/ruby/2.2.0 | |
ENV GEM_HOME /app/heroku/ruby/bundle/ruby/2.2.0 | |
RUN mkdir -p /app/heroku/ruby/bundle/ruby/2.2.0 | |
# Install Ruby | |
RUN mkdir -p /app/heroku/ruby/ruby-2.2.3 | |
RUN curl -s --retry 3 -L https://heroku-buildpack-ruby.s3.amazonaws.com/cedar-14/ruby-2.2.3.tgz | tar xz -C /app/heroku/ruby/ruby-2.2.3 | |
ENV PATH /app/heroku/ruby/ruby-2.2.3/bin:$PATH | |
# Install Node | |
RUN curl -s --retry 3 -L http://s3pository.heroku.com/node/v0.12.7/node-v0.12.7-linux-x64.tar.gz | tar xz -C /app/heroku/ruby/ | |
RUN mv /app/heroku/ruby/node-v0.12.7-linux-x64 /app/heroku/ruby/node-0.12.7 | |
ENV PATH /app/heroku/ruby/node-0.12.7/bin:/app/user/node_modules/.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/2.2.0/bin:$PATH | |
ENV BUNDLE_APP_CONFIG /app/heroku/ruby/.bundle/config | |
# Run bundler and npm to cache dependencies | |
COPY ["Gemfile", "Gemfile.lock", "package.json", "/app/user/"] | |
RUN bundle install --path /app/heroku/ruby/bundle --jobs 4 | |
RUN /app/heroku/ruby/node-0.12.7/bin/npm install | |
ADD . /app/user | |
# How to conditionally `rake assets:precompile`? | |
ENV RAILS_ENV production | |
ENV SECRET_KEY_BASE $(openssl rand -base64 32) | |
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 | |
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"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
for SCRIPT in /app/.profile.d/*; | |
do source $SCRIPT; | |
done | |
exec "$@" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"private": true, | |
"dependencies" : { | |
"babel-plugin-transform-es2015-modules-commonjs": "^6.3.16", | |
"babel-preset-es2015": "^6.3.13", | |
"babelify": "^7.2.0", | |
"browserify": "~10.2.4", | |
"browserify-incremental": "^3.0.1" | |
}, | |
"license": "MIT", | |
"engines": { | |
"node": ">= 0.10" | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
web: bundle exec puma -C config/puma.rb |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment