Created
July 29, 2016 17:01
-
-
Save zeroasterisk/cc8b3f3e7a2e5145f666722575e98391 to your computer and use it in GitHub Desktop.
Meteor build -> Docker (custom image, from bundle)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
VERSION=$1 | |
ORG=myorg | |
APP=myapp | |
TAG=dev | |
CURRENT_DIR=`basename $PWD` | |
BUILD_DIR=../$CURRENT_DIR-build | |
DOCKER_TAG="${ORG}/${APP}/${TAG}" | |
SERVER="http://${APP}.${ORG}.com" | |
# ----- about ------ | |
# builds the meteor app to a bundle dir | |
# copies DockerfileForBuilt -> bundle dir Dockerfile | |
# builds the docker image from the bundle | |
# the image should "just work" after that | |
# ----- usage ------ | |
# cd <meteor-app-root> | |
# bash ./build2docker.sh | |
# ----- source ----- | |
# https://markshust.com/2016/02/01/creating-custom-production-docker-image-meteor-13 | |
set -e | |
rm -rf $BUILD_DIR | |
echo "Building to $BUILD_DIR" | |
meteor build --architecture=os.linux.x86_64 --server=$SERVER --directory $BUILD_DIR | |
cp DockerfileForBundle $BUILD_DIR/bundle/Dockerfile | |
touch .dockerignore package.json | |
cp package.json $BUILD_DIR/bundle/ | |
cp .dockerignore $BUILD_DIR/bundle/ | |
cd $BUILD_DIR/bundle/ | |
echo "Building Dockerfile..." | |
docker build -t ${DOCKER_TAG}:${VERSION} . | |
# gcloud docker push ${DOCKER_TAG}:${VERSION} | |
# kubectl rolling-update ${CURRENT_DIR} --update-period=15s --image=${DOCKER_TAG}:${VERSION} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM node:4.4.7-slim | |
MAINTAINER Alan Blount <alan@zeroasterisk.com> | |
RUN npm install -g npm@3 pm2 \ | |
&& npm cache clear | |
# TODO: remove when https://github.com/npm/npm/issues/9863 is fixed | |
RUN cd $(npm root -g)/npm \ | |
&& npm install fs-extra \ | |
&& sed -i -e s/graceful-fs/fs-extra/ -e s/fs\.rename/fs.move/ ./lib/utils/rename.js | |
# --------- | |
# -- APP -- | |
# --------- | |
ADD . /opt/app | |
WORKDIR /opt/app/programs/server | |
RUN npm install \ | |
&& npm cache clear \ | |
&& mv /opt/app/programs/server/node_modules /opt/ | |
RUN mv /opt/app/package.json /opt | |
WORKDIR /opt | |
RUN npm install --production --unsafe-perm \ | |
&& npm cache clear | |
RUN ln -s node_modules app/programs/server/node_modules | |
RUN ln -s node_modules app/programs/web.browser/node_modules | |
# RUN ln -s node_modules app/programs/web.cordova/node_modules | |
WORKDIR /opt/app | |
ENV PORT 80 | |
EXPOSE 80 | |
CMD ["node", "main.js"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
nice script, thanks a lot