meteordockergraphicsmagickmeteor-up

Meteor Up Docker and Graphicsmagick


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

Solution

  • 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.