Skip to content

Instantly share code, notes, and snippets.

@yc0
Created December 9, 2018 14:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yc0/63b5c95bc306d0f4b0a90182d882be2a to your computer and use it in GitHub Desktop.
Save yc0/63b5c95bc306d0f4b0a90182d882be2a to your computer and use it in GitHub Desktop.
Dockerfile for app
FROM ruby:2.3.1
RUN apt-get update -qq && apt-get install -y build-essential libpq-dev nodejs
# Set an environment variable where the Rails app is installed to inside of Docker image
ENV LC_ALL C.UTF-8
# Setup TZ
ENV TZ Asia/Taipei
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
ENV RAILS_ROOT /var/www/app
RUN mkdir -p $RAILS_ROOT
# Set working directory
WORKDIR $RAILS_ROOT
# Setting env up
ENV RAILS_ENV='production'
ENV RACK_ENV='production'
# Adding gems
# Adding project files
COPY ./app/{project}/Gemfile ./{project}/Gemfile
COPY ./app/{project}/Gemfile.lock ./{project}/Gemfile.lock
COPY ./app/{model}/Gemfile ./{model}/Gemfile
COPY ./app/{model}/Gemfile.lock ./{model}/Gemfile.lock
COPY ./app/{model}/lib/shoppe/version.rb ./{model}/lib/{model}/version.rb
COPY ./app/{model}/shoppe.gemspec ./{model}/{model}.gemspec
WORKDIR $RAILS_ROOT/easybuy
RUN bundle install --jobs 20 --retry 5 --without development test
WORKDIR $RAILS_ROOT
COPY ./app/{project}/ ./{project}/
COPY ./app/{model}/ ./{model}/
WORKDIR $RAILS_ROOT/{project}
COPY ./conf/email.yml ./config/email.yml
COPY ./conf/ecpay.yml ./config/ecpay.yml
COPY ./conf/facebook.yml ./config/facebook.yml
COPY ./conf/secrets.yml ./config/secrets.yml
COPY ./conf/redis.yml ./config/redis.yml
COPY ./conf/database.yml ./config/database.yml
RUN bundle exec rake assets:clean
RUN bundle exec rake tmp:clear
RUN bundle exec rake log:clear
RUN bundle exec rake assets:precompile
EXPOSE 3000
CMD ["bundle", "exec", "puma"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment