Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docker support #382

Merged
merged 28 commits into from
Jun 8, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
0b3451d
Docker WIP
badgerwithagun May 18, 2019
ac56993
Settle on Dockerfile
badgerwithagun May 18, 2019
7765346
Absolute image paths to play nice on Docker Hub
badgerwithagun May 18, 2019
a742023
Include frontend build, increase memory usage
badgerwithagun May 18, 2019
683c78b
Drop to fit in 1GB memory
badgerwithagun May 18, 2019
bab457c
Actually use build (first attempt for new hosting)
badgerwithagun May 20, 2019
cdac3d5
Set up for container memory
badgerwithagun May 20, 2019
d6618c4
Add JMX settings
badgerwithagun May 20, 2019
542b10f
Remote install
badgerwithagun May 20, 2019
c81c0a3
Use mountable folder for H2 database
badgerwithagun May 21, 2019
c981eca
Docker secret support
badgerwithagun May 25, 2019
e4e229d
Missing class
badgerwithagun May 25, 2019
c165322
Docker secret support
badgerwithagun May 25, 2019
eceb261
Remove docker secrets fetch; it's just not an efficient way to work.
badgerwithagun May 26, 2019
ef9fbac
Make docker config optional
badgerwithagun May 26, 2019
0dcafb3
Make command line features work with bash scripting
badgerwithagun May 26, 2019
6bd7d34
Revert "Remove docker secrets fetch; it's just not an efficient way t…
badgerwithagun May 26, 2019
eab21d0
Remove rogue System.out which was hurting command line behaviour
badgerwithagun May 27, 2019
b0ab7ef
Escape quotes in YaML
badgerwithagun May 27, 2019
f4ef838
Use single quotes for secret substitution, remove unnecessary sysout
badgerwithagun May 27, 2019
d8ea668
Add dbinit command line command so we can add a db start position on …
badgerwithagun May 27, 2019
b35c1e4
Remove extraneous sysout [skip ci]
badgerwithagun May 27, 2019
0307c40
Sonar fix
badgerwithagun May 29, 2019
b024d02
Allow docker secret config to return blank
badgerwithagun May 29, 2019
1ff82ac
Setup base docker config
badgerwithagun May 29, 2019
735e7a0
Improve Docker secret parsing and improve testing
badgerwithagun May 29, 2019
1de79e4
Remove test case that fails on proper computers
badgerwithagun May 29, 2019
1dacfd2
Rationalise use of Maven profiles
badgerwithagun Jun 8, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
echo "Pull request: $CIRCLE_PULL_REQUEST"
echo " - Username: $CIRCLE_PR_USERNAME"
echo " - Repository: $CIRCLE_PR_REPONAME"
mvn -B -U -Pintegration-test clean install -Dskip.failsafe.tests=true -Dskip.surefire.tests=true -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn -T 1C
mvn -B -U -Pui,e2etest,bundle clean install -Dskip.failsafe.tests=true -Dskip.surefire.tests=true -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn -T 1C

- save_cache:
paths:
Expand Down
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,12 @@ matrix:
name: "JUnit tests, Spotbugs and Checkstyle (External)"
script: |
git fetch --unshallow --quiet
mvn -Pproduction clean test ${BUILD_ARGS}
mvn clean test ${BUILD_ARGS}

- if: repo = gruelbox/orko AND NOT branch = master AND tag IS present AND NOT type = pull_request
name: "Release to Github"
script: |
mvn -Pproduction clean package ${BUILD_ARGS}
mvn -Pui,bundle clean package ${BUILD_ARGS}
cd orko-app
mvn github-release:release --settings ../etc/.maven-settings.xml ${BUILD_ARGS}

Expand Down
30 changes: 15 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@ Orko is a **self hosted** web application which provides a unified dashboard to

All this without sharing your API keys with anyone.

![Screenshot](.github/app1.PNG)
![Screenshot](https://github.com/gruelbox/orko/blob/master/.github/app1.PNG?raw=true)

Feel like creating your own special order types, such as soft stops, stops triggered off the price of a different asset, or a "Nuke" button which sells all your alt positions? Orko features a [scripting](https://github.com/gruelbox/orko/wiki/Scripting) API allowing you to design your own bespoke order types.
Feel like creating your own special order types, such as soft stops, stops triggered off the price of a different asset, or a "Nuke" button which sells all your alt positions? Orko features a [scripting](https://github.com/gruelbox/orko/wiki/Scripting) API allowing you to design your own bespoke order types.

![Scripting UI](.github/scripting1.PNG)
![Scripting UI](https://github.com/gruelbox/orko/blob/master/.github/scripting1.PNG?raw=true)

Best of all, it's completely [free](https://www.fsf.org/about/what-is-free-software) (as in "free speech" as well as "free beer"). Read about some more [things it can do](https://github.com/gruelbox/orko/wiki/Example-Use-Cases).
Best of all, it's completely [free](https://www.fsf.org/about/what-is-free-software) (as in "free speech" as well as "free beer"). Read about some more [things it can do](https://github.com/gruelbox/orko/wiki/Example-Use-Cases).

<img align="right" src=".github/mobile1.png" width="281" height="609"/>
<img align="right" src="https://github.com/gruelbox/orko/blob/master/.github/mobile1.png?raw=true" width="281" height="609"/>

## Status
badgerwithagun marked this conversation as resolved.
Show resolved Hide resolved

Expand All @@ -52,21 +52,21 @@ Paper trading only. Can take 30 seconds to spin up when accessed. Don't expect t

### General

Orko does not support the following on any exchange: **deposits**, **withdrawals**, **funding** or **account management**. It is purely for trading. [Margin trading](https://github.com/gruelbox/orko/issues/83) including position management is on the roadmap but not supported yet.
Orko does not support the following on any exchange: **deposits**, **withdrawals**, **funding** or **account management**. It is purely for trading. [Margin trading](https://github.com/gruelbox/orko/issues/83) including position management is on the roadmap but not supported yet.

Exchanges with "excellent" support use **streaming updates**, which means that generally most changes will appear in the UI almost immediately. Without streaming updates, changes can take a number of seconds to be reflected in the UI. Usually, streaming updates are possible for any exchange, but involve considerably more work to implement, so exchanges tend to be added first without streaming updates and get updated later.

### By Exchange

| Exchange | Support level | Missing trading features | Notes |
| -------- | ------------- | ---- | ----- |
| Binance | ✔️ Excellent | Dust conversion | Almost perfect. |
| Bitfinex | ✔️ Excellent | True OCO trades, post only, reduce only, visibility of trades and positions on chart | Short on features, but what is supported is supported perfectly. |
| Coinbase Pro | ✔️ Excellent | Post only, good-till-cancelled | Very good, with one or two minor known issues. |
| Kucoin | ✔️ Good | Streaming updates | Works well other than the lack of streaming updates. |
| Bittrex | ✔️ Good | Streaming updates, stop orders | Works well other than the lack of streaming updates. |
| Bitmex | ⚠️ In development | Streaming updates, most complex order types, balances, historical trades | Not recommended for serious use yet. |
| Kraken | ⚠️ In development | Streaming updates, stop orders | Read-only. |
| Exchange | Support level | Missing trading features | Notes |
| ------------ | ----------------- | ------------------------------------------------------------------------------------ | ---------------------------------------------------------------- |
| Binance | ✔️ Excellent | Dust conversion | Almost perfect. |
| Bitfinex | ✔️ Excellent | True OCO trades, post only, reduce only, visibility of trades and positions on chart | Short on features, but what is supported is supported perfectly. |
| Coinbase Pro | ✔️ Excellent | Post only, good-till-cancelled | Very good, with one or two minor known issues. |
| Kucoin | ✔️ Good | Streaming updates | Works well other than the lack of streaming updates. |
| Bittrex | ✔️ Good | Streaming updates, stop orders | Works well other than the lack of streaming updates. |
| Bitmex | ⚠️ In development | Streaming updates, most complex order types, balances, historical trades | Not recommended for serious use yet. |
| Kraken | ⚠️ In development | Streaming updates, stop orders | Read-only. |

## Help wanted

Expand Down
9 changes: 6 additions & 3 deletions app.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
},
"MAVEN_CUSTOM_OPTS": {
"description": "Used by the Heroku buildpack. Do not change.",
"value": "-Pproduction -DskipTests=true -T 1C"
"value": "-Pui,bundle -DskipTests=true -T 1C"
},
"TELEGRAM_BOT_TOKEN": {
"description": "The Telegram bot API token. Can be omitted, in which case Telegram notifications won't be used.",
Expand All @@ -63,10 +63,13 @@
"quantity": 1
}
},
"addons": ["jawsdb", "papertrail"],
"addons": [
"jawsdb",
"papertrail"
],
"buildpacks": [
{
"url": "heroku/java"
}
]
}
}
3 changes: 2 additions & 1 deletion build-backend-only.sh
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
#!/bin/bash
mvn clean package -U -Pwebdev -Dmaven.test.skip=true -Dskip.failsafe.tests=true -Dspotbugs.skip=true -Dcheckstyle.skip=true -T 1C
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
mvn clean package -f "$DIR" -U -Dmaven.test.skip=true -Dskip.failsafe.tests=true -Dspotbugs.skip=true -Dcheckstyle.skip=true -T 1C
3 changes: 3 additions & 0 deletions build-docker.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
mvn clean package -f "$DIR" -U -P ui,docker -Dmaven.test.skip=true -Dskip.failsafe.tests=true -Dspotbugs.skip=true -Dcheckstyle.skip=true -T 1C
3 changes: 2 additions & 1 deletion build.sh
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
#!/bin/bash
mvn clean package -U -Pproduction -Dmaven.test.skip=true -Dskip.failsafe.tests=true -Dspotbugs.skip=true -Dcheckstyle.skip=true -T 1C
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
mvn clean package -f "$DIR" -U -Pui,bundle -Dmaven.test.skip=true -Dskip.failsafe.tests=true -Dspotbugs.skip=true -Dcheckstyle.skip=true -T 1C
142 changes: 90 additions & 52 deletions orko-app/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@

<profiles>
<profile>
<id>production</id>
<id>ui</id>
<dependencies>
<dependency>
<groupId>com.gruelbox</groupId>
Expand All @@ -60,24 +60,97 @@
</dependencies>
</profile>
<profile>
<id>integration-test</id>
<dependencies>
<dependency>
<groupId>com.gruelbox</groupId>
<artifactId>orko-ui</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
<id>bundle</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<executions>
<execution>
<id>shade</id>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<createDependencyReducedPom>true</createDependencyReducedPom>
<filters>
<filter>
<artifact>*:*</artifact>
<excludes>
<exclude>META-INF/*.SF</exclude>
<exclude>META-INF/*.DSA</exclude>
<exclude>META-INF/*.RSA</exclude>
</excludes>
</filter>
</filters>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ApacheLicenseResourceTransformer" />
<transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer" />
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>com.gruelbox.orko.app.monolith.MonolithApplication</mainClass>
</transformer>
<transformer implementation="org.apache.maven.plugins.shade.resource.ApacheNoticeResourceTransformer">
<addHeader>false</addHeader>
</transformer>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>release</id>
<dependencies>
<dependency>
<groupId>com.gruelbox</groupId>
<artifactId>orko-ui</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
<id>docker</id>
<build>
<plugins>
<plugin>
<groupId>com.google.cloud.tools</groupId>
<artifactId>jib-maven-plugin</artifactId>
<version>1.2.0</version>
<configuration>
<to>
<image>orko:latest</image>
</to>
<container>
<jvmFlags>
<jvmFlag>-XX:+UnlockExperimentalVMOptions</jvmFlag>
<jvmFlag>-XX:+UseCGroupMemoryLimitForHeap</jvmFlag>
<jvmFlag>-Dsun.net.inetaddr.ttl=60</jvmFlag>
<jvmFlag>-Dio.netty.leakDetectionLevel=advanced</jvmFlag>
<jvmFlag>-Dmorf.mysql.noadmin=true</jvmFlag>
<jvmFlag>-Ddw.server.connector.port=8080</jvmFlag>
<jvmFlag>-Dcom.sun.management.jmxremote.rmi.port=9090</jvmFlag>
<jvmFlag>-Dcom.sun.management.jmxremote=true</jvmFlag>
<jvmFlag>-Dcom.sun.management.jmxremote.port=9090</jvmFlag>
<jvmFlag>-Dcom.sun.management.jmxremote.ssl=false</jvmFlag>
<jvmFlag>-Dcom.sun.management.jmxremote.authenticate=false</jvmFlag>
<jvmFlag>-Dcom.sun.management.jmxremote.local.only=false</jvmFlag>
<jvmFlag>-Djava.rmi.server.hostname=localhost</jvmFlag>
</jvmFlags>
<mainClass>com.gruelbox.orko.app.monolith.MonolithApplication</mainClass>
badgerwithagun marked this conversation as resolved.
Show resolved Hide resolved
<args>
<arg>server</arg>
<arg>docker-config.yml</arg>
</args>
<ports>
<port>8080</port>
</ports>
</container>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>buildTar</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>

Expand All @@ -96,41 +169,6 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<createDependencyReducedPom>true</createDependencyReducedPom>
<filters>
<filter>
<artifact>*:*</artifact>
<excludes>
<exclude>META-INF/*.SF</exclude>
<exclude>META-INF/*.DSA</exclude>
<exclude>META-INF/*.RSA</exclude>
</excludes>
</filter>
</filters>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ApacheLicenseResourceTransformer" />
<transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer" />
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>com.gruelbox.orko.app.monolith.MonolithApplication</mainClass>
</transformer>
<transformer implementation="org.apache.maven.plugins.shade.resource.ApacheNoticeResourceTransformer">
<addHeader>false</addHeader>
</transformer>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>de.jutzig</groupId>
<artifactId>github-release-plugin</artifactId>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/**
* Orko
* Copyright © 2018-2019 Graham Crockford
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.gruelbox.orko.app.monolith;

import org.alfasoftware.morf.jdbc.ConnectionResources;

import com.gruelbox.orko.OrkoConfiguration;
import com.gruelbox.orko.db.DbDump;

import io.dropwizard.cli.Cli;
import io.dropwizard.cli.ConfiguredCommand;
import io.dropwizard.setup.Bootstrap;
import net.sourceforge.argparse4j.inf.Namespace;
import net.sourceforge.argparse4j.inf.Subparser;

/**
* Command line command to restore a database dump
*/
class DbInitCommand extends ConfiguredCommand<OrkoConfiguration> {

DbInitCommand() {
super("dbinit", "Imports a database snapshot taken using the /api/db.zip endpoint to the configured DB");
}

@Override
protected void run(Bootstrap<OrkoConfiguration> bootstrap, Namespace namespace, OrkoConfiguration configuration) throws Exception {
ConnectionResources connectionResources = configuration.getDatabase().toConnectionResources();
new DbDump(connectionResources).restore(namespace.getString("dbfile"));
}

@Override
public void configure(Subparser subparser) {
super.configure(subparser);
subparser.addArgument("dbfile")
.required(true)
.help("The database dump filename to load");
}

@Override
public void onError(Cli cli, Namespace namespace, Throwable e) {
cli.getStdErr().println(e.getMessage());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,25 +27,31 @@

class HashCommand extends Command {

private static final String SALT_PARM = "salt";
private static final String VALUE_PARM = "value";

HashCommand() {
super("hash", "Hashes the specified value using a provided salt");
}

@Override
public void run(Bootstrap<?> bootstrap, Namespace namespace) throws Exception {
Hasher hasher = new Hasher();
String salt = namespace.getString("salt");
if (salt == null)
String salt = namespace.getString(SALT_PARM);
if (salt == null) {
salt = hasher.salt();
System.out.println("Salt used: " + salt);
System.out.println("Hashed result: " + hasher.hash(namespace.getString("value"), salt));
System.out.println("Salt used: " + salt);
System.out.println("Hashed result: " + hasher.hash(namespace.getString(VALUE_PARM), salt));
} else {
System.out.print(hasher.hash(namespace.getString(VALUE_PARM), salt));
}
}

@Override
public void configure(Subparser subparser) {
subparser.addArgument("--salt", "-s")
subparser.addArgument("--" + SALT_PARM, "-s")
.help("An encryption salt. If not provided, a new one will be used and returned.");
subparser.addArgument("value")
subparser.addArgument(VALUE_PARM)
.required(true)
.help("The value for which to create a hash.");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,6 @@ protected void addDefaultCommands(Bootstrap<OrkoConfiguration> bootstrap) {
bootstrap.addCommand(new OtpCommand());
bootstrap.addCommand(new HashCommand());
bootstrap.addCommand(new SaltCommand());
bootstrap.addCommand(new DbInitCommand());
}
}
Loading