10

I'm looking for how to install Graphicsmagick at Meteor Up Docker.

I found this solution (Access binaries inside docker) but I couldn't make work, where do I put those lines at start.sh?

meteorDockerId=docker ps | grep meteorhacks/meteord:base | awk '{print $1}'
docker exec $meteorDockerId apt-get install graphicsmagick -y

That's my start.sh:

#!/bin/bash

APPNAME=instagatas
APP_PATH=/opt/$APPNAME
BUNDLE_PATH=$APP_PATH/current
ENV_FILE=$APP_PATH/config/env.list
PORT=80
USE_LOCAL_MONGO=0

# remove previous version of the app, if exists
docker rm -f $APPNAME

# remove frontend container if exists
docker rm -f $APPNAME-frontend

set -e
docker pull meteorhacks/meteord:base

if [ "$USE_LOCAL_MONGO" == "1" ]; then
  docker run \
    -d \
    --restart=always \
    --publish=$PORT:80 \
    --volume=$BUNDLE_PATH:/bundle \
    --env-file=$ENV_FILE \
    --link=mongodb:mongodb \
    --hostname="$HOSTNAME-$APPNAME" \
    --env=MONGO_URL=mongodb://mongodb:27017/$APPNAME \
    --name=$APPNAME \
    meteorhacks/meteord:base
else
  docker run \
    -d \
    --restart=always \
    --publish=$PORT:80 \
    --volume=$BUNDLE_PATH:/bundle \
    --hostname="$HOSTNAME-$APPNAME" \
    --env-file=$ENV_FILE \
    --name=$APPNAME \
    meteorhacks/meteord:base
fi


  docker pull meteorhacks/mup-frontend-server:latest
  docker run \
    -d \
    --restart=always \
    --volume=/opt/$APPNAME/config/bundle.crt:/bundle.crt \
    --volume=/opt/$APPNAME/config/private.key:/private.key \
    --link=$APPNAME:backend \
    --publish=443:443 \
    --name=$APPNAME-frontend \
    meteorhacks/mup-frontend-server /start.sh
Community
  • 1
  • 1
Guima Ferreira
  • 195
  • 1
  • 11

5 Answers5

14

Re-installing the graphicsmagick package every time you re-start the containers seems like a hack I wouldn't want to do.

If you're modifying the start script already, might as well use a Dockerfile:

FROM meteorhacks/meteord:base
RUN apt-get install graphicsmagick -y

Then modify start.sh template to build a new docker image with graphicsmagick, tag it and use that image instead:

see: https://gist.github.com/so0k/7d4be21c5e2d9abd3743/revisions

EDIT: Where to put Dockerfile?

start.sh template is copied to /opt/<appName>/config/, currently the Dockerfile would need to be in that same directory (/opt/<appName>/config/Dockerfile)

see Linux init Task

Alternatively, you can specify specific Dockerfile with the -f flag for the docker build

Or your third option is to pipe Dockerfile to docker build using a here document

I've updated the start.sh gist, we no longer pull the meteord:base image and build it instead:

docker build -t meteorhacks/meteord:app - << EOF
FROM meteorhacks/meteord:base
RUN apt-get install graphicsmagick -y
EOF

The docker build will run every time, but as long as the requirements aren't changing, docker will use the docker images it cached.

Vincent De Smet
  • 4,859
  • 2
  • 34
  • 41
  • I couldn't find where to put my Docker file. I putted at `/opt/instagatas/config` and `/opt/instagatas` but I'm seeing this message `Cannot locate Dockerfile: Dockerfile`. Where do I put it? – Guima Ferreira Aug 09 '15 at 12:45
  • I've updated my answer to address your comment where to put the Dockerfile, I think it might actually be better to pipe the contents to the `docker build` command within the start.sh template. – Vincent De Smet Aug 09 '15 at 15:41
  • I tried the third option and it worked if I use `mupx restart`, but when I do `mupx deploy` the `start.sh` change back to original, so I need to change the file again and restart. Theres a way to this don't happen? – Guima Ferreira Aug 09 '15 at 17:46
  • did you make the change to start.sh in the template folder or in the `/opt/.../config` folder? You should change the start.sh **template** – Vincent De Smet Aug 09 '15 at 20:14
  • I chagend at `/opt/.../conf`, I couldn't find the template file, where do I find it? – Guima Ferreira Aug 09 '15 at 21:53
  • I guess in your **global** npm directory? If you installed mup globally `npm install -g mup` – Vincent De Smet Aug 09 '15 at 23:33
  • awkwardly this didn't work for me - do i have to somehow reset mupx first? – Lukasstr Dec 08 '15 at 21:54
  • In global .npm/mupx directory I only have 2 files: package.tgz and package/package.json. Can you pls explain how to modify start.sh file in the template? Thanks – Ronen Jan 06 '16 at 16:33
  • 1
    For me it was in /usr/local/lib/node_modules/mupx/templates/linux/start.sh – PhilippSpo Jan 17 '16 at 10:45
  • @PhilippSpo is the real MVP here. Thanks a ton, how do we make this a config? is there a fork that already does it? – Mackenzie Browne Mar 13 '16 at 23:12
  • @mackbrowne - things changed since this question was asked and it is indeed a bad idea to modify your local mupx copy (your changes will be lost on updates). I personally don't use mupx, I just have experience with Docker & npm. If this functionality is required, somebody may fork and do a pull request to handle this instead... – Vincent De Smet Mar 14 '16 at 10:30
  • @VincentDeSmet Thanks for this, Easy short term solution is to fork mupx and then just keep it updated regularly with this single file change. Maybe I'll build it out into a feature and PR it back into the main repo. Thanks for the inspiration yo. Also your avatar is dope! – Mackenzie Browne Mar 14 '16 at 21:49
  • my avatar is only a rip from little dicky bc ppl say I look like him, honest! – Vincent De Smet Mar 15 '16 at 10:20
  • mupx show me a npm deprecated message and failed to install gm for me. – Dude Mar 16 '16 at 17:13
3

The development Version of Meteor Up at Kadirahq allows specification of a custom Docker Image in the config file (mup.js).

MeteorD-Images with Graphicsmagick installed are available on Docker Hub.

This got me a working deployment (Meteor 1.3.2.4, Meter Up 309cefb, Node v5.4.1):

mup.js:

module.exports = {
  …
  meteor: {
    dockerImage: 'ianmartorell/meteord-graphicsmagick',
    …
  },
};
bskp
  • 350
  • 4
  • 12
  • 1
    Did you have to download this docker image somewhere, or did you just make this change in the mup.js file and it worked? – JoshJoe Sep 09 '16 at 20:26
1

I couldn't get the docker image that @bskp mentioned to work, so I figured out how to write one that uses abernix/meteord:base and then has graphicsmagick installed. Very simple, but it seems to be working for me on Meteor 1.4.1.1

I just did this in my mup.js file

docker: {
  image: "joshjoe/meteor-graphicsmagick",
},

This was a huge pain to get working, so I'd be happy to help anyone who is struggling with this.

https://github.com/c316/meteor-graphicsmagick

bskp
  • 350
  • 4
  • 12
JoshJoe
  • 1,482
  • 2
  • 17
  • 35
0

If the if statement successes, you should be able to see a running container corresponding to the image you are grepping. In my opinion you can add the two lines after the fi to obtain the environment variable.

BY0B
  • 99
  • 1
  • 9
0

Build an image for get things right, but you can do temporary:

docker exec -it MeteorAppName apt-get install imagemagick -y

docker restart MeteorAppName

Check imagemagick: docker exec -it MeteorAppName convert -version

Liko
  • 2,130
  • 19
  • 20