3

I have a ruby on rails app running on a Google Cloud Platform VM running on the app engine flexible environment. It looks like it installs most of the software on the VM when I deploy the app with gcloud --project project-name preview app deploy I think it installs rails and other software from reading the temporary dockerfile it creates. It grabs the info for the dockerfile from the app.yaml file (I got this setup from following their tutorials).

This was working fine for me but now I need to install ImageMagick onto the server to manipulate images on the site. Normally you do this by running sudo apt-get install imagemagick from the project directory. When I SSH onto the VM I cant find the project directory so that doesn't work.

I have no idea how to get it to run sudo apt-get install imagemagick each time I make a new deploy to the site so it has the software on the new VM.

As you might be able to tell I'm not very good with the server side of things and want to know what I'm supposed to do to get new software onto the VM the right way so its always there like ruby and rails etc.. are each time I make a new deploy.

Rob
  • 1,835
  • 2
  • 25
  • 53
  • 1
    Instead of default, you have to make a custom Dockerfile with this `sudo apt-get install imagemagick` command – Igor Artamonov Aug 21 '16 at 08:19
  • @IgorArtamonov Ok. So there will be 2 dockerfiles, the default one made on the deploy and the one I make so I runs `sudo apt-get install imagemagick`? I cant find anything on how to do this so it knows there is acustom dockerfile can you link some documentation on how this custom dockerfile should be setup or maybe a tutorial? – Rob Aug 21 '16 at 08:31
  • 1
    @Rob I think you'll need to look at building a [`custom`](https://cloud.google.com/appengine/docs/flexible/custom-runtimes/quickstart) runtime (i.e. instead of `ruby` in your `app.yaml`), based on one of the pre-defined ones, [here](https://cloud.google.com/appengine/docs/flexible/custom-runtimes/build) – tx802 Aug 21 '16 at 08:47
  • @IgorArtamonov looks like I can basically use the default dockerfile created when I do a deploy and just add a the command line to it. I'll let you know if it works and you can add it as the answer. – Rob Aug 21 '16 at 09:43
  • 1
    yes, exactly, copy default one, and add this line – Igor Artamonov Aug 21 '16 at 10:29
  • @IgorArtamonov I added the line `CMD apt-get install imagemagick` (tried with and without sudo) but I doesn't look like its installed. It doesn't give an output of what it did `Step 8 : CMD sudo apt-get install imagemagick ---> Running in eb815726a4a5`. If I use the app I get `Error: ImageMagick/GraphicsMagick is not installed` any ideas on how to see if its installed or how to show the output of the install so I know if it is actually not installed or some other problem causing the error? – Rob Aug 21 '16 at 12:53
  • @Rob no, not `CMD`, this is for final command to run containerized app. You need to use `RUN`, see docs https://docs.docker.com/engine/reference/builder/#/run – Igor Artamonov Aug 21 '16 at 12:57
  • Unfortunately I'm not a Ruby developer, so cannot provide full example of Dockerfile for Ruby. But I hope you'll figure it out, I suggest to read a tutorial for Docker – Igor Artamonov Aug 21 '16 at 12:59
  • @IgorArtamonov After some fiddling around I got it. I added `RUN apt-get update` and `RUN apt-get install imagemagick -y` to the custom dockerfile. Wouldn't have gotten it without your help. If want to add add an answer mentioning the custom dockerfile and add them lines I'll give you the answer. – Rob Aug 22 '16 at 02:46

1 Answers1

3

You should use a custom Dockerfile when you need additional configuration.

To install ImageMagics you have to set runtime: custom in your app.yaml, create a Dockerfile based on default one, and add following line:

RUN apt-get update && \
    apt-get install imagemagick -y
Igor Artamonov
  • 35,450
  • 10
  • 82
  • 113
  • 3
    Please remove the `and`, as it makes the build fail. It'd be nice if you mentioned that you can generate a default `Dockerfile` with `gcloud beta app gen-config --custom` – diogovk Feb 17 '17 at 17:22
  • `gcloud beta app gen-config --custom` was deprecated, I'm afraid. Might still work, but FYI. – Graham P Heath Feb 28 '20 at 20:44