From 73241f38dff8bc6b1af586f81e4b112e139d7648 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Se=C3=A1n=20C=20McCord?= Date: Fri, 24 Nov 2017 12:30:52 -0500 Subject: [PATCH 1/2] hack two-segment semver to three segments --- entrypoint.sh | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/entrypoint.sh b/entrypoint.sh index e9db328..6980d4f 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -85,6 +85,12 @@ if [ -e "${METEOR_DIR}" ]; then # Check Meteor version echo "Checking Meteor version..." RELEASE=$(cat .meteor/release | cut -f2 -d'@') + + # HACK: if version is x.y, bump it to x.y.0 to work around faulty semver + if [ $(echo $RELEASE | wc -c) -lt 5 ]; then + RELEASE=${RELEASE}.0 + fi + set +e # Allow the next command to fail semver -r '>=1.3.1' $(echo $RELEASE |cut -d'.' -f1-3) if [ $? -ne 0 ]; then From 12d1b6be0fb6e2bcd6057a74b3ad4352dcdfbef0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Se=C3=A1n=20C=20McCord?= Date: Fri, 24 Nov 2017 14:05:11 -0500 Subject: [PATCH 2/2] Clean up meteor version checking - Handle short releases (1.6 vs 1.6.0) - Handle `-` suffixed releases (1.6-pre1, 1.6.1-beta.1, etc) - Consolidate version checks into common function Fixes #56 --- README.md | 4 ++-- entrypoint.sh | 58 ++++++++++++++++++++++++++++----------------------- 2 files changed, 34 insertions(+), 28 deletions(-) diff --git a/README.md b/README.md index cf24aa6..da6c787 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -## Meteor 1.4 +## Meteor 1.4+ The `latest` Docker tag and the `master` git branch are for Meteor 1.4+. For prior versions of Meteor, please use the `legacy` tag and branch. @@ -32,7 +32,7 @@ logins on your site, you must use the `:build` Docker tag (`build` git branch). * References your external MongoDB database * Uses Docker links (i.e. `MONGO_PORT`...) * Explicit Mongo URLs by at `MONGO_URL` - * NOTE: This does NOT set `MONGO_OPLOG_URL`. There were too many potention complications. As a result, unless you explicitly set `MONGO_OPLOG_URL`, Meteor will fall back to a polling-based approach to database synchronization. Note that oplog tailing requires a working replica set on your MongoDB server as well as access to the `local` database. + * NOTE: This does NOT set `MONGO_OPLOG_URL`. There were too many potential complications. As a result, unless you explicitly set `MONGO_OPLOG_URL`, Meteor will fall back to a polling-based approach to database synchronization. Note that oplog tailing requires a working replica set on your MongoDB server as well as access to the `local` database. * Optionally specify the port on which the web server should run (`PORT`); defaults to 80 * Non-root location of Meteor tree; the script will search for the first .meteor directory * _NOTE_: PhantomJS is no longer pre-installed. This package was swelling the size of the image by 50%, and it is not maintainable with the standard Docker Node images. Instead, please use one of the docker-friendly (read port-based) spiderable packages on Meteor, such as [ongoworks:spiderable](https://atmospherejs.com/ongoworks/spiderable); if there is demand, please create an issue on Github, and I'll see about managing a separate branch for it. diff --git a/entrypoint.sh b/entrypoint.sh index 6980d4f..e167a6a 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -19,6 +19,9 @@ set -e export MONGO_URL export PORT +# MIN_METEOR_RELEASE is the minimum Meteor version which can be run with this script +MIN_METEOR_RELEASE=1.4.0 + # If we were given arguments, run them instead if [ $? -gt 0 ]; then exec "$@" @@ -49,6 +52,32 @@ fi mkdir -p $APP_DIR mkdir -p $SRC_DIR +function checkver { + set +e # Allow commands inside this function to fail + + # Strip "-" suffixes + local VER=$(echo $1 | cut -d'-' -f1) + + # Format to x.y.z + if [ $(echo $1 | wc -c) -lt 5 ]; then + # if version is x.y, bump it to x.y.0 + RELEASE_VER=${VER}.0 + else + # If version is x.y.z.A, truncate it to x.y.z + RELEASE_VER=$(echo $VER |cut -d'.' -f1-3) + fi + + semver -r '>='$MIN_METEOR_RELEASE $RELEASE_VER >/dev/null + if [ $? -ne 0 ]; then + echo "Application's Meteor version ($1) is less than ${MIN_METEOR_RELEASE}; please use ulexus/meteor:legacy" + + if [ -z "${IGNORE_METEOR_VERSION}" ]; then + exit 1 + fi + fi + + set -e +} # getrepo pulls the supplied git repository into $SRC_DIR function getrepo { @@ -85,22 +114,7 @@ if [ -e "${METEOR_DIR}" ]; then # Check Meteor version echo "Checking Meteor version..." RELEASE=$(cat .meteor/release | cut -f2 -d'@') - - # HACK: if version is x.y, bump it to x.y.0 to work around faulty semver - if [ $(echo $RELEASE | wc -c) -lt 5 ]; then - RELEASE=${RELEASE}.0 - fi - - set +e # Allow the next command to fail - semver -r '>=1.3.1' $(echo $RELEASE |cut -d'.' -f1-3) - if [ $? -ne 0 ]; then - echo "Application's Meteor version ($RELEASE) is less than 1.3.1; please use ulexus/meteor:legacy" - - if [ -Z "${IGNORE_METEOR_VERSION}" ]; then - exit 1 - fi - fi - set -e + checkver $RELEASE # Download Meteor installer echo "Downloading Meteor install script..." @@ -150,16 +164,8 @@ if [ -e ${BUNDLE_DIR}/programs/server ]; then # Check Meteor version echo "Checking Meteor version..." - set +e # Allow the next command to fail - semver -r '>=1.3.1' $(cat config.json | jq .meteorRelease | tr -d '"' | cut -f2 -d'@' | cut -d'.' -f1-3) - if [ $? -ne 0 ]; then - echo "Application's Meteor version is less than 1.3.1; please use ulexus/meteor:legacy" - - if [ -Z "${IGNORE_METEOR_VERSION}" ]; then - exit 1 - fi - fi - set -e + set +e # Allow the next commands to fail + checkver $(cat config.json | jq -r .meteorRelease | cut -f2 -d'@') echo "Installing NPM prerequisites..." # Install all NPM packages