diff --git a/.dockerignore b/.dockerignore index 66d49ea0..ab5e8767 100755 --- a/.dockerignore +++ b/.dockerignore @@ -1,15 +1,11 @@ -#https://stackoverflow.com/questions/28097064/dockerignore-ignore-everything-except-a-file-and-the-dockerfile +# Environments +.env +.venv +env/ +venv/ +ENV/ +env.bak/ +venv.bak/ -# Ignore Everything -** - -!pypfopt -!tests -!setup.py -!README.md -!requirements.txt -!binder -!cookbook - -**/__pycache__ -**/*.pyc +*/__pycache__ +*/*.pyc \ No newline at end of file diff --git a/.gitignore b/.gitignore index 1868dd62..df7aef02 100644 --- a/.gitignore +++ b/.gitignore @@ -11,6 +11,15 @@ DEV/ .pytest_cache/ .vscode/ +# Environments +.env +.venv +env/ +venv/ +ENV/ +env.bak/ +venv.bak/ + pip-selfcheck.json html-coverage diff --git a/Dockerfile b/Dockerfile index 21286730..fd7cf0f7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,26 +1,28 @@ -FROM python:3.7.7-slim-stretch as builder +FROM python:3.8-slim-buster -# this will be user root regardless whether home/beakerx is not -COPY . /tmp/pypfopt +WORKDIR pypfopt +COPY pyproject.toml poetry.lock ./ RUN buildDeps='gcc g++' && \ apt-get update && apt-get install -y $buildDeps --no-install-recommends && \ - pip install --no-cache-dir -r /tmp/pypfopt/requirements.txt && \ - # One could install the pypfopt library directly in the image. We don't and share via docker-compose instead. - # pip install --no-cache-dir /tmp/pyhrp && \ - rm -r /tmp/pypfopt && \ + pip install --upgrade pip==21.0.1 && \ + pip install "poetry==1.1.4" && \ + poetry install -E optionals --no-root && \ apt-get purge -y --auto-remove $buildDeps - -# ---------------------------------------------------------------------------------------------------------------------- -FROM builder as test - -# COPY tools needed for testing into the image -RUN pip install --no-cache-dir pytest pytest-cov pytest-html - -# COPY the tests over -COPY tests /pypfopt/tests - -WORKDIR /pypfopt - -CMD py.test --cov=pypfopt --cov-report html:artifacts/html-coverage --cov-report term --html=artifacts/html-report/report.html tests +COPY . . + +# Usage examples: +# +# Build +# docker build . -t pypfopt +# +# Run +# iPython interpreter: +# docker run -it pypfopt poetry run ipython +# Jupyter notebook server: +# docker run -it -p 8888:8888 pypfopt poetry run jupyter notebook --allow-root --no-browser --ip 0.0.0.0 +# Pytest +# docker run -t pypfopt poetry run pytest +# Bash +# docker run -it pypfopt bash diff --git a/binder/Dockerfile b/binder/Dockerfile deleted file mode 100644 index 0fbf219d..00000000 --- a/binder/Dockerfile +++ /dev/null @@ -1,20 +0,0 @@ -FROM jupyter/base-notebook:python-3.7.6 as jupyter - -# File Author / Maintainer -# MAINTAINER Thomas Schmelzer "thomas.schmelzer@gmail.com" - -# copy the config file -COPY ./binder/jupyter_notebook_config.py /etc/jupyter/jupyter_notebook_config.py - -# copy the package over and install it -COPY --chown=jovyan:users . /tmp/pyportfolioopt - -RUN conda install -y -c conda-forge --file /tmp/pyportfolioopt/requirements.txt && \ - conda clean -y --all && \ - pip install --no-cache-dir /tmp/pyportfolioopt && \ - pip install yfinance && \ - pip install lxml && \ - rm -rf /tmp/pyportfolioopt - -# hardcoded parameters!? see https://github.com/moby/moby/issues/35018 -COPY --chown=jovyan:users ./cookbook $HOME/work diff --git a/binder/jupyter_notebook_config.py b/binder/jupyter_notebook_config.py deleted file mode 100644 index ef619faa..00000000 --- a/binder/jupyter_notebook_config.py +++ /dev/null @@ -1,7 +0,0 @@ -c = get_config() -c.NotebookApp.ip = '0.0.0.0' -c.NotebookApp.port = 8888 -c.NotebookApp.open_browser = False -c.NotebookApp.token = '' -c.NotebookApp.password = '' -c.NotebookApp.notebook_dir = "/home/jovyan/work" \ No newline at end of file diff --git a/docker-compose.test.yml b/docker-compose.test.yml deleted file mode 100755 index e44a5448..00000000 --- a/docker-compose.test.yml +++ /dev/null @@ -1,12 +0,0 @@ -version: '3.6' -services: - sut: - build: - context: . - dockerfile: Dockerfile - target: test - - volumes: - - ./artifacts:/artifacts - - ./tests:/pypfopt/tests - - ./pypfopt:/pypfopt/pypfopt:ro diff --git a/docker-compose.yml b/docker-compose.yml deleted file mode 100644 index 5afa6d4b..00000000 --- a/docker-compose.yml +++ /dev/null @@ -1,16 +0,0 @@ -version: '3.6' -services: - pypfopt: - build: - context: . - dockerfile: Dockerfile - target: builder - - jupyter: - build: - context: . - dockerfile: ./binder/Dockerfile - volumes: - - ./cookbook:${WORK} - ports: - - ${PORT}:8888 \ No newline at end of file