OCLI in Docker

Build OCLI Docker image

Get or build the “ocli-base” image first

docker buildx build --platform=linux/amd64 -t ocli:latest .

First run in docker

Test run.

docker run -it ocli:latest 

If everything is ok you will see prompt like

➜  ~ docker run -it ocli:latest 
⚠️ WARNING: Could not load ocli.pro: No module named 'ocli.pro'
→         
→         use  ? command to OCLI help
→         use :? command to show console help
→         use <TAB> to auto-complete commands
→         use :q or Ctrl-d to exit       
→         use exit command exit       
→         
tsar:default::>

Run OCLI REPL in Docker

Before start please make sure that you have $OCLI_HOME, $OCLI_CREDENTIALS and $OCLI_RC on your local system. You can create whole infrastructure using “OCLI environment init script” (please see below).

OCLI_HOME=${OCLI_HOME:-"$HOME/OCLI_HOME"}
SSH_CREDENTIALS=${SSH_CREDENTIALS:-"$HOME/.ssh"}

docker run -it \
  -v $OCLI_HOME:$OCLI_HOME \
  -v $SSH_CREDENTIALS:/root/.ssh \
  ocli:latest 

OCLI for developers

Please remember $OCLI_HOME, $OCLI_CREDENTIALS and $OCLI_RC is non mandatory if do not want to preserve ocli configuration and artifacts.

OCLI_HOME=${OCLI_HOME:-"$HOME/OCLI_HOME"}
SSH_CREDENTIALS=${SSH_CREDENTIALS:-"$HOME/.ssh"}
OCLI_SOURCE=${OCLI_SOURCE:-"./"}

docker run -it \
  -v $OCLI_HOME:$OCLI_HOME \
  -v $SSH_CREDENTIALS:/root/.ssh \
  -v $OCLI_SOURCE:/root/ocli_install/ocli \
  ocli:latest \
  bash

Now you can edit $OCLI_SOURCE in your favourite IDE or editor.

After the first run in Docker container, you need to install OCLI (inside Docker container)

pip install -e /root/ocli_install/ocli

Run inside of docker container:

ocli -v DEBUG repl