diff --git a/Dockerfile b/Dockerfile index 4c2fee7..08a88bd 100755 --- a/Dockerfile +++ b/Dockerfile @@ -54,14 +54,14 @@ ONBUILD COPY . $APP_SOURCE_DIR # install all dependencies, build app, clean up ONBUILD RUN cd $APP_SOURCE_DIR && \ - $BUILD_SCRIPTS_DIR/install-deps.sh && \ - $BUILD_SCRIPTS_DIR/install-node.sh && \ - $BUILD_SCRIPTS_DIR/install-phantom.sh && \ - $BUILD_SCRIPTS_DIR/install-graphicsmagick.sh && \ - $BUILD_SCRIPTS_DIR/install-mongo.sh && \ - $BUILD_SCRIPTS_DIR/install-meteor.sh && \ - $BUILD_SCRIPTS_DIR/build-meteor.sh && \ - $BUILD_SCRIPTS_DIR/post-build-cleanup.sh + bash -l $BUILD_SCRIPTS_DIR/install-deps.sh && \ + bash -l $BUILD_SCRIPTS_DIR/install-node.sh && \ + bash -l $BUILD_SCRIPTS_DIR/install-phantom.sh && \ + bash -l $BUILD_SCRIPTS_DIR/install-graphicsmagick.sh && \ + bash -l $BUILD_SCRIPTS_DIR/install-mongo.sh && \ + bash -l $BUILD_SCRIPTS_DIR/install-meteor.sh && \ + bash -l $BUILD_SCRIPTS_DIR/build-meteor.sh && \ + bash -l $BUILD_SCRIPTS_DIR/post-build-cleanup.sh # Default values for Meteor environment variables ENV ROOT_URL http://localhost @@ -74,4 +74,4 @@ WORKDIR $APP_BUNDLE_DIR/bundle # start the app ENTRYPOINT ["./entrypoint.sh"] -CMD ["node", "main.js"] \ No newline at end of file +CMD ["node", "main.js"] diff --git a/README.md b/README.md index 7f9eb45..d237f88 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,8 @@ [![Circle CI](https://circleci.com/gh/jshimko/meteor-launchpad/tree/master.svg?style=svg)](https://circleci.com/gh/jshimko/meteor-launchpad/tree/master) # Meteor Launchpad - Base Docker Image for Meteor Apps +Works for Meteor 2 and 3. + ### Build Add the following to a `Dockerfile` in the root of your app: @@ -67,7 +69,7 @@ Here are examples of both methods of setting custom options for your build: To use any of them, create a `launchpad.conf` in the root of your app and add any of the following values. -```sh +```dotenv # launchpad.conf # Use apt-get to install any additional dependencies @@ -75,8 +77,8 @@ To use any of them, create a `launchpad.conf` in the root of your app and add an # (default: undefined) APT_GET_INSTALL="curl git wget" -# Install a custom Node version (default: latest 8.x) -NODE_VERSION=8.9.0 +# Install a custom Node version (default: latest 20.x) +NODE_VERSION=20.10.0 # Installs the latest version of each (default: all false) INSTALL_MONGO=true @@ -84,6 +86,7 @@ INSTALL_PHANTOMJS=true INSTALL_GRAPHICSMAGICK=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. @@ -159,7 +162,7 @@ docker-compose up -d ## Custom Builds of Meteor Launchpad -If you'd like to create a custom build for some reason, you can use the `build.sh` script in the root of the project to run all of the necessary commands. +If you'd like to create a custom build for some reason, you can use the `build.sh` script in the root of the project to run all the necessary commands. First, make any changes you want, then to create your custom build: diff --git a/build.sh b/build.sh index 52b66b0..ede26e4 100755 --- a/build.sh +++ b/build.sh @@ -6,5 +6,5 @@ IMAGE_NAME=${1:-"jshimko/meteor-launchpad"} printf "\n[-] Building $IMAGE_NAME...\n\n" -docker build -f dev.dockerfile -t $IMAGE_NAME:devbuild . -docker build -t $IMAGE_NAME:latest . +docker build --no-cache -f dev.dockerfile -t $IMAGE_NAME:devbuild . +docker build --no-cache -t $IMAGE_NAME:latest . diff --git a/dev.dockerfile b/dev.dockerfile index a694b50..eeef385 100644 --- a/dev.dockerfile +++ b/dev.dockerfile @@ -37,6 +37,7 @@ ONBUILD ENV APT_GET_INSTALL $APT_GET_INSTALL ONBUILD ARG NODE_VERSION ONBUILD ENV NODE_VERSION ${NODE_VERSION:-14.17.4} + ONBUILD ARG INSTALL_MONGO ONBUILD ENV INSTALL_MONGO ${INSTALL_MONGO:-true} diff --git a/scripts/build-meteor.sh b/scripts/build-meteor.sh index 79a0f30..060c86e 100755 --- a/scripts/build-meteor.sh +++ b/scripts/build-meteor.sh @@ -21,9 +21,31 @@ export METEOR_ALLOW_SUPERUSER=true cd $APP_SOURCE_DIR +printf "\n[-] Activate conda in app directory...\n\n" + +source /opt/conda/etc/profile.d/conda.sh + +NODE_VERSION=$(node -v | cut -c2-) + +echo "\nNODE_VERSION: ${NODE_VERSION}\n\n" + +if [[ "$(echo "$NODE_VERSION" | cut -d'.' -f1)" -gt 14 ]]; then + PYTHON_VERSION=3.12.2 +else + PYTHON_VERSION=2.7.18 +fi + +echo "\PYTHON_VERSION: ${PYTHON_VERSION}\n\n" + +conda create --name py python=${PYTHON_VERSION} -y +conda activate py + +echo "\n[-] Check python version on build...\n\n" +echo `python --version` + # Install app deps printf "\n[-] Running npm install in app directory...\n\n" -meteor npm install +meteor npm ci # build the bundle printf "\n[-] Building Meteor application...\n\n" diff --git a/scripts/install-deps.sh b/scripts/install-deps.sh index be0abb1..36555a4 100755 --- a/scripts/install-deps.sh +++ b/scripts/install-deps.sh @@ -20,10 +20,22 @@ if [ -f $APP_SOURCE_DIR/launchpad.conf ]; then fi fi -apt-get install -y --no-install-recommends curl bzip2 libarchive-tools build-essential python git wget gnupg2 dirmngr +apt-get install -y --no-install-recommends curl bzip2 libarchive-tools build-essential git wget gpg gnupg2 dirmngr +### Conda -# install gosu +# Install our public GPG key to trusted store +curl https://repo.anaconda.com/pkgs/misc/gpgkeys/anaconda.asc | gpg --dearmor > conda.gpg +install -o root -g root -m 644 conda.gpg /usr/share/keyrings/conda-archive-keyring.gpg + +# Check whether fingerprint is correct (will output an error message otherwise) +gpg --keyring /usr/share/keyrings/conda-archive-keyring.gpg --no-default-keyring --fingerprint 34161F5BF5EB1D4BFBBB8F0A8AEB4F8B29D82806 + +# Add our Debian repo +echo "deb [arch=amd64 signed-by=/usr/share/keyrings/conda-archive-keyring.gpg] https://repo.anaconda.com/pkgs/misc/debrepo/conda stable main" > /etc/apt/sources.list.d/conda.list + +apt-get update +apt-get install -y conda dpkgArch="$(dpkg --print-architecture | awk -F- '{ print $NF }')" diff --git a/scripts/post-build-cleanup.sh b/scripts/post-build-cleanup.sh index 77bcb8a..3bc2c51 100755 --- a/scripts/post-build-cleanup.sh +++ b/scripts/post-build-cleanup.sh @@ -28,7 +28,7 @@ rm -rf /opt/nodejs/bin/npm rm -rf /opt/nodejs/lib/node_modules/npm/ # remove os dependencies -apt-get purge -y --auto-remove apt-transport-https build-essential libarchive-tools bzip2 ca-certificates curl git python +apt-get purge -y --auto-remove apt-transport-https build-essential libarchive-tools bzip2 ca-certificates curl git wget gpg gnupg2 dirmngr conda apt-get -y autoremove apt-get -y clean apt-get -y autoclean