Skip to content

Instantly share code, notes, and snippets.

@sidkdbl07
Last active July 17, 2018 00:59
Show Gist options
  • Save sidkdbl07/245fe0aa7622b93dbd10474cdfcf9178 to your computer and use it in GitHub Desktop.
Save sidkdbl07/245fe0aa7622b93dbd10474cdfcf9178 to your computer and use it in GitHub Desktop.
Steps for deploying Meteor projects to Google App Engine (GAE)

Assumptions

  1. You have a GAE project setup
  2. You have a mongoDB setup at mLab (or equiv.)

Setup a Meteor Project

Create a project

meteor create [YOUR_APP_NAME]
cd [YOUR_APP_NAME]

Test Your Meteor Project

Run the project

meteor run

If you can see something at http://localhost:3000, it works! Proceed.

Setup package.json

Add the following to the file (don't delete what is there alreday)

"scripts": {
  "cleanup": "rm -rf ../bundle/",
  "dist": "npm run cleanup && meteor build ../ --directory --architecture os.linux.x86_64 --server-only",
  "predeploy": "npm run dist && cp app.yaml ../bundle/ && cp Dockerfile ../bundle/",
  "deploy": "npm run predeploy && (cd ../bundle && gcloud app deploy -q)"
},

Create a Custom Runtime

gcloud beta app gen-config --custom

This wil create Dockerfile and app.yaml in your project directory

Replace Dockerfile

FROM launcher.gcr.io/google/nodejs
RUN install_node v5.6.0
COPY . /app/
RUN (cd programs/server && npm install --unsafe-perm)
CMD node main.js

Replace app.yaml

env: flex
runtime: custom
threadsafe: true
automatic_scaling:
  max_num_instances: 1
env_variables:
  ROOT_URL: https://<gae-app-name>.appspot.com
  MONGO_URL: mongodb://<mongodb-username>:<mongodb-password>@<gce-ip>:27017/<mongodb-name>
  DISABLE_WEBSOCKETS: "1"
skip_files:
- ^(.*/)?\.dockerignore$
- ^(.*/)?\npm-debug.log$
- ^(.*/)?\yarn-error.log$
- ^(.*/)?\.git$
- ^(.*/)?\.hg$
- ^(.*/)?\.svn$

Steps to Deploy

$> meteor build ../ --directory --architecture os.linux.x86_64 --server-only
$> cp app.yaml ../bundle/ && cp Dockerfile ../bundle/
$> cd ../bundle && gcloud app deploy --verbosity=info -q
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment