Skip to content

Instantly share code, notes, and snippets.

@narath
Last active June 13, 2020 16:47
Show Gist options
  • Save narath/652b85f7c4398c02fc25b18b5c32a28a to your computer and use it in GitHub Desktop.
Save narath/652b85f7c4398c02fc25b18b5c32a28a to your computer and use it in GitHub Desktop.
Running Rails on Aptible
before_release:
- bundle exec rake db:migrate
# config/database.yml
default: &default
adapter: postgresql
encoding: unicode
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
development:
<<: *default
database: app_development
test:
<<: *default
database: app_test
production:
<<: *default
url: <%= ENV["DATABASE_URL"] %>
FROM ruby:2.6.5-slim-stretch
# from https://medium.com/@yuliaoletskaya/how-to-start-your-rails-app-in-a-docker-container-9f9ce29ff6d6
# also helpful https://blog.engineyard.com/using-docker-for-rails
RUN apt-get update && apt-get install -y \
curl \
build-essential \
libpq-dev &&\
curl -sL https://deb.nodesource.com/setup_10.x | bash - && \
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - && \
echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list && \
apt-get update && apt-get install -y nodejs yarn
# once working, consider cleaning up files
# && rm -rf /var/lib/apt/lists/*
ADD . /app
WORKDIR /app
EXPOSE 3000
ENV RAILS_ENV production
ENV RAILS_SERVE_STATIC_FILES true
ENV RAILS_LOG_TO_STDOUT true
# COPY Gemfile .
# COPY Gemfile.lock .
RUN gem update bundler
RUN bundle install --jobs 5 --without development test
# COPY package.json .
# COPY yarn.lock .
RUN yarn install
# Collect assets. This approach is not fully production-ready, but
# will help you experiment with Aptible Deploy before bothering with assets.
# Review http://go.aptible.com/assets for production-ready advice.
RUN set -a \
&& . /app/.aptible.env \
&& bundle exec rake assets:precompile
CMD ["bundle", "exec", "rails", "s", "-b", "0.0.0.0", "-p", "3000"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment