Sign inSign up

maudy2u/meteor-launchpad

By maudy2u

•Updated over 5 years ago

A base Docker image for Meteor apps. This is a fork of jshimko/meteor-launchpad: node, arm64, x86_64

Image
0

2.6K

maudy2u/meteor-launchpad repository overview

⁠Meteor Launchpad - Base Docker Image for Meteor Apps

⁠History
  • 1.2.0 added support for arm64, amd64 via buildx --platform
    • added support for arm64, amd64 via buildx --platform. e.g. docker buildx build --platform linux/arm64,linux/amd64 -t yourname/app .
⁠Build

Add the following to a Dockerfile in the root of your app:

FROM maudy2u/meteor-launchpad:latest

Then you can build the image with:

docker build -t yourname/app .

Setting up a .dockerignore file

There are several parts of a Meteor development environment that you don't need to pass into a Docker build because a complete production build happens inside the container. For example, you don't need to pass in your node_modules or the local build files and development database that live in .meteor/local. To avoid copying all of these into the container, here's a recommended starting point for a .dockerignore file to be put into the root of your app. Read more: https://docs.docker.com/engine/reference/builder/#dockerignore-file⁠

.git
.meteor/local
node_modules
⁠Run

Now you can run your container with the following command... (note that the app listens on port 3000 because it is run by a non-root user for security reasons⁠ and non-root users can't run processes on port 80⁠)

docker run -d \
  -e ROOT_URL=http://example.com \
  -e MONGO_URL=mongodb://url \
  -e MONGO_OPLOG_URL=mongodb://oplog_url \
  -e MAIL_URL=smtp://mail_url.com \
  -p 80:3000 \
  yourname/app
⁠Delay startup

You can need to force a delay in the startup of the Node process (for example, to wait for a database to be ready), you can set the STARTUP_DELAY environment variable to any number of seconds. For example, to delay starting the app by 10 seconds, you would do this:

docker run -d \
  -e ROOT_URL=http://example.com \
  -e MONGO_URL=mongodb://url \
  -e STARTUP_DELAY=10 \
  -p 80:3000 \
  yourname/app
⁠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⁠. The currently supported options are to install MongoDB, 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.

The Mongo port and be exposed if needed using the following, where 28017 is your desired port:

-p 28017:27017 \

Note that having Mongo in the same container as your app is just for convenience while testing/developing. In production, you should use a separate Mongo deployment or at least a separate Mongo container.

Here are examples of both methods of setting custom options for your build:

Option #1 - launchpad.conf

To use any of them, create a launchpad.conf in the root of your app and add any of the following values.

# launchpad.conf

# Use apt-get to install any additional dependencies
# that you need before your building/running your app
# (default: undefined)
APT_GET_INSTALL="curl git wget"

# Install a custom Node version (default: latest 8.x)
NODE_VERSION=8.9.0

# Installs the latest version of each (default: all false)
INSTALL_MONGO=true

Option #2 - Docker Build Args

If you prefer not to have a config file in your project, your other option is to use the Docker --build-arg flag. When you build your image, you can set any of the same values above as a build arg.

docker build \
  --build-arg APT_GET_INSTALL="curl git wget" \
  --build-arg INSTALL_MONGO=true \
  --build-arg NODE_VERSION=8.9.0 \
  -t myorg/myapp:latest .

⁠Installing Private NPM Packages

You can provide your NPM auth token⁠ with the NPM_TOKEN build arg.

docker build --build-arg NPM_TOKEN="<your token>" -t myorg/myapp:latest .

⁠Development Builds - in progress..

You can optionally avoid downloading Meteor every time when building regularly in development. Add the following to your Dockerfile instead...

FROM maudy2u/meteor-launchpad:builder

This isn't recommended for your final production build because it creates a much larger image, but it's a bit of a time saver when you're building often in development. This image has keeps the build scripts in /opt/build/scripts and has Meteor already installed. You can attach your source, such as using a volume, and then run update-bundle.sh.

⁠Meteor additions and Multiple platforms - amd64, arm64

The build scripts in /opt/build/scripts allow for different dependencies and versions depending on the platform you are using These can be configured if needed in the launchpad.conf

  • METEOR_ADD - used for generic packages to add to all platforms
  • METEOR_NPM_SAVE_DEV - for specific NPM develop packages
  • METEOR_NPM_SAVE - for specific NPM production packages
  • METEOR_ARM64 - for ARM64 specific packages
  • METEOR_ARM - for ARM64 specific packages
  • METEOR_x86_64 - for ARM64 specific packages

⁠Meteor.settings

If you want to include custom settings (as you would via a settings.json file⁠), you need to set the METEOR_SETTINGS environment variable:

docker run -d \
  -e ROOT_URL=http://example.com \
  -e MONGO_URL=mongodb://url \
  -e MONGO_OPLOG_URL=mongodb://oplog_url \
  -e MAIL_URL=smtp://mail_url.com \
  -e METEOR_SETTINGS="$(cat settings.json)" \
  -p 80:3000 \
  yourname/app

⁠License

MIT License

Copyright (c) 2017 Jeremy Shimko

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Tag summary

Content type

Image

Digest

Size

22.6 MB

Last updated

over 5 years ago

docker pull maudy2u/meteor-launchpad