minimal setup
parent
babfc17f40
commit
7ffd1b0d0f
|
@ -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
|
|
@ -11,6 +11,15 @@ DEV/
|
|||
.pytest_cache/
|
||||
.vscode/
|
||||
|
||||
# Environments
|
||||
.env
|
||||
.venv
|
||||
env/
|
||||
venv/
|
||||
ENV/
|
||||
env.bak/
|
||||
venv.bak/
|
||||
|
||||
pip-selfcheck.json
|
||||
|
||||
html-coverage
|
||||
|
|
40
Dockerfile
40
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
|
||||
|
||||
COPY . .
|
||||
|
||||
# ----------------------------------------------------------------------------------------------------------------------
|
||||
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
|
||||
# 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
|
||||
|
|
|
@ -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
|
|
@ -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"
|
|
@ -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
|
|
@ -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
|
Loading…
Reference in New Issue