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

Created Dockerfile to run service in container - Currently Supports EOS & WAX #17

Open
wants to merge 23 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@ build/
contract/oracle.wasm
contract/*.sh
src/*.sh
oracleconf.py
lib/
22 changes: 22 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# build environment
FROM node:14.5.0-alpine

## ENV variables
ENV PERM=active

WORKDIR /app
ENV PATH /app/node_modules/.bin:$PATH
COPY scripts/package.json ./
COPY scripts/package-lock.json ./
COPY scripts/docker-updater.js ./updater.js
COPY scripts/docker.env .env


RUN npm ci --silent
RUN npm install react-scripts@3.4.1 -g --silent


# Entrypoint
ADD scripts/start.sh /
RUN chmod +x /start.sh
CMD /start.sh
24 changes: 24 additions & 0 deletions Dockerfile-python
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# build environment
FROM node:14.5.0-alpine

## ENV variables
ENV PERM=active

RUN apk add --update-cache \
python3 \
py3-pip \
&& pip3 install eospyo preprocessing \
&& rm -rf /var/cache/apk/*

WORKDIR /app
ENV PATH /app/node_modules/.bin:$PATH
COPY scripts/docker-updater.py ./updater.py
COPY scripts/docker-python.conf oracleconf.py




# Entrypoint
ADD scripts/python-start.sh /
RUN chmod +x /python-start.sh
CMD /python-start.sh
54 changes: 54 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -208,3 +208,57 @@ if you have `jq` installed, you can show the first record, which should contain
```
cleos get table --limit 100 delphioracle eosusd datapoints |jq .rows[0]
```

# Running the updater.js using Docker
## :exclamation: Updater in docker uses EOSJS v2

## ENV Variables

|ENV & ARG |Value |Description |
|--------------------------|-------------------------------|-----------------------------------------------|
|**PRIVATE_KEY** |`5xxxxxxxxxxxx` | The prviate key of your permission |
|**BPNAME** |`sentnlagents` | Your BP account |
|**PERM** |`oracle` | If using Custom permission; defaults to active|
|**API** |`https://hyperion6.sentnl.io"` | Wax API endpoint |
|**CHAIN** |`wax` | The EOSIO Chain that hosts the delphioracle |
|**APIPORT** |`443` | The port of API endpoint |
|**APIKEY** |`XXXXXXXXXXXXX` | API key to min-api.cryptocompare.com |

## Build the production container for Javascript version

```
docker build https://github.com/ankh2054/delphioracle.git -t delphioracle
```

## Build the production container for Python version

```
git pull https://github.com/ankh2054/delphioracle.git
docker build -f Dockerfile-python -t delphioracle.python .
```

## Run the container passing required ENV variables


### The following ENV variables need to be passed:


- **APIKEY** - The API key for min-api.cryptocompare.com
- **BPNAME** - The name of your bp account
- **PERM** - The permissions to sign the transaction with. Defaults to active.
- **PRIVATE_KEY** - The private associated with your EOSIO account
- **API** - The API endpoint you wish to use.
- **CHAIN** - The EOSIO Chain that hosts the delphioracle. :exclamation: Currently only WAX and EOS is supported.

```Dockerfile:
docker run --name delphioracle.wax \
-d -e "PRIVATE_KEY=xxxxxxxxxxxxx" \
-e "BPNAME=sentnlagents" \
-e "PERM=oracle" \
-e "API=https://hyperion6.sentnl.io" \
-e "APIPORT=4343" \
-e "CHAIN=wax" \
-e "APIKEY=XXXXXXXXXXX" \
delphioracle
```

83 changes: 83 additions & 0 deletions bin/activate
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
# This file must be used with "source bin/activate" *from bash*
# you cannot run it directly


if [ "${BASH_SOURCE-}" = "$0" ]; then
echo "You must source this script: \$ source $0" >&2
exit 33
fi

deactivate () {
unset -f pydoc >/dev/null 2>&1 || true

# reset old environment variables
# ! [ -z ${VAR+_} ] returns true if VAR is declared at all
if ! [ -z "${_OLD_VIRTUAL_PATH:+_}" ] ; then
PATH="$_OLD_VIRTUAL_PATH"
export PATH
unset _OLD_VIRTUAL_PATH
fi
if ! [ -z "${_OLD_VIRTUAL_PYTHONHOME+_}" ] ; then
PYTHONHOME="$_OLD_VIRTUAL_PYTHONHOME"
export PYTHONHOME
unset _OLD_VIRTUAL_PYTHONHOME
fi

# The hash command must be called to get it to forget past
# commands. Without forgetting past commands the $PATH changes
# we made may not be respected
hash -r 2>/dev/null

if ! [ -z "${_OLD_VIRTUAL_PS1+_}" ] ; then
PS1="$_OLD_VIRTUAL_PS1"
export PS1
unset _OLD_VIRTUAL_PS1
fi

unset VIRTUAL_ENV
if [ ! "${1-}" = "nondestructive" ] ; then
# Self destruct!
unset -f deactivate
fi
}

# unset irrelevant variables
deactivate nondestructive

VIRTUAL_ENV='/Users/charlesholtzkampf/sentnl/delphioracle'
if ([ "$OSTYPE" = "cygwin" ] || [ "$OSTYPE" = "msys" ]) && $(command -v cygpath &> /dev/null) ; then
VIRTUAL_ENV=$(cygpath -u "$VIRTUAL_ENV")
fi
export VIRTUAL_ENV

_OLD_VIRTUAL_PATH="$PATH"
PATH="$VIRTUAL_ENV/bin:$PATH"
export PATH

# unset PYTHONHOME if set
if ! [ -z "${PYTHONHOME+_}" ] ; then
_OLD_VIRTUAL_PYTHONHOME="$PYTHONHOME"
unset PYTHONHOME
fi

if [ -z "${VIRTUAL_ENV_DISABLE_PROMPT-}" ] ; then
_OLD_VIRTUAL_PS1="${PS1-}"
if [ "x" != x ] ; then
PS1="() ${PS1-}"
else
PS1="(`basename \"$VIRTUAL_ENV\"`) ${PS1-}"
fi
export PS1
fi

# Make sure to unalias pydoc if it's already there
alias pydoc 2>/dev/null >/dev/null && unalias pydoc || true

pydoc () {
python -m pydoc "$@"
}

# The hash command must be called to get it to forget past
# commands. Without forgetting past commands the $PATH changes
# we made may not be respected
hash -r 2>/dev/null
55 changes: 55 additions & 0 deletions bin/activate.csh
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# This file must be used with "source bin/activate.csh" *from csh*.
# You cannot run it directly.
# Created by Davide Di Blasi <davidedb@gmail.com>.

set newline='\
'

alias deactivate 'test $?_OLD_VIRTUAL_PATH != 0 && setenv PATH "$_OLD_VIRTUAL_PATH:q" && unset _OLD_VIRTUAL_PATH; rehash; test $?_OLD_VIRTUAL_PROMPT != 0 && set prompt="$_OLD_VIRTUAL_PROMPT:q" && unset _OLD_VIRTUAL_PROMPT; unsetenv VIRTUAL_ENV; test "\!:*" != "nondestructive" && unalias deactivate && unalias pydoc'

# Unset irrelevant variables.
deactivate nondestructive

setenv VIRTUAL_ENV '/Users/charlesholtzkampf/sentnl/delphioracle'

set _OLD_VIRTUAL_PATH="$PATH:q"
setenv PATH "$VIRTUAL_ENV:q/bin:$PATH:q"



if ('' != "") then
set env_name = '() '
else
set env_name = '('"$VIRTUAL_ENV:t:q"') '
endif

if ( $?VIRTUAL_ENV_DISABLE_PROMPT ) then
if ( $VIRTUAL_ENV_DISABLE_PROMPT == "" ) then
set do_prompt = "1"
else
set do_prompt = "0"
endif
else
set do_prompt = "1"
endif

if ( $do_prompt == "1" ) then
# Could be in a non-interactive environment,
# in which case, $prompt is undefined and we wouldn't
# care about the prompt anyway.
if ( $?prompt ) then
set _OLD_VIRTUAL_PROMPT="$prompt:q"
if ( "$prompt:q" =~ *"$newline:q"* ) then
:
else
set prompt = "$env_name:q$prompt:q"
endif
endif
endif

unset env_name
unset do_prompt

alias pydoc python -m pydoc

rehash
100 changes: 100 additions & 0 deletions bin/activate.fish
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
# This file must be used using `source bin/activate.fish` *within a running fish ( http://fishshell.com ) session*.
# Do not run it directly.

function _bashify_path -d "Converts a fish path to something bash can recognize"
set fishy_path $argv
set bashy_path $fishy_path[1]
for path_part in $fishy_path[2..-1]
set bashy_path "$bashy_path:$path_part"
end
echo $bashy_path
end

function _fishify_path -d "Converts a bash path to something fish can recognize"
echo $argv | tr ':' '\n'
end

function deactivate -d 'Exit virtualenv mode and return to the normal environment.'
# reset old environment variables
if test -n "$_OLD_VIRTUAL_PATH"
# https://github.com/fish-shell/fish-shell/issues/436 altered PATH handling
if test (echo $FISH_VERSION | head -c 1) -lt 3
set -gx PATH (_fishify_path "$_OLD_VIRTUAL_PATH")
else
set -gx PATH $_OLD_VIRTUAL_PATH
end
set -e _OLD_VIRTUAL_PATH
end

if test -n "$_OLD_VIRTUAL_PYTHONHOME"
set -gx PYTHONHOME "$_OLD_VIRTUAL_PYTHONHOME"
set -e _OLD_VIRTUAL_PYTHONHOME
end

if test -n "$_OLD_FISH_PROMPT_OVERRIDE"
and functions -q _old_fish_prompt
# Set an empty local `$fish_function_path` to allow the removal of `fish_prompt` using `functions -e`.
set -l fish_function_path

# Erase virtualenv's `fish_prompt` and restore the original.
functions -e fish_prompt
functions -c _old_fish_prompt fish_prompt
functions -e _old_fish_prompt
set -e _OLD_FISH_PROMPT_OVERRIDE
end

set -e VIRTUAL_ENV

if test "$argv[1]" != 'nondestructive'
# Self-destruct!
functions -e pydoc
functions -e deactivate
functions -e _bashify_path
functions -e _fishify_path
end
end

# Unset irrelevant variables.
deactivate nondestructive

set -gx VIRTUAL_ENV '/Users/charlesholtzkampf/sentnl/delphioracle'

# https://github.com/fish-shell/fish-shell/issues/436 altered PATH handling
if test (echo $FISH_VERSION | head -c 1) -lt 3
set -gx _OLD_VIRTUAL_PATH (_bashify_path $PATH)
else
set -gx _OLD_VIRTUAL_PATH $PATH
end
set -gx PATH "$VIRTUAL_ENV"'/bin' $PATH

# Unset `$PYTHONHOME` if set.
if set -q PYTHONHOME
set -gx _OLD_VIRTUAL_PYTHONHOME $PYTHONHOME
set -e PYTHONHOME
end

function pydoc
python -m pydoc $argv
end

if test -z "$VIRTUAL_ENV_DISABLE_PROMPT"
# Copy the current `fish_prompt` function as `_old_fish_prompt`.
functions -c fish_prompt _old_fish_prompt

function fish_prompt
# Run the user's prompt first; it might depend on (pipe)status.
set -l prompt (_old_fish_prompt)

# Prompt override provided?
# If not, just prepend the environment name.
if test -n ''
printf '(%s) ' ''
else
printf '(%s) ' (basename "$VIRTUAL_ENV")
end

string join -- \n $prompt # handle multi-line prompts
end

set -gx _OLD_FISH_PROMPT_OVERRIDE "$VIRTUAL_ENV"
end