diff --git a/Dockerfile b/Dockerfile index 3e7f1c4..65b9580 100644 --- a/Dockerfile +++ b/Dockerfile @@ -30,6 +30,9 @@ ONBUILD ENV APT_GET_INSTALL $APT_GET_INSTALL ONBUILD ARG NODE_VERSION ONBUILD ENV NODE_VERSION ${NODE_VERSION:-8.9.0} +ONBUILD ARG INSTALL_NODEGYP +ONBUILD ENV INSTALL_NODEGYP $INSTALL_NODEGYP + ONBUILD ARG NPM_TOKEN ONBUILD ENV NPM_TOKEN $NPM_TOKEN @@ -56,6 +59,7 @@ ONBUILD COPY . $APP_SOURCE_DIR ONBUILD RUN cd $APP_SOURCE_DIR && \ $BUILD_SCRIPTS_DIR/install-deps.sh && \ $BUILD_SCRIPTS_DIR/install-node.sh && \ + $BUILD_SCRIPTS_DIR/install-nodegyp.sh && \ $BUILD_SCRIPTS_DIR/install-phantom.sh && \ $BUILD_SCRIPTS_DIR/install-graphicsmagick.sh && \ $BUILD_SCRIPTS_DIR/install-mongo.sh && \ diff --git a/README.md b/README.md index ff0bb57..9426af2 100644 --- a/README.md +++ b/README.md @@ -23,6 +23,8 @@ There are several parts of a Meteor development environment that you don't need .git .meteor/local node_modules +packages/*/.git +packages/*/.npm ``` ### Run @@ -55,7 +57,7 @@ docker run -d \ ### Build Options -Meteor Launchpad supports setting custom build options in one of two ways. You can either create a launchpad.conf config file in the root of your app or you can use [Docker build args](https://docs.docker.com/engine/reference/builder/#arg). The currently supported options are to install PhantomJS, GraphicsMagick, MongoDB, or any list of `apt-get` dependencies (Meteor Launchpad is built on `debian:jesse`). +Meteor Launchpad supports setting custom build options in one of two ways. You can either create a launchpad.conf config file in the root of your app or you can use [Docker build args](https://docs.docker.com/engine/reference/builder/#arg). The currently supported options are to install PhantomJS, GraphicsMagick, MongoDB, node-gyp, or any list of `apt-get` dependencies (Meteor Launchpad is built on `debian:jesse`). If you choose to install Mongo, you can use it by _not_ supplying a `MONGO_URL` when you run your app container. The startup script will then start Mongo inside the container and tell your app to use it. If you _do_ supply a `MONGO_URL`, Mongo will not be started inside the container and the external database will be used instead. @@ -82,6 +84,7 @@ NODE_VERSION=8.9.0 INSTALL_MONGO=true INSTALL_PHANTOMJS=true INSTALL_GRAPHICSMAGICK=true +INSTALL_NODEGYP=true ``` **Option #2 - Docker Build Args** @@ -104,6 +107,27 @@ You can provide your [NPM auth token](http://blog.npmjs.org/post/118393368555/de docker build --build-arg NPM_TOKEN="" -t myorg/myapp:latest . ``` +## Installing Private Meteor Packages + +You can provide private Meteor packages by copying them to the [`packages/`](https://guide.meteor.com/writing-atmosphere-packages.html#local-packages) folder per the standard Meteor docs. Please note the recommended `.dockerignore` for Meteor Launchpad excludes the `packages//.npm` directory. + +``` +MeteorApp +├──.meteor +├──client +├──server +├──packages +| |--privatePackage1 +| | ├──.npm +| | └─ +| └--privatePackage2 +| ├──.npm +| └─ +├── +├──package.json +└──launchpad.conf +``` + ## Development Builds You can optionally avoid downloading Meteor every time when building regularly in development. Add the following to your Dockerfile instead... diff --git a/dev.dockerfile b/dev.dockerfile index 8911919..ff00435 100644 --- a/dev.dockerfile +++ b/dev.dockerfile @@ -25,9 +25,7 @@ ENV BUILD_SCRIPTS_DIR /opt/build_scripts COPY scripts $BUILD_SCRIPTS_DIR RUN chmod -R 750 $BUILD_SCRIPTS_DIR -# install base dependencies, build app, cleanup -RUN bash $BUILD_SCRIPTS_DIR/install-deps.sh && \ - bash $BUILD_SCRIPTS_DIR/post-install-cleanup.sh +RUN bash $BUILD_SCRIPTS_DIR/install-deps.sh # define all --build-arg options ONBUILD ARG APT_GET_INSTALL @@ -36,6 +34,12 @@ ONBUILD ENV APT_GET_INSTALL $APT_GET_INSTALL ONBUILD ARG NODE_VERSION ONBUILD ENV NODE_VERSION ${NODE_VERSION:-8.9.0} +ONBUILD ARG INSTALL_NODEGYP +ONBUILD ENV INSTALL_NODEGYP $INSTALL_NODEGYP + +ONBUILD ARG NPM_TOKEN +ONBUILD ENV NPM_TOKEN $NPM_TOKEN + ONBUILD ARG INSTALL_MONGO ONBUILD ENV INSTALL_MONGO ${INSTALL_MONGO:-true} @@ -45,21 +49,25 @@ ONBUILD ENV INSTALL_PHANTOMJS ${INSTALL_PHANTOMJS:-true} ONBUILD ARG INSTALL_GRAPHICSMAGICK ONBUILD ENV INSTALL_GRAPHICSMAGICK ${INSTALL_GRAPHICSMAGICK:-true} -# optionally custom apt dependencies at app build time -ONBUILD RUN if [ "$APT_GET_INSTALL" ]; then apt-get update && apt-get install -y $APT_GET_INSTALL; fi - -# optionally install Mongo or Phantom at app build time -ONBUILD RUN bash $BUILD_SCRIPTS_DIR/install-phantom.sh -ONBUILD RUN bash $BUILD_SCRIPTS_DIR/install-mongo.sh -ONBUILD RUN bash $BUILD_SCRIPTS_DIR/install-graphicsmagick.sh - # Node flags for the Meteor build tool ONBUILD ARG TOOL_NODE_FLAGS ONBUILD ENV TOOL_NODE_FLAGS $TOOL_NODE_FLAGS +# optionally custom apt dependencies at app build time +ONBUILD RUN if [ "$APT_GET_INSTALL" ]; then apt-get update && apt-get install -y $APT_GET_INSTALL; fi + +# copy the app to the container +ONBUILD COPY . $APP_SOURCE_DIR +WORKDIR $APP_SOURCE_DIR + +# install base dependencies, build app, cleanup +ONBUILD RUN bash $BUILD_SCRIPTS_DIR/install-deps.sh ONBUILD RUN bash $BUILD_SCRIPTS_DIR/install-node.sh +ONBUILD RUN bash $BUILD_SCRIPTS_DIR/install-nodegyp.sh +ONBUILD RUN bash $BUILD_SCRIPTS_DIR/install-phantom.sh +ONBUILD RUN bash $BUILD_SCRIPTS_DIR/install-graphicsmagick.sh +ONBUILD RUN bash $BUILD_SCRIPTS_DIR/install-mongo.sh ONBUILD RUN bash $BUILD_SCRIPTS_DIR/install-meteor.sh -ONBUILD COPY . $APP_SOURCE_DIR ONBUILD RUN bash $BUILD_SCRIPTS_DIR/build-meteor.sh # Default values for Meteor environment variables diff --git a/scripts/install-nodegyp.sh b/scripts/install-nodegyp.sh new file mode 100644 index 0000000..a8f65e5 --- /dev/null +++ b/scripts/install-nodegyp.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +set -e + +if [ -f $APP_SOURCE_DIR/launchpad.conf ]; then + source <(grep INSTALL_NODEGYP $APP_SOURCE_DIR/launchpad.conf) +fi + +if [ "$INSTALL_NODEGYP" = true ]; then + printf "\n[-] Installing node-gyp ...\n\n" + npm install -g node-gyp --unsafe-perms +fi