├── .gitignore ├── .meteor ├── .finished-upgraders ├── .gitignore ├── .id ├── packages ├── platforms ├── release └── versions ├── Makefile ├── README.md ├── client ├── main.css ├── main.html └── main.js ├── coldbrew.conf ├── deploy ├── Dockerfile └── script │ ├── lib │ ├── build_app.sh │ ├── cleanup.sh │ ├── install_base.sh │ ├── install_meteor.sh │ ├── install_node.sh │ └── install_phantomjs.sh │ └── run_app.sh ├── package.json └── server └── main.js /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | -------------------------------------------------------------------------------- /.meteor/.finished-upgraders: -------------------------------------------------------------------------------- 1 | # This file contains information which helps Meteor properly upgrade your 2 | # app when you run 'meteor update'. You should check it into version control 3 | # with your project. 4 | 5 | notices-for-0.9.0 6 | notices-for-0.9.1 7 | 0.9.4-platform-file 8 | notices-for-facebook-graph-api-2 9 | 1.2.0-standard-minifiers-package 10 | 1.2.0-meteor-platform-split 11 | 1.2.0-cordova-changes 12 | 1.2.0-breaking-changes 13 | 1.3.0-split-minifiers-package 14 | 1.4.0-remove-old-dev-bundle-link 15 | 1.4.1-add-shell-server-package 16 | -------------------------------------------------------------------------------- /.meteor/.gitignore: -------------------------------------------------------------------------------- 1 | local 2 | -------------------------------------------------------------------------------- /.meteor/.id: -------------------------------------------------------------------------------- 1 | # This file contains a token that is unique to your project. 2 | # Check it into your repository along with the rest of this directory. 3 | # It can be used for purposes such as: 4 | # - ensuring you don't accidentally deploy one app on top of another 5 | # - providing package authors with aggregated statistics 6 | 7 | 1yt916p1020zel13kncmf 8 | -------------------------------------------------------------------------------- /.meteor/packages: -------------------------------------------------------------------------------- 1 | # Meteor packages used by this project, one per line. 2 | # Check this file (and the other files in this directory) into your repository. 3 | # 4 | # 'meteor add' and 'meteor remove' will edit this file for you, 5 | # but you can also edit it by hand. 6 | 7 | meteor-base@1.0.4 # Packages every Meteor app needs to have 8 | mobile-experience@1.0.4 # Packages for a great mobile UX 9 | mongo@1.1.14 # The database Meteor supports right now 10 | blaze-html-templates@1.0.4 # Compile .html files into Meteor Blaze views 11 | reactive-var@1.0.11 # Reactive variable for tracker 12 | jquery@1.11.10 # Helpful client-side library 13 | tracker@1.1.1 # Meteor's client-side reactive programming library 14 | 15 | standard-minifier-css@1.3.2 # CSS minifier run for production mode 16 | standard-minifier-js@1.2.1 # JS minifier run for production mode 17 | es5-shim@4.6.15 # ECMAScript 5 compatibility for older browsers. 18 | ecmascript@0.5.9 # Enable ECMAScript2015+ syntax in app code 19 | shell-server@0.2.1 # Server-side component of the `meteor shell` command 20 | 21 | autopublish@1.0.7 # Publish all data to the clients (for prototyping) 22 | insecure@1.0.7 # Allow all DB writes from clients (for prototyping) 23 | -------------------------------------------------------------------------------- /.meteor/platforms: -------------------------------------------------------------------------------- 1 | server 2 | browser 3 | -------------------------------------------------------------------------------- /.meteor/release: -------------------------------------------------------------------------------- 1 | METEOR@1.4.2 2 | -------------------------------------------------------------------------------- /.meteor/versions: -------------------------------------------------------------------------------- 1 | allow-deny@1.0.5 2 | autopublish@1.0.7 3 | autoupdate@1.2.11 4 | babel-compiler@6.13.0 5 | babel-runtime@0.1.13 6 | base64@1.0.10 7 | binary-heap@1.0.10 8 | blaze@2.1.9 9 | blaze-html-templates@1.0.5 10 | blaze-tools@1.0.10 11 | boilerplate-generator@1.0.11 12 | caching-compiler@1.1.8 13 | caching-html-compiler@1.0.7 14 | callback-hook@1.0.10 15 | check@1.2.4 16 | ddp@1.2.5 17 | ddp-client@1.2.9 18 | ddp-common@1.2.7 19 | ddp-server@1.2.10 20 | deps@1.0.12 21 | diff-sequence@1.0.7 22 | ecmascript@0.5.9 23 | ecmascript-runtime@0.3.15 24 | ejson@1.0.13 25 | es5-shim@4.6.15 26 | fastclick@1.0.13 27 | geojson-utils@1.0.10 28 | hot-code-push@1.0.4 29 | html-tools@1.0.11 30 | htmljs@1.0.11 31 | http@1.1.8 32 | id-map@1.0.9 33 | insecure@1.0.7 34 | jquery@1.11.10 35 | launch-screen@1.0.12 36 | livedata@1.0.18 37 | logging@1.1.16 38 | meteor@1.6.0 39 | meteor-base@1.0.4 40 | minifier-css@1.2.15 41 | minifier-js@1.2.15 42 | minimongo@1.0.18 43 | mobile-experience@1.0.4 44 | mobile-status-bar@1.0.13 45 | modules@0.7.7 46 | modules-runtime@0.7.7 47 | mongo@1.1.14 48 | mongo-id@1.0.6 49 | npm-mongo@2.2.11_2 50 | observe-sequence@1.0.14 51 | ordered-dict@1.0.9 52 | promise@0.8.8 53 | random@1.0.10 54 | reactive-var@1.0.11 55 | reload@1.1.11 56 | retry@1.0.9 57 | routepolicy@1.0.12 58 | shell-server@0.2.1 59 | spacebars@1.0.13 60 | spacebars-compiler@1.0.13 61 | standard-minifier-css@1.3.2 62 | standard-minifier-js@1.2.1 63 | templating@1.2.15 64 | templating-compiler@1.2.15 65 | templating-runtime@1.2.15 66 | templating-tools@1.0.5 67 | tracker@1.1.1 68 | ui@1.0.12 69 | underscore@1.0.10 70 | url@1.0.11 71 | webapp@1.3.12 72 | webapp-hashing@1.0.9 73 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | BUILD_DIR := /tmp/tutorial-meteor 2 | 3 | bundle: 4 | mkdir -p $(BUILD_DIR) 5 | rm -rf $(BUILD_DIR)/bundle 6 | meteor build --directory $(BUILD_DIR)/ --architecture os.linux.x86_64 --server http://localhost:3000 --server-only 7 | 8 | deploy: bundle 9 | cp -rf deploy/* $(BUILD_DIR)/ 10 | cp -rf coldbrew.conf $(BUILD_DIR)/ 11 | coldbrew deploy --app-dir $(BUILD_DIR) --dockerfile $(BUILD_DIR)/Dockerfile 12 | 13 | .PHONY: deploy bundle 14 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Tutorial: Running a Meteor app on AWS using coldbrew-cli 2 | 3 | This is a sample project to demonstrate how to run a [Meteor](https://www.meteor.com/) application on AWS using [coldbrew-cli](https://github.com/coldbrewcloud/coldbrew-cli). 4 | 5 | ## Getting Started 6 | 7 | ### Install Docker 8 | 9 | [coldbrew-cli](https://github.com/coldbrewcloud/coldbrew-cli) deploys your application in [Docker containers](https://www.docker.com/what-docker). So the first step is to [install Docker](https://docs.docker.com/engine/installation/) in your system if you don't have it yet. 10 | 11 | ### Install coldbrew-cli 12 | 13 | Download the package for your system [here](https://github.com/coldbrewcloud/coldbrew-cli/wiki/Downloads). It makes things easier if you copy the downloaded binary `coldbrew` (or `coldbrew.exe` on Windows) in your `$PATH`, so you can run `coldbrew` from anywhere. _But it's also okay to keep `coldbrew` executable in your application directory if you want._ 14 | 15 | ### AWS Account 16 | 17 | As you will be deploying your application on AWS, you will need an AWS account for sure. [Sign up](https://aws.amazon.com/) if you haven't yet, and get your [AWS access keys](http://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSGettingStartedGuide/AWSCredentials.html). You can pass AWS access keys to **coldbrew-cli** either in [environment variables](https://github.com/coldbrewcloud/coldbrew-cli/wiki/CLI-Environment-Variables) or using [CLI flags](https://github.com/coldbrewcloud/coldbrew-cli/wiki/CLI-Global-Flags), but we will assume that you set the follow environment variables throughout the tutorial: 18 | 19 | - `$AWS_ACCESS_KEY_ID`: AWS Access Key ID 20 | - `$AWS_SECRET_ACCESS_KEY`: AWS Secret Access Key 21 | - `$AWS_REGION`: AWS region name 22 | - `$AWS_VPC`: AWS VPC ID _(this is completely optional. If you don't specify or don't know your VPC ID, **coldbrew-cli** will automatically use the [default VPC](http://docs.aws.amazon.com/AmazonVPC/latest/UserGuide/default-vpc.html) of your AWS account.)_ 23 | 24 | ### Meteor 25 | 26 | Pretty obvious, but, you will need to [install Meteor](https://www.meteor.com/install) to follow this tutorial. 27 | 28 | ### Clone This Repo 29 | 30 | This tutorial project contains the bare minimum _(but fully functional)_ sample resources so you can get started right away. 31 | 32 | - A sample Meteor application: created by running `meteor create tutorial-meteor` 33 | - [deploy](https://github.com/coldbrewcloud/tutorial-meteor/blob/master/deploy) directory: all deploy related resources including deploy configuration, Dockerfile, and bunch of scripts. 34 | - [coldbrew.conf](https://github.com/coldbrewcloud/tutorial-meteor/blob/master/Makefile): deploy configuration file 35 | - [Makefile](https://github.com/coldbrewcloud/tutorial-meteor/blob/master/Makefile): for Meteor app bundling (`make bundle`) and deployment (`make deploy`) 36 | 37 | _Basically, everything should be the regular Meteor app directory structure except for the `deploy` directory, `coldbrew.conf`, and, `Makefile`._ 38 | 39 | Clone this repo: 40 | 41 | ```bash 42 | git clone https://github.com/coldbrewcloud/tutorial-meteor.git 43 | cd tutorial-meteor 44 | ``` 45 | 46 | ## Creating Your First Cluster 47 | 48 | **coldbrew-cli** has _very_ simple [concepts](https://github.com/coldbrewcloud/coldbrew-cli/wiki/Concepts): clusters and applications (apps). An app is the minimum deployment unit and _typically_ corresponds to a project (like this tutorial project). And a cluster is simply a collection of apps who will share some AWS resources. _Most importantly they share the Docker hosts (which is ECS Container Instances in the AWS context)._ 49 | 50 | Let's create your first cluster `tutorial` using [cluster-create](https://github.com/coldbrewcloud/coldbrew-cli/wiki/CLI-Command:-cluster-create) command: 51 | 52 | ```bash 53 | coldbrew cluster-create tutorial --disable-keypair 54 | ``` 55 | 56 | 57 | 58 | _*In this tutorial, we used `--disable-keypair` flag to skip assigning EC2 key pairs to the container instances. If you will need direct access to the instances (e.g. via SSH), you can use the `--key` flag to specify your key pair name._ 59 | 60 | If you want to check the current running status of your first cluster, you can use [cluster-status](https://github.com/coldbrewcloud/coldbrew-cli/wiki/CLI-Command:-cluster-status) command: 61 | 62 | ```bash 63 | coldbrew cluster-status tutorial 64 | ``` 65 | 66 | It can take several minutes until the initial ECS Container Instances (EC2 Instances) become fully available, but, you can continue on to start deploying your application. 67 | 68 | 69 | 70 | ## Deploying Your Application 71 | 72 | Now it's time to deploy your app for the first time. All you need is an application [configuration file](https://github.com/coldbrewcloud/coldbrew-cli/wiki/Configuration-File) to define your app's deployment settings. You can easily create it on your own, or you can use [init](https://github.com/coldbrewcloud/coldbrew-cli/wiki/CLI-Command:-init) command to generate a proper default configuration for your app. In this tutorial, we provide a sample [coldbrew.conf](https://github.com/coldbrewcloud/tutorial-meteor/blob/master/coldbrew.conf) file so we can start quickly. 73 | 74 | In this tutorial, we will use `make deploy` command to script the typical Meteor app deployment process: 75 | 76 | - Create a temporary build directory (`/tmp/tutorial-meteor`) 77 | - Run `meteor build` to compile, build, and, bundle everything in the temporary build directory (`/tmp/tutorial-meteor/bundle`) 78 | - Copy deployment files to the temporary build directory 79 | - Run `coldbrew deploy` to initiate the deployment process 80 | 81 | See [Makefile](https://github.com/coldbrewcloud/tutorial-meteor/blob/master/Makefile) if you want more details, and feel free to customize the scripts if you want. 82 | 83 | Now let's run it: 84 | 85 | ```bash 86 | make deploy 87 | ``` 88 | 89 | 90 | 91 | If you're curious, this is what happens when **coldbrew-cli** initiates the deployment process: 92 | 93 | - **coldbrew-cli** builds local Docker image using [Dockerfile](https://github.com/coldbrewcloud/tutorial-meteor/blob/master/deploy/Dockerfile). _(You can skip this if you provide the local image name using `--docker-image` flag directly.)_ 94 | - It pushes the Docker image to the ECR Repository that's created for your application. 95 | - It creates, updates, or configures ECS Task Definition and ECS Service to apply your configurations. 96 | - It also creates or configures an ELB Application Load Balanacer if your application needs a load balancer. _(This tutorial enables the load balancer.)_ 97 | 98 | Now let's check the application status using [status](https://github.com/coldbrewcloud/coldbrew-cli/wiki/CLI-Command:-status) command: 99 | 100 | ```bash 101 | coldbrew status 102 | ``` 103 | 104 | 105 | 106 | It gives you much more details about your application and its related AWS resources. 107 | 108 | _*Again, it will take several minutes until all AWS resources get fully provisioned and become active (especially if you enabled load balancer). But, the next deploys will be much faster, typically within a minute._ 109 | 110 | #### Deploying Again 111 | 112 | After the first deploy, whenever you have changes in your code or configurations, you can re-deploy them again using the same [deploy](https://github.com/coldbrewcloud/coldbrew-cli/wiki/CLI-Command:-deploy) command. In this example, I made a simple change in `.units` attributes in the configuration file: from `1` tom `2`. 113 | 114 | ```bash 115 | make deploy 116 | ``` 117 | 118 | 119 | 120 | This time, you will notice that **coldbrew-cli** did not create a new AWS resources this time because they were already created during the first deploy run. **coldbrew-cli** always tries to minimize the actual AWS changes by analyzing and comparing the current status and the desired status. 121 | 122 | _*Note that not all configuration changes will be applied immediately. See [this](https://github.com/coldbrewcloud/coldbrew-cli/wiki/Configuration-Changes-and-Their-Effects) for more details._ 123 | 124 | Let's run [status](https://github.com/coldbrewcloud/coldbrew-cli/wiki/CLI-Command:-status) command again: 125 | 126 | ```bash 127 | coldbrew status 128 | ``` 129 | 130 | 131 | 132 | ## Testing the Application 133 | 134 | To know if your application is up and running, check [status](https://github.com/coldbrewcloud/coldbrew-cli/wiki/CLI-Command:-status) command output: 135 | - Make sure ELB Load Balancer's Status becomes `active`. 136 | - Make sure you have more than 1 ECS Task has running status (`RUNNING/RUNNING`). 137 | 138 | Assuming it's all good, let's test if your Meteor application really works. Again check [status](https://github.com/coldbrewcloud/coldbrew-cli/wiki/CLI-Command:-status) command output to find the Load Balancer endpoint _(`http://tutorial-meteor-elb-352619032.us-west-2.elb.amazonaws.com:80` in my example run)_. You should be able to test your app by opening the load balancer endpoint URL in your web browser. 139 | 140 | ## Cleaning Up 141 | 142 | When you no longer need to run your application in AWS, you can use the [delete](https://github.com/coldbrewcloud/coldbrew-cli/wiki/CLI-Command:-delete) command to clean up all AWS resources that were used to run your application. 143 | 144 | ```bash 145 | coldbrew delete 146 | ``` 147 | 148 | 149 | 150 | _*Note that cleanining up can take several minutes to finish to make sure all AWS resources are properly deleted or updated._ 151 | 152 | And, if you need to delete the cluster too, you can [cluster-delete](https://github.com/coldbrewcloud/coldbrew-cli/wiki/CLI-Command:-cluster-delete) command. 153 | 154 | ```bash 155 | coldbrew cluster-delete tutorial 156 | ``` 157 | 158 | 159 | 160 | _*For the same reason, cluster delete can take long to finish._ 161 | 162 | ## Notes 163 | 164 | - In this tutorial, we didn't use `$MONGO_URL`, but, in production you should set up your own MongoDB cluster (one easy way to do is to use [compose.io](https://compose.io)) and specify its connection URI in `$MONGO_URL`. You can use `env` attribute in the configuration file. 165 | 166 | --- 167 | 168 | That's it for the tutorial. Now you know how to run your Meteor applications on AWS using [coldbrew-cli](https://github.com/coldbrewcloud/coldbrew-cli). Although this tutorial used a sample Meteor application, the deployment workflow of **coldbrew-cli** for other tech stacks is almost the same, as long as you have your Dockerfile in place. 169 | 170 | See [Documentations](https://github.com/coldbrewcloud/coldbrew-cli/wiki) for more details. 171 | -------------------------------------------------------------------------------- /client/main.css: -------------------------------------------------------------------------------- 1 | /* CSS declarations go here */ 2 | -------------------------------------------------------------------------------- /client/main.html: -------------------------------------------------------------------------------- 1 | 2 | tutorial-meteor 3 | 4 | 5 | 6 |

Welcome to Meteor!

7 | 8 | {{> hello}} 9 | {{> info}} 10 | 11 | 12 | 16 | 17 | 26 | -------------------------------------------------------------------------------- /client/main.js: -------------------------------------------------------------------------------- 1 | import { Template } from 'meteor/templating'; 2 | import { ReactiveVar } from 'meteor/reactive-var'; 3 | 4 | import './main.html'; 5 | 6 | Template.hello.onCreated(function helloOnCreated() { 7 | // counter starts at 0 8 | this.counter = new ReactiveVar(0); 9 | }); 10 | 11 | Template.hello.helpers({ 12 | counter() { 13 | return Template.instance().counter.get(); 14 | }, 15 | }); 16 | 17 | Template.hello.events({ 18 | 'click button'(event, instance) { 19 | // increment the counter when button is clicked 20 | instance.counter.set(instance.counter.get() + 1); 21 | }, 22 | }); 23 | -------------------------------------------------------------------------------- /coldbrew.conf: -------------------------------------------------------------------------------- 1 | name: tutorial-meteor 2 | cluster: tutorial 3 | port: 80 4 | cpu: 0.3 5 | memory: 300m 6 | units: 2 7 | 8 | env: 9 | ROOT_URL: "http://www.example.com" 10 | 11 | load_balancer: 12 | enabled: true 13 | -------------------------------------------------------------------------------- /deploy/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM debian:jessie 2 | 3 | ENV METEORD_DIR /opt/meteord 4 | COPY script $METEORD_DIR 5 | 6 | ARG NODE_VERSION 7 | ENV NODE_VERSION ${NODE_VERSION:-4.6.1} 8 | ONBUILD ENV NODE_VERSION ${NODE_VERSION:-4.6.1} 9 | 10 | RUN bash $METEORD_DIR/lib/install_base.sh 11 | RUN bash $METEORD_DIR/lib/install_node.sh 12 | RUN bash $METEORD_DIR/lib/install_phantomjs.sh 13 | RUN bash $METEORD_DIR/lib/cleanup.sh 14 | 15 | COPY bundle /bundle 16 | 17 | EXPOSE 80 18 | ENTRYPOINT bash $METEORD_DIR/run_app.sh 19 | -------------------------------------------------------------------------------- /deploy/script/lib/build_app.sh: -------------------------------------------------------------------------------- 1 | set -e 2 | 3 | COPIED_APP_PATH=/copied-app 4 | BUNDLE_DIR=/tmp/bundle-dir 5 | 6 | # sometimes, directly copied folder cause some wierd issues 7 | # this fixes that 8 | echo "=> Copying the app" 9 | cp -R /app $COPIED_APP_PATH 10 | cd $COPIED_APP_PATH 11 | 12 | echo "=> Executing NPM install --production" 13 | meteor npm install --production 14 | 15 | echo "=> Executing Meteor Build..." 16 | export 17 | METEOR_WAREHOUSE_URLBASE=https://d3fm2vapipm3k9.cloudfront.net \ 18 | METEOR_LOG=debug \ 19 | meteor build \ 20 | --unsafe-perm \ 21 | --directory $BUNDLE_DIR \ 22 | --server=http://localhost:3000 23 | 24 | echo "=> Printing Meteor Node information..." 25 | echo " => platform" 26 | meteor node -p process.platform 27 | echo " => arch" 28 | meteor node -p process.arch 29 | echo " => versions" 30 | meteor node -p process.versions 31 | 32 | echo "=> Printing System Node information..." 33 | echo " => platform" 34 | node -p process.platform 35 | echo " => arch" 36 | node -p process.arch 37 | echo " => versions" 38 | node -p process.versions 39 | 40 | echo "=> Executing NPM install within Bundle" 41 | cd $BUNDLE_DIR/bundle/programs/server/ 42 | npm i 43 | 44 | echo "=> Moving bundle" 45 | mv $BUNDLE_DIR/bundle /built_app 46 | 47 | echo "=> Cleaning up" 48 | # cleanup 49 | echo " => COPIED_APP_PATH" 50 | rm -rf $COPIED_APP_PATH 51 | echo " => BUNDLE_DIR" 52 | rm -rf $BUNDLE_DIR 53 | echo " => .meteor" 54 | rm -rf ~/.meteor 55 | rm /usr/local/bin/meteor -------------------------------------------------------------------------------- /deploy/script/lib/cleanup.sh: -------------------------------------------------------------------------------- 1 | ## Borrowed from: https://github.com/chriswessels/meteor-tupperware 2 | 3 | set -e 4 | # Autoremove any junk 5 | apt-get autoremove -y 6 | 7 | # Clean out docs 8 | rm -rf /usr/share/doc /usr/share/doc-base /usr/share/man /usr/share/locale /usr/share/zoneinfo 9 | 10 | # Clean out package management dirs 11 | rm -rf /var/lib/cache /var/lib/log 12 | 13 | # Clean out /tmp 14 | rm -rf /tmp/* 15 | 16 | # Clear npm cache 17 | npm cache clear -------------------------------------------------------------------------------- /deploy/script/lib/install_base.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | apt-get update -y 4 | apt-get install -y curl bzip2 build-essential g++ python git -------------------------------------------------------------------------------- /deploy/script/lib/install_meteor.sh: -------------------------------------------------------------------------------- 1 | set -e 2 | 3 | curl -sL https://install.meteor.com | sed s/--progress-bar/-sL/g | /bin/sh 4 | -------------------------------------------------------------------------------- /deploy/script/lib/install_node.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | if [ -z "$NODE_VERSION" ]; then 4 | echo "Must set NODE_VERSION with --build-arg NODE_VERSION=x.y.z when building docker image" 5 | exit 1 6 | fi 7 | echo "Installing Node v${NODE_VERSION}" 8 | NODE_ARCH=x64 9 | 10 | # check we need to do this or not 11 | 12 | NODE_DIST=node-v${NODE_VERSION}-linux-${NODE_ARCH} 13 | 14 | cd /tmp 15 | curl -O -L http://nodejs.org/dist/v${NODE_VERSION}/${NODE_DIST}.tar.gz 16 | tar xvzf ${NODE_DIST}.tar.gz 17 | rm -rf /opt/nodejs 18 | mv ${NODE_DIST} /opt/nodejs 19 | 20 | ln -sf /opt/nodejs/bin/node /usr/bin/node 21 | ln -sf /opt/nodejs/bin/npm /usr/bin/npm 22 | 23 | npm install --global npm@3 24 | -------------------------------------------------------------------------------- /deploy/script/lib/install_phantomjs.sh: -------------------------------------------------------------------------------- 1 | # Install PhantomJS 2 | set -e 3 | apt-get -y install libfreetype6 libfreetype6-dev fontconfig 4 | ARCH=`uname -m` 5 | PHANTOMJS_VERSION=2.1.1 6 | PHANTOMJS_TAR_FILE=phantomjs-${PHANTOMJS_VERSION}-linux-${ARCH}.tar.bz2 7 | 8 | cd /usr/local/share/ 9 | curl -L -O https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-${PHANTOMJS_VERSION}-linux-${ARCH}.tar.bz2 10 | tar xjf $PHANTOMJS_TAR_FILE 11 | ln -s -f /usr/local/share/phantomjs-${PHANTOMJS_VERSION}-linux-${ARCH}/bin/phantomjs /usr/local/share/phantomjs 12 | ln -s -f /usr/local/share/phantomjs-${PHANTOMJS_VERSION}-linux-${ARCH}/bin/phantomjs /usr/local/bin/phantomjs 13 | ln -s -f /usr/local/share/phantomjs-${PHANTOMJS_VERSION}-linux-${ARCH}/bin/phantomjs /usr/bin/phantomjs 14 | 15 | rm $PHANTOMJS_TAR_FILE 16 | -------------------------------------------------------------------------------- /deploy/script/run_app.sh: -------------------------------------------------------------------------------- 1 | set -e 2 | 3 | if [ -d /bundle ]; then 4 | cd /bundle/programs/server/ 5 | npm install --unsafe-perm 6 | cd /bundle 7 | elif [[ $BUNDLE_URL ]]; then 8 | cd /tmp 9 | curl -L -o bundle.tar.gz $BUNDLE_URL 10 | tar xzf bundle.tar.gz 11 | cd /tmp/bundle/programs/server/ 12 | npm install --unsafe-perm 13 | cd /tmp/bundle/ 14 | elif [ -d /built_app ]; then 15 | cd /built_app 16 | else 17 | echo "=> You don't have an meteor app to run in this image." 18 | exit 1 19 | fi 20 | 21 | if [[ $REBUILD_NPM_MODULES ]]; then 22 | echo "=> abernix/meteord:bin-build is NOT TESTED AT ALL (and maybe not necessary???)" 23 | echo " Since Meteor handles rebuilding binary dependencies itself now, it's not entirely" 24 | echo " clear to me if this particular image is still necessary. If you are receiving" 25 | echo " this message, I highly recommend trying the :base image without the REBUILD_NPM_MODULES" 26 | echo " environment variable and see if it works for you. Please report back as I'd like to" 27 | echo " discourage use of the :bin-build image if possible! Thanks! -abernix" 28 | if [ -f /opt/meteord/rebuild_npm_modules.sh ]; then 29 | cd programs/server 30 | bash /opt/meteord/rebuild_npm_modules.sh 31 | cd ../../ 32 | else 33 | echo "=> Use abernix/meteord:bin-build for binary bulding." 34 | exit 1 35 | fi 36 | fi 37 | 38 | # Set a delay to wait to start meteor container 39 | if [[ $DELAY ]]; then 40 | echo "Delaying startup for $DELAY seconds" 41 | sleep $DELAY 42 | fi 43 | 44 | # Honour already existing PORT setup 45 | export PORT=${PORT:-80} 46 | 47 | echo "=> Starting meteor app on port:$PORT" 48 | node main.js 49 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "tutorial-meteor", 3 | "private": true, 4 | "scripts": { 5 | "start": "meteor run" 6 | }, 7 | "dependencies": { 8 | "meteor-node-stubs": "~0.2.0" 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /server/main.js: -------------------------------------------------------------------------------- 1 | import { Meteor } from 'meteor/meteor'; 2 | 3 | Meteor.startup(() => { 4 | // code to run on server at startup 5 | }); 6 | --------------------------------------------------------------------------------