mirror of
https://github.com/OpenBB-finance/OpenBB.git
synced 2026-10-27 20:42:26 +00:00
Docker : image build + documentation (#3666)
* Moving Docker folder into Build * Workflows : update Docker * Docker : update compose image version * Docker : fix volumes path * Docker : image build + doc * Docker : update image name * Docker : update build * Docker : clean cache * Docker : image name
This commit is contained in:
9
build/docker/build.sh
vendored
9
build/docker/build.sh
vendored
@@ -4,10 +4,11 @@ echo "Building docker release"
|
||||
|
||||
# SET DEFAULT PARAMETERS IF EMPTY
|
||||
OPENBBTERMINAL_DOCKER_REGISTRY="${OPENBBTERMINAL_DOCKER_REGISTRY:-ghcr.io}"
|
||||
OPENBBTERMINAL_DOCKER_GITHUB_REPOSITORY="${OPENBBTERMINAL_DOCKER_GITHUB_REPOSITORY:-openbb-finance}"
|
||||
OPENBBTERMINAL_DOCKER_RELEASE_VERSION="${OPENBBTERMINAL_DOCKER_RELEASE_VERSION:-0.0.1}"
|
||||
OPENBBTERMINAL_DOCKER_GITHUB_REPOSITORY="${OPENBBTERMINAL_DOCKER_GITHUB_REPOSITORY:-openbb-finance/openbbterminal}"
|
||||
OPENBBTERMINAL_DOCKER_RELEASE_VERSION="${OPENBBTERMINAL_DOCKER_RELEASE_VERSION:-0.0.0}"
|
||||
# SET IMAGES NAMES
|
||||
OPENBBTERMINAL_DOCKER_POETRY_IMAGE=${OPENBBTERMINAL_DOCKER_REGISTRY,,}/${OPENBBTERMINAL_DOCKER_GITHUB_REPOSITORY,,}/poetry:${OPENBBTERMINAL_DOCKER_RELEASE_VERSION,,}
|
||||
OPENBBTERMINAL_DOCKER_POETRY_IMAGE=${OPENBBTERMINAL_DOCKER_REGISTRY,,}/${OPENBBTERMINAL_DOCKER_GITHUB_REPOSITORY,,}/openbb:${OPENBBTERMINAL_DOCKER_RELEASE_VERSION,,}
|
||||
OPENBBTERMINAL_DOCKER_POETRY_IMAGE_LATEST=${OPENBBTERMINAL_DOCKER_REGISTRY,,}/${OPENBBTERMINAL_DOCKER_GITHUB_REPOSITORY,,}/openbb:latest
|
||||
|
||||
# DISPLAY PARAMETERS
|
||||
echo "OPENBBTERMINAL_DOCKER_REGISTRY = $OPENBBTERMINAL_DOCKER_REGISTRY"
|
||||
@@ -17,4 +18,4 @@ echo "OPENBBTERMINAL_DOCKER_RELEASE_VERSION = $OPENBBTERMINAL_DOCKER_RELEASE_VER
|
||||
echo "OPENBBTERMINAL_DOCKER_POETRY_IMAGE = $OPENBBTERMINAL_DOCKER_POETRY_IMAGE"
|
||||
|
||||
# Docker command to build image
|
||||
docker build -f build/docker/poetry.dockerfile -t "${OPENBBTERMINAL_DOCKER_POETRY_IMAGE}" .
|
||||
docker build -f build/docker/openbb.dockerfile -t "${OPENBBTERMINAL_DOCKER_POETRY_IMAGE}" -t "${OPENBBTERMINAL_DOCKER_POETRY_IMAGE_LATEST}" .
|
||||
8
build/docker/docker-compose.yaml
vendored
8
build/docker/docker-compose.yaml
vendored
@@ -1,12 +1,12 @@
|
||||
version: '3.8'
|
||||
services:
|
||||
poetry:
|
||||
openbb:
|
||||
environment:
|
||||
DISPLAY: host.docker.internal:0.0
|
||||
volumes:
|
||||
- ~/OpenBBUserData:/root/OpenBBUserData
|
||||
- ~/.openbb_terminal:/root/.openbb_terminal
|
||||
- ~/OpenBBUserData:/home/python/OpenBBUserData
|
||||
- ~/.openbb_terminal:/home/python/.openbb_terminal
|
||||
platform: linux/amd64
|
||||
image: ghcr.io/openbb-finance/openbbterminal/poetry:2.0.0
|
||||
image: ghcr.io/openbb-finance/openbbterminal/openbb:2.0.0
|
||||
stdin_open: true # docker run -i
|
||||
tty: true # docker run -t
|
||||
64
build/docker/openbb.dockerfile
vendored
Normal file
64
build/docker/openbb.dockerfile
vendored
Normal file
@@ -0,0 +1,64 @@
|
||||
# SETUP PYTHON IMAGE
|
||||
FROM --platform=linux/amd64 python:3.10-slim-bullseye as python
|
||||
|
||||
LABEL org.opencontainers.image.source https://github.com/OpenBB-finance/OpenBBTerminal
|
||||
|
||||
# SETUP DEBIAN IMAGE
|
||||
FROM python as debian
|
||||
|
||||
RUN apt-get update
|
||||
|
||||
RUN apt-get -y install --no-install-recommends \
|
||||
gcc \
|
||||
g++ \
|
||||
make
|
||||
|
||||
RUN apt-get -y install --no-install-recommends \
|
||||
git
|
||||
|
||||
RUN apt-get -y install --no-install-recommends \
|
||||
curl \
|
||||
wget
|
||||
|
||||
RUN apt-get -y install --no-install-recommends \
|
||||
libsm6 \
|
||||
libxt6 \
|
||||
libgl1-mesa-glx \
|
||||
libpng16-16 \
|
||||
python3-tk
|
||||
|
||||
RUN apt-get clean
|
||||
|
||||
RUN useradd --create-home --shell /bin/bash python
|
||||
|
||||
USER python
|
||||
WORKDIR /home/python
|
||||
|
||||
# SETUP POETRY IMAGE
|
||||
FROM debian as poetry
|
||||
|
||||
ENV PATH="/home/python/.local/bin:${PATH}"
|
||||
|
||||
RUN pip install --upgrade pip wheel
|
||||
RUN pip install poetry==1.1.15
|
||||
|
||||
# SETUP OPENBB IMAGE
|
||||
FROM poetry as repository
|
||||
|
||||
COPY --chown=python:python pyproject.toml poetry.lock terminal.py ./
|
||||
|
||||
RUN mkdir openbb_terminal
|
||||
COPY --chown=python:python openbb_terminal openbb_terminal
|
||||
|
||||
RUN mkdir -p website/content/sdk/quickstart
|
||||
COPY --chown=python:python ./website/content/sdk/quickstart/installation.md ./website/content/sdk/quickstart
|
||||
|
||||
# SETUP OPENBB IMAGE
|
||||
FROM repository as dependencies
|
||||
|
||||
RUN poetry install --no-root --no-dev --extras optimization --extras prediction
|
||||
|
||||
# SETUP OPENBB IMAGE
|
||||
FROM dependencies as openbb
|
||||
|
||||
CMD ["poetry", "run", "python", "terminal.py"]
|
||||
73
build/docker/poetry.dockerfile
vendored
73
build/docker/poetry.dockerfile
vendored
@@ -1,73 +0,0 @@
|
||||
###############################################
|
||||
# Base Image openbb poetry build
|
||||
###############################################
|
||||
FROM --platform=linux/amd64 python:3.9-slim-bullseye as python
|
||||
|
||||
LABEL org.opencontainers.image.source https://github.com/OpenBB-finance/OpenBBTerminal
|
||||
|
||||
# PIP_DEFAULT_TIMEOUT: Set the default timeout for pip
|
||||
|
||||
ENV PIP_DEFAULT_TIMEOUT=100 \
|
||||
POETRY_VERSION=1.1.15 \
|
||||
POETRY_HOME="/opt/poetry" \
|
||||
POETRY_VIRTUALENVS_IN_PROJECT=true \
|
||||
POETRY_NO_INTERACTION=1 \
|
||||
PYSETUP_PATH="/opt" \
|
||||
VENV_PATH="/opt/.venv"
|
||||
|
||||
# prepend poetry and venv to path
|
||||
ENV PATH="$POETRY_HOME/bin:$VENV_PATH/bin:$PATH"
|
||||
|
||||
###############################################
|
||||
# Builder Image openbb poetry build
|
||||
###############################################
|
||||
|
||||
FROM python as poetry-deps
|
||||
|
||||
RUN apt-get update
|
||||
|
||||
RUN apt-get install --no-install-recommends -y \
|
||||
curl \
|
||||
build-essential \
|
||||
unzip \
|
||||
git \
|
||||
python3-tk
|
||||
|
||||
RUN curl -sL https://deb.nodesource.com/setup_16.x -o nodesource_setup.sh
|
||||
RUN bash nodesource_setup.sh
|
||||
RUN apt-get install -y nodejs
|
||||
RUN apt-get -y autoremove
|
||||
RUN apt-get clean
|
||||
RUN rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
|
||||
|
||||
# install poetry - respects $POETRY_VERSION & $POETRY_HOME
|
||||
RUN curl -sSL https://install.python-poetry.org | python3 -
|
||||
|
||||
# copy project requirement files here to ensure they will be cached.
|
||||
WORKDIR $PYSETUP_PATH
|
||||
|
||||
# Copy poetry files
|
||||
COPY pyproject.toml website/content/sdk/quickstart/installation.md poetry.lock ./
|
||||
|
||||
RUN mkdir -p website/content/sdk/quickstart
|
||||
RUN mkdir openbb_terminal
|
||||
RUN mv installation.md ./website/content/sdk/quickstart
|
||||
RUN touch openbb_terminal/__init__.py
|
||||
|
||||
# install runtime deps - uses $POETRY_VIRTUALENVS_IN_PROJECT internally
|
||||
RUN poetry install --no-dev --no-interaction -E optimization -E prediction
|
||||
|
||||
###############################################
|
||||
# Production Image openbb poetry build
|
||||
###############################################
|
||||
|
||||
FROM python as poetry
|
||||
|
||||
COPY --from=poetry-deps $PYSETUP_PATH $PYSETUP_PATH
|
||||
|
||||
WORKDIR $PYSETUP_PATH
|
||||
COPY . .
|
||||
|
||||
RUN echo "OPENBB_LOGGING_APP_NAME=gst_docker" > .env
|
||||
|
||||
CMD ["python", "terminal.py"]
|
||||
@@ -143,7 +143,7 @@ Here are the commands to use `Docker Compose` to pull and run the `OpenBBTermina
|
||||
```bash
|
||||
curl -o docker-compose.yaml https://raw.githubusercontent.com/OpenBB-finance/OpenBBTerminal/main/build/docker/docker-compose.yaml
|
||||
|
||||
docker compose run poetry
|
||||
docker compose run openbb
|
||||
```
|
||||
|
||||
The command line with `curl` is downloading this file : [`docker-compose.yaml`](https://raw.githubusercontent.com/OpenBB-finance/OpenBBTerminal/main/build/docker/docker-compose.yaml).
|
||||
@@ -164,12 +164,12 @@ If you don't have `Docker Compose` you can also use `Docker` directly to run the
|
||||
Here is the commands to run:
|
||||
|
||||
```bash
|
||||
docker pull ghcr.io/openbb-finance/openbbterminal-poetry:X.Y.Z
|
||||
docker pull ghcr.io/openbb-finance/openbbterminal/openbb:latest
|
||||
|
||||
docker run -v ~/.openbb_terminal/:/home/python/.openbb_terminal -v ~/OpenBBUserData:/home/python/OpenBBUserData -it --rm ghcr.io/openbb-finance/openbbterminal-poetry:X.Y.Z
|
||||
docker run -v ~/.openbb_terminal/:/home/python/.openbb_terminal -v ~/OpenBBUserData:/home/python/OpenBBUserData -it --rm ghcr.io/openbb-finance/openbbterminal/openbb:latest
|
||||
```
|
||||
|
||||
Be sure to replace `X.Y.Z` with the version you want to pull and run.
|
||||
You can replace `latest` with the version you want to pull and run.
|
||||
|
||||
Note for windows:
|
||||
|
||||
@@ -200,7 +200,7 @@ docker compose run poetry
|
||||
Or run `Docker` directly:
|
||||
|
||||
```bash
|
||||
docker run -v ~/.openbb_terminal:/home/python/.openbb_terminal -v ~/OpenBBUserData:/home/python/OpenBBUserData -it --rm --env DISPLAY=host.docker.internal:0.0 ghcr.io/openbb-finance/openbbterminal-poetry:X.Y.Z
|
||||
docker run -v ~/.openbb_terminal:/home/python/.openbb_terminal -v ~/OpenBBUserData:/home/python/OpenBBUserData -it --rm --env DISPLAY=host.docker.internal:0.0 ghcr.io/openbb-finance/openbbterminal/openbb:latest
|
||||
```
|
||||
|
||||
### X-Server on macOS
|
||||
@@ -229,7 +229,7 @@ xhost + $IP
|
||||
Now we can run the docker container, adding the display to the environment:
|
||||
|
||||
```bash
|
||||
docker run -v ~/.openbb_terminal/:/home/python/.openbb_terminal -v ~/OpenBBUserData:/home/python/OpenBBUserData -it --rm --env-file=path/to/setenv --env DISPLAY=$IP:0 ghcr.io/openbb-finance/openbbterminal-poetry:X.Y.Z
|
||||
docker run -v ~/.openbb_terminal/:/home/python/.openbb_terminal -v ~/OpenBBUserData:/home/python/OpenBBUserData -it --rm --env-file=path/to/setenv --env DISPLAY=$IP:0 ghcr.io/openbb-finance/openbbterminal/openbb:latest
|
||||
```
|
||||
|
||||
This container will be able to display all the same plots as the terminal interface.
|
||||
@@ -252,7 +252,7 @@ And run the following commands.
|
||||
|
||||
```bash
|
||||
xhost +local:
|
||||
docker run -it --rm --name openbb --env-file=./.env -e DISPLAY=$DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix ghcr.io/openbb-finance/openbbterminal-poetry:X.Y.Z
|
||||
docker run -it --rm --name openbb --env-file=./.env -e DISPLAY=$DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix ghcr.io/openbb-finance/openbbterminal/openbb:latest
|
||||
xhost -local:
|
||||
```
|
||||
|
||||
|
||||
Reference in New Issue
Block a user