#
# 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.43.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 ROOT_URL=http://localhost PORT=3000 MONGO_URL=mongodb://localhost:27017/parties Accounts_AvatarStorePath=$SNAP_COMMON/uploads node $SNAP/main.js >$SNAP_DATA/server.log 2>&1
        daemon: simple
        plugs: [network, network-bind]
    rocketchat-mongo:
        command: env LC_ALL=C mongod --smallfiles --dbpath=$SNAP_COMMON
        daemon: simple
        plugs: [network, network-bind]
parts:
    node:
        plugin: nodejs
        node-engine: 4.6.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/develop/download
        source-type: tar
        stage-packages:
            - imagemagick
        organize:
            usr/bin/convert-im6: usr/bin/convert
        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
