appinio-appi
framework
Last updated 2 years ago by appinio .
ISC · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install appinio-appi 
SYNC missed versions from official npm registry.

Appinio Node Backend (NodeJS + Express)

The Appinio Node Backend provides access to the MongoDB via Restful JSON for the interfaces for the mobile application and the business & admin interfaces.

Dependency Management via NPM

  • Initial setup: npm install
  • Check for new versions: npm outdated
  • Update to wanted versions: npm update
  • Fix locally used versions before committing: npm shrinkwrap
  • this is very important!
  • otherwise newer dependencies could be used during deployment
  • Docs: https://docs.npmjs.com/cli/

Docker

The docker container we are using is based in the Node container you can find here.

Setup

  • install docker and aws cli
  • you need an IAM user from aws with role to access docker registry (ecs registry)
  • run aws configure to setup credentials on your computer, name profile apn

Get versions for apt-get installed packages

  • build container without versions for apt-get packages
  • run apt-cache policy <package> inside
  • set packages in Dockerfile apt-get install <package>=<version>

Build docker image

  • temp. login to our aws docker registry: aws ecr get-login --profile apn | bash /dev/stdin
  • build image: docker build -t appinio/backend . (automatically tagged as appinio/backend:latest)

Push / Pull docker image

  • tag image (before pushing it): docker tag appinio/backend:latest 374852508736.dkr.ecr.eu-central-1.amazonaws.com/backend:latest
  • push image to aws registry: docker push 374852508736.dkr.ecr.eu-central-1.amazonaws.com/backend:latest
  • pull image from aws registry: docker pull 374852508736.dkr.ecr.eu-central-1.amazonaws.com/backend:latest

Running a container

Required environment parameters

  • INSTANCE_COUNT - Defines how many instances should pm2 start (0 = as many as cores)
  • NAME - Name of the application for pm2 and key metrics.

Optional environment parameters

  • PM2_SECRET_KEY and PM2_PUBLIC_KEY - For key metrics monitoring. (only in prod or staging)

Required volumes

  • .private This folder contains the environment specific config.js to connect to the database.
  • push This folder contains the environment specific certificates for push notifications.

Example Kai

docker run -p 8080:80 -e 'INSTANCE_COUNT=2' -e 'NAME=backend-staging' \
-v /Users/Kai/dev/server/.private:/app/.private \
-v /Users/Kai/dev/server/push:/app/push \
--name apn.backend -d \
appinio/backend

Example

docker run -p 8080:80 -e 'INSTANCE_COUNT=2' -e 'NAME=backend-staging' \
-v /my/workspace/appinio/default/.private:/app/.private \
-v /my/workspace/appinio/default/push:/app/push \
--name apn.backend -d \
appinio/backend

Shell access into docker container

docker exec -it apn.backend /bin/bash

Remove docker container

docker rm -f apn.backend

Current Tags

  • 1.0.0                                ...           latest (2 years ago)

1 Versions

  • 1.0.0                                ...           2 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 1
Dependencies (18)
Dev Dependencies (9)
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |