#
# Easiest way to work with this file, from an updated Ubuntu 16.04 LTS image
# 1.   create a non-root user with sudo priv and perform following steps as non-root
# 2.  `sudo apt-get update`
# 3.  `sudo apt-get install snapcraft python build-essential`
# 4.  `snapcraft stage`
# 5.  `snapcraft snap`

name: rocketchat-server
version: 0.49.0-develop
summary: Rocket.Chat server
description: Have your own Slack like online chat, built with Meteor. https://rocket.chat/
confinement: strict
apps:
    rocketchat-server:
        command: env BABEL_CACHE_DIR=/tmp ROOT_URL=http://localhost PORT=3000 MONGO_URL=mongodb://localhost:27017/parties Accounts_AvatarStorePath=$SNAP_COMMON/uploads node $SNAP/main.js
        daemon: simple
        plugs: [network, network-bind]
    rocketchat-mongo:
        command: env LC_ALL=C mongod --bind_ip 127.0.0.1 --smallfiles --dbpath=$SNAP_COMMON
        daemon: simple
        plugs: [network, network-bind]
parts:
    node:
        plugin: nodejs
        node-engine: 4.7.0
        node-packages:
            - promise
            - fibers
            - underscore
            - source-map-support
            - semver
        build-packages:
            # For fibers
            - python
            - build-essential
            - nodejs
        organize:
            lib/node_modules: node_modules
    rocketchat-server:
        plugin: dump
        after: [mongodb]
        source: https://rocket.chat/releases/latest/download
        source-type: tar
        stage-packages:
            - graphicsmagick
        stage:
            - programs
            - main.js
            - usr
            - lib
        snap:
            - programs
            - main.js
            - usr
            - lib
    mongodb:
        source: https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-ubuntu1604-3.2.7.tgz
        plugin: dump
        stage-packages:
            - libssl1.0.0
        stage:
            - usr
            - bin
            - lib
        snap:
            - usr
            - bin
            - lib
