Skip to content

Commit

Permalink
Merge pull request #26 from devicehive/development
Browse files Browse the repository at this point in the history
Development
  • Loading branch information
tmatvienko authored Jun 15, 2018
2 parents 924192e + 7e07799 commit e98b4ae
Show file tree
Hide file tree
Showing 7 changed files with 430 additions and 555 deletions.
4 changes: 1 addition & 3 deletions Dockerfile.plugin → Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,4 @@ RUN apk update \
&& npm cache clean --force \
&& apk del .gyp

VOLUME ["/usr/src/app/cassandraSchemas", "/usr/src/app/cassandraConfig"]

CMD ["npm", "start"]
CMD ["npm", "start"]
26 changes: 0 additions & 26 deletions Dockerfile.schema

This file was deleted.

34 changes: 34 additions & 0 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
properties([
buildDiscarder(logRotator(artifactDaysToKeepStr: '', artifactNumToKeepStr: '32', daysToKeepStr: '', numToKeepStr: '100'))
])

def publishable_branches = ["development", "master"]

node('docker') {
stage('Build and publish Docker images in CI repository') {
checkout scm
echo 'Building image ...'
def DevicehivePluginCassandraNode = docker.build('devicehiveci/devicehive-plugin-cassandra-node:${BRANCH_NAME}', '--pull -f Dockerfile .')

echo 'Pushing image to CI repository ...'
docker.withRegistry('https://registry.hub.docker.com', 'devicehiveci_dockerhub'){
DevicehivePluginCassandraNode.push()
}
}
}

if (publishable_branches.contains(env.BRANCH_NAME)) {
node('docker') {
stage('Publish image in main repository') {
// Builds from 'master' branch will have 'latest' tag
def IMAGE_TAG = (env.BRANCH_NAME == 'master') ? 'latest' : env.BRANCH_NAME

docker.withRegistry('https://registry.hub.docker.com', 'devicehiveci_dockerhub'){
sh """
docker tag devicehiveci/devicehive-plugin-cassandra-node:${BRANCH_NAME} registry.hub.docker.com/devicehive/devicehive-plugin-cassandra-node:${IMAGE_TAG}
docker push registry.hub.docker.com/devicehive/devicehive-plugin-cassandra-node:${IMAGE_TAG}
"""
}
}
}
}
17 changes: 15 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,12 @@ When the message arrives it can be either a command, command update, or notifica
1. Start DeviceHive
2. Start Cassandra
3. Create Cassandra keyspace
4. Create following .env file. **Replace username, password, plugin topic, localhost, keyspace name, cassandra username and password with your values.**
4. Create following .env file. **Replace access and refresh tokens (or username and password), plugin topic, localhost, keyspace name, cassandra username and password with your values.**

ENVSEPARATOR=_ <br />
plugin_user_login=username<br />
plugin_user_access_token=your.JWT.accessToken <br />
plugin_user_refresh_token=your.JWT.refreshToken <br />
plugin_user_login=username <br />
plugin_user_password=password <br />
plugin_plugin_topic=plugin topic <br />
plugin_device_hive_plugin_ws_endpoint=ws://localhost:3001 <br />
Expand Down Expand Up @@ -45,6 +47,17 @@ When the message arrives it can be either a command, command update, or notifica
--------------+---------------------------------+-------------------------------------------
test | 2018-02-27 17:17:27.963000+0000 | { "yourParam": "custom parameter value" }


Note: **If you have Cassandra running in separate Docker network or without any container please specify as contact points IP of Docker container or Docker host/another machine IP instead of localhost so plugin could connect to Cassandra(cassandra_connection_contactPoints in env file)**

# Manual run (without Docker)

1. Start DeviceHive
2. Start Cassandra
3. Create Cassandra keyspace
4. Configure your plugin and Cassandra connections with *plugin/plugin-config.json* and *cassandraConfig/config.json* (see [Configuration](#configuration))
5. Execute: `npm run plugin` to create Cassandra schemas defined with JSON and to run plugin

# Configuration
## Plugin
Plugin part of configuration you can find [here](https://github.com/devicehive/devicehive-plugin-core-node#configuration).
Expand Down
8 changes: 5 additions & 3 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,22 @@ services:
plugin:
build:
context: .
dockerfile: Dockerfile.plugin
dockerfile: Dockerfile
env_file:
- .env
depends_on:
- schema
volumes:
- ./cassandraSchemas/:/usr/src/app/cassandraSchemas:ro
- ./cassandraConfig/:/usr/src/app/cassandraConfig:ro

schema:
build:
context: .
dockerfile: Dockerfile.schema
dockerfile: Dockerfile
command: ["npm", "run", "schema"]
env_file:
- .env
volumes:
- ./cassandraSchemas/:/usr/src/app/cassandraSchemas:ro
- ./cassandraConfig/:/usr/src/app/cassandraConfig:ro
- ./cassandraConfig/:/usr/src/app/cassandraConfig:ro
Loading

0 comments on commit e98b4ae

Please sign in to comment.