1

I'm deploying a rails application using Google App Engine and it takes a lot of time to reinstall libraries like rbenv, ruby,...

Is there anyway to prevent this, I just want to install new library only

Cụt Cánh
  • 375
  • 2
  • 10
  • 1
    Potentailly related: http://stackoverflow.com/questions/34500213/how-can-i-speed-up-rails-docker-deployments-on-google-cloud-platform – Dan Cornilescu Aug 19 '16 at 03:34

1 Answers1

1

Yeah... we're actively working on making this faster. In the interim, here's how you can make it faster. At the end of the day - all we're really doing with App Engine Flex is creating a Dockerfile for you, and then doing a docker build. With Ruby, we try to play some fancy tricks like letting you tell us what version of rbenv or ruby you want to run. If you're fine hard coding all of that, you can just use our base image.

To do that, first open the terminal and cd into the dir with your code. Then run:

gcloud beta app gen-config --custom

Follow along with the prompts. This is going to create a Dockerfile in your CWD. Go ahead and edit that file, and check out what it's doing. In the simplest form, you can delete most of it and end up with something like this:

FROM gcr.io/google_appengine/ruby
COPY . /app/
RUN  bundle install --deployment && rbenv rehash;
ENV RACK_ENV=production \
    RAILS_ENV=production \
    RAILS_SERVE_STATIC_FILES=true
RUN if test -d app/assets -a -f config/application.rb; then \
    bundle exec rake assets:precompile; \
    fi
ENTRYPOINT []
CMD bundle exec rackup -p $PORT

Most of the heavy lifting is already done in gcr.io/google_appengine/ruby, so you can just essentially add your code, perform any gem installs you need, and then set the entrypoint. You could also fork our base docker image and create your own. After you have this file, you should do a build to test it:

docker build -t myapp .

Now go ahead and run it, just to make sure:

docker run -it -p 8080:8080 myapp

Visit http://localhost:8080 to make sure it's all looking good. Now when you run glcoud app deploy the next time, we're going to use this Dockerfile. Should be much, much faster.

Hope this helps!

Justin Beckwith
  • 7,686
  • 1
  • 33
  • 55