From 19d1a9a0678e698d15f187fdbfb324a4e931a9aa Mon Sep 17 00:00:00 2001 From: Jinto Jose <129657162+jj701@users.noreply.github.com> Date: Fri, 9 Jun 2023 06:44:58 -0700 Subject: [PATCH] Vscode/Github Codespaces dev container (#4975) * vscode/Github Codespaces dev container * move badge to new line * actually move badge to new line --------- Co-authored-by: James Maslek --- .devcontainer/Dockerfile | 79 +++++++++++++++++++++++++++++++ .devcontainer/devcontainer.json | 33 +++++++++++++ .devcontainer/docker-compose.yaml | 11 +++++ README.md | 4 ++ 4 files changed, 127 insertions(+) create mode 100644 .devcontainer/Dockerfile create mode 100644 .devcontainer/devcontainer.json create mode 100644 .devcontainer/docker-compose.yaml diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile new file mode 100644 index 00000000000..d129cb15a14 --- /dev/null +++ b/.devcontainer/Dockerfile @@ -0,0 +1,79 @@ +# SETUP PYTHON IMAGE +FROM --platform=linux/amd64 mcr.microsoft.com/vscode/devcontainers/python:0-3.10-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 \ + libwebkit2gtk-4.0-dev \ + build-essential \ + libssl-dev \ + librsvg2-dev \ + ffmpeg \ + python3-tk + +RUN apt-get clean + +USER vscode +WORKDIR /home/vscode + +# SETUP POETRY IMAGE +FROM debian as poetry + +ENV PATH="/home/vscode/.local/bin:${PATH}" + +# Define the version of Poetry to install (default is 1.4.2) +# Define the directory of python virtual environment +ARG PYTHON_VIRTUALENV_HOME=/home/vscode/openbb-py-env \ + POETRY_VERSION=1.4.0 + +ENV POETRY_VIRTUALENVS_IN_PROJECT=false \ + POETRY_NO_INTERACTION=true + +# Create a Python virtual environment for Poetry and install it +RUN python3 -m venv ${PYTHON_VIRTUALENV_HOME} && \ + $PYTHON_VIRTUALENV_HOME/bin/pip install --upgrade pip wheel && \ + $PYTHON_VIRTUALENV_HOME/bin/pip install poetry==${POETRY_VERSION} + +ENV PATH="$PYTHON_VIRTUALENV_HOME/bin:$PATH" \ + VIRTUAL_ENV=$PYTHON_VIRTUALENV_HOME + +# Setup for bash +RUN poetry completions bash >> /home/vscode/.bash_completion && \ + echo "export PATH=$PYTHON_VIRTUALENV_HOME/bin:$PATH" >> ~/.bashrc + +# SETUP OPENBB IMAGE +FROM poetry as openbb-dev + +COPY --chown=vscode:vscode pyproject.toml poetry.lock ./ + +RUN mkdir OpenBBUserData +RUN chown vscode:vscode OpenBBUserData + +RUN mkdir .openbb_terminal +RUN chown vscode:vscode .openbb_terminal + +RUN poetry install --no-root --extras optimization --extras forecast + +# Set the working directory for the app +WORKDIR /workspaces/openbb \ No newline at end of file diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 00000000000..455ca0c18ec --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,33 @@ +// For format details, see https://aka.ms/devcontainer.json. For config options, see the +// README at: https://github.com/devcontainers/templates/tree/main/src/docker-existing-dockerfile +{ + "dockerComposeFile": "./docker-compose.yaml", + "service": "openbb", + "workspaceFolder": "/workspaces/openbb", + "name": "openbb", + "customizations": { + "vscode": { + "extensions": [ + "ms-python.python" + ], + "settings": { + "python.defaultInterpreterPath": "/home/vscode/openbb-py-env/bin/python" + } + } + + }, + + // Features to add to the dev container. More info: https://containers.dev/features. + "features": {}, + + // Use 'forwardPorts' to make a list of ports inside the container available locally. + "forwardPorts": [], + + // Uncomment the next line to run commands after the container is created. + // "postCreateCommand": "cat /etc/os-release", + + // Uncomment to connect as an existing user other than the container default. More info: https://aka.ms/dev-containers-non-root. + // "remoteUser": "devcontainer" + "remoteUser": "vscode", + "overrideCommand": true +} diff --git a/.devcontainer/docker-compose.yaml b/.devcontainer/docker-compose.yaml new file mode 100644 index 00000000000..fffffdfb91a --- /dev/null +++ b/.devcontainer/docker-compose.yaml @@ -0,0 +1,11 @@ +version: '3.8' +services: + openbb: + volumes: + - ~/OpenBBUserData:/home/vscode/OpenBBUserData + - ~/.openbb_terminal:/home/vscode/.openbb_terminal + - ../:/workspaces/openbb + platform: linux/amd64 + build: + dockerfile: .devcontainer/Dockerfile + context: ../ diff --git a/README.md b/README.md index 591dfe4374c..221332fb10d 100644 --- a/README.md +++ b/README.md @@ -23,6 +23,10 @@ ![Discord Shield](https://discordapp.com/api/guilds/831165782750789672/widget.png?style=shield) [![Twitter](https://img.shields.io/twitter/url/https/twitter.com/openbb_finance.svg?style=social&label=Follow%20%40openbb_finance)](https://twitter.com/openbb_finance) +[![Open in Dev Containers](https://img.shields.io/static/v1?label=Dev%20Containers&message=Open&color=blue&logo=visualstudiocode)](https://vscode.dev/redirect?url=vscode://ms-vscode-remote.remote-containers/cloneInVolume?url=https://github.com/OpenBB-finance/OpenBBTerminal) + +[![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/OpenBB-finance/OpenBBTerminal) + | OpenBB is committed to build the future of investment research by focusing on an open source infrastructure accessible to everyone, everywhere. |