diff options
author | Luqman Bello O <luqazino@gmail.com> | 2022-11-28 18:23:09 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-11-28 12:23:09 -0500 |
commit | d5d8e71e15286e883a3440947ce30f686abe1d9a (patch) | |
tree | 3f34e417164d0c11dbf316547e95be7592640687 | |
parent | d2622528e596430358ec55b61c5e003d1416e49f (diff) |
reduce docker image size (#3620)
* reduce docker image size
* Update pyproject
* Update pyproject
* reduce docker image size
* Update pyproject.toml
* reduce docker image size
* reduce docker image size
* Update docker image builder
Co-authored-by: Luqman Bello <lb@Luqmans-MacBook-Pro.local>
Co-authored-by: Chavithra PARANA <chavithra@gmail.com>
-rw-r--r-- | build/docker/README.md | 55 | ||||
-rw-r--r-- | build/docker/build.sh | 3 | ||||
-rw-r--r-- | build/docker/poetry.dockerfile | 10 | ||||
-rw-r--r-- | pyproject.toml | 6 |
4 files changed, 9 insertions, 65 deletions
diff --git a/build/docker/README.md b/build/docker/README.md deleted file mode 100644 index be6d097e4ea..00000000000 --- a/build/docker/README.md +++ /dev/null @@ -1,55 +0,0 @@ -# OpenBBTerminal Docker - -These files create our docker images. To use docker read [this](openbb_terminal/DOCKER_README.md). - -## Building the Docker Image - -Building the Docker image can be done easily. The following steps allow users to create a docker -image on their local machine: - -1. Enter the OpenBB directory `cd ~/OpenbbTerminal` -1. Open `docker/compose.env` and set `OPENBBTERMINAL_DOCKER_RELEASE_VERSION` to the desired version -1. Load the environment variables `bash compose/env` -1. Run the build script `bash docker/build.sh` - -### Important Notes - -1. The `build.sh` script requires bash 5.0 or newer. -1. We currently build without developer dependnencies such as pytest. If you want to develop using - this image please open `poetry.dockerfile` and replace `RUN poetry install --no-dev` with - `RUN poetry install` -1. If you have issues building on MacOs run the following commands: - - - `export DOCKER_BUILDKIT=0` - - `export COMPOSE_DOCKER_CLI_BUILD=0` - -## Testing the Docker Image - -Integration and unit tests can be run on the new docker image. Before running either set of tests -you need to start up an image with: - -- `docker run -it --rm ghcr.io/[BUILD_NAME]` - -Leave the terminal open and then navigate docker desktop. Find the currently running image and -select `open in terminal`. Now: - -- For integration tests run: `poetry run python terminal.py scripts -t` -- For unit tests run `poetry run pytest tests/` - -## Setup Explanation - -The `compose.env` file is responsible for loading in the correct environment variables before a -session begins. Once this is done the `build.sh` file creates a docker image with the appropriate -tag. The `poetry.dockerfile` is the file used to create the image. It has enhanced caching by -building in three stages. The stages are described below. - -- python: this stage creates a new `python:3.9-slim-bullseye` image. Slim-buster is a small linux - distro that comes with a lot of the functionality we need. We then set environment variables. - This image will only be reran when there is a new version of `python:3.9-slim-bullseye` or when - the environment variables are updated (there is almost never a reason to update them). -- poetry-deps: this stage installs necessary apt packages like curl and git, and then installs - poetry. This will be reran whenever dependencies change, or whenever `python` has been rerun. -- poetry: this takes the build from `poetry-deps` and then copies the terminal files into it. Then - this image runs the terminal. This image will be rebuilt every time files are changed in the - terminal or when `poetry-deps` has been rerun, however; this is not an issue because it builds - quickly. diff --git a/build/docker/build.sh b/build/docker/build.sh index 97d49fcc173..2b1451944ee 100644 --- a/build/docker/build.sh +++ b/build/docker/build.sh @@ -16,4 +16,5 @@ echo "OPENBBTERMINAL_DOCKER_RELEASE_VERSION = $OPENBBTERMINAL_DOCKER_RELEASE_VER # DISPLAY IMAGES NAMES echo "OPENBBTERMINAL_DOCKER_POETRY_IMAGE = $OPENBBTERMINAL_DOCKER_POETRY_IMAGE" -docker build -f docker/poetry.dockerfile -t "${OPENBBTERMINAL_DOCKER_POETRY_IMAGE}" . +# Docker command to build image +docker build -f build/docker/poetry.dockerfile -t "${OPENBBTERMINAL_DOCKER_POETRY_IMAGE}" .
\ No newline at end of file diff --git a/build/docker/poetry.dockerfile b/build/docker/poetry.dockerfile index 2028cb4c6a1..218c53079bc 100644 --- a/build/docker/poetry.dockerfile +++ b/build/docker/poetry.dockerfile @@ -45,16 +45,15 @@ 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 and install git -COPY pyproject.toml openbb_terminal/SDK_README.md poetry.lock ./ +# Copy poetry files +COPY pyproject.toml website/content/sdk/quickstart/installation.md poetry.lock ./ RUN mkdir $PYSETUP_PATH/openbb_terminal -RUN mv SDK_README.md ./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 -RUN poetry install -E optimization +RUN poetry install --no-dev --no-interaction -E optimization -E prediction ############################################### # Production Image openbb poetry build @@ -66,7 +65,6 @@ COPY --from=poetry-deps $PYSETUP_PATH $PYSETUP_PATH WORKDIR $PYSETUP_PATH COPY . . -RUN pip install "u8darts[torch]" RUN echo "OPENBB_LOGGING_APP_NAME=gst_docker" > .env diff --git a/pyproject.toml b/pyproject.toml index 305574d41e7..3df64d38a19 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -7,10 +7,10 @@ authors = ["Didier Rodrigues Lopes"] packages = [ { include = "openbb_terminal" }, ] -readme = "openbb_terminal/SDK_README.md" -homepage = "https://openbb.co/" +readme = "website/content/sdk/quickstart/installation.md" +homepage = "https://openbb.co" repository = "https://github.com/OpenBB-finance/OpenBBTerminal" -documentation = "https://openbb-finance.github.io/OpenBBTerminal/" +documentation = "https://docs.openbb.co/sdk" [tool.poetry.scripts] openbb = 'openbb_terminal.terminal_controller:parse_args_and_run' |