From 9615bc9e6129266596d658cbba56b95013f8b648 Mon Sep 17 00:00:00 2001 From: Nikhil Saraf <1028334+nikhilsaraf@users.noreply.github.com> Date: Fri, 2 Jul 2021 21:01:27 +0530 Subject: [PATCH] update Dockerfile to use pre-compiled binnary v1.11.0 (closes #713) --- README.md | 10 ++++++++++ ops/Dockerfile | 45 +++++++++++++++++++++------------------------ 2 files changed, 31 insertions(+), 24 deletions(-) diff --git a/README.md b/README.md index 1472e9fc3..a99f97ec6 100644 --- a/README.md +++ b/README.md @@ -37,6 +37,7 @@ Your use of Kelp is governed by the Apache 2.0 open-source license. Please note * [Getting Started](#getting-started) * [How To Get Kelp](#how-to-get-kelp) * [Download Kelp Binary](#download-kelp-binary) + * [Run With Docker](#run-with-docker) * [Compile from Source](#compile-from-source) * [Running Kelp](#running-kelp) * [Using CCXT](#using-ccxt) @@ -108,6 +109,15 @@ To run the bot in simulation mode, try this command: ./kelp trade -c sample_trader.cfg -s buysell -f sample_buysell.cfg --sim +### Run With Docker + +This docker image (`nikhilsaraf/kelp:latest`) points to the latest pre-compiled version of the kelp binary v1.11.0, which can be run like this: + +`docker run nikhilsaraf/kelp:latest version` +`docker run nikhilsaraf/kelp:latest trade -c sample_trader.cfg -s buysell -f sample_buysell.cfg --sim` +`docker run nikhilsaraf/kelp:latest exchanges` +`docker run nikhilsaraf/kelp:latest strategies` + ### Compile from Source _Note for Windows Users: You should use a [Bash Shell][bash] to follow the steps below. This will give you a UNIX environment in which to run your commands and will enable the `./scripts/build.sh` bash script to work correctly._ diff --git a/ops/Dockerfile b/ops/Dockerfile index dd56aecea..9867c23e5 100644 --- a/ops/Dockerfile +++ b/ops/Dockerfile @@ -1,35 +1,32 @@ -FROM golang:1.12.7 +FROM ubuntu:20.04 LABEL maintainer="Nikhil Saraf " -# install yarn -RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - -RUN echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list -RUN apt update -RUN apt -y install yarn +# add dependencies: curl, unzip +RUN apt-get update && apt-get install -y curl unzip -# set working dir -WORKDIR /go/src/github.com/stellar/kelp -RUN pwd +# fetch ccxt-rest +RUN mkdir -p /root/.kelp/ccxt +RUN curl -L https://github.com/stellar/kelp/releases/download/ccxt-rest_v0.0.4/ccxt-rest_linux-x64.zip -o /root/.kelp/ccxt/ccxt-rest_linux-x64.zip +RUN unzip /root/.kelp/ccxt/ccxt-rest_linux-x64.zip -d /root/.kelp/ccxt -# install glide -RUN curl -s https://glide.sh/get | sh - -# install kelp -ENV GOPATH /go -RUN git clone https://github.com/stellar/kelp.git . -RUN git fetch --tags -RUN glide install -RUN ./scripts/build.sh +# fetch kelp archive +RUN curl -L https://github.com/stellar/kelp/releases/download/v1.11.0/kelp-v1.11.0-linux-amd64.tar -o kelp-archive.tar +# extract +RUN tar xvf kelp-archive.tar +# set working directory +WORKDIR kelp-v1.11.0 # set ulimit RUN ulimit -n 10000 +# start ccxt-rest when container is started +CMD nohup /root/.kelp/ccxt/ccxt-rest_linux-x64/ccxt-rest > ~/ccxt-rest.log & + # use command line arguments from invocation of docker run against this ENTRYPOINT command - https://stackoverflow.com/a/40312311/1484710 -ENTRYPOINT ["./bin/kelp"] +ENTRYPOINT ["./kelp"] +# default arguments are empty +CMD [""] -# sample command to run this container as a daemon process: -# docker run -v `pwd`/ops:/go/src/github.com/stellar/kelp/bin/ops -d -p 8011:8011 server -p 8011 --ccxt-rest-url=http://host.docker.internal:3000 -# this assumes that you are running ccxt on port 3000 outside this kelp docker container -# the three port numbers (8011 in the example above) must be the same and must be specified -# the first part of the -v argument is the directory where you want to save the kelp configs and kelp logs from the bots created in this container +# sample command to run this container: +# docker run nikhilsaraf/kelp:latest trade -c sample_trader.cfg -s buysell -f sample_buysell.cfg --sim