Skip to content

Commit

Permalink
add dockerignore and simplify dockerfile, and test in CI (#136)
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinsung authored Apr 14, 2024
1 parent db71281 commit c019db1
Show file tree
Hide file tree
Showing 3 changed files with 181 additions and 8 deletions.
148 changes: 148 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
.git
.github
Dockerfile

# Below items are from .gitignore

# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
pip-wheel-metadata/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/
docs/api/generated/

# PyBuilder
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
.python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock

# PEP 582; used by e.g. github.com/David-OConnor/pyflow
__pypackages__/

# Celery stuff
celerybeat-schedule
celerybeat.pid

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/

# PyCharm
.idea/

# VS Code
.vscode/

# cibuildwheel
wheelhouse/

# asv
.asv/
26 changes: 26 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Docker notebook tests

on:
push:
branches: [ main ]
paths: ['Dockerfile', '.dockerignore', 'compose.yaml', '.github/workflows/docker.yml']
pull_request:
branches: [ main ]
paths: ['Dockerfile', '.dockerignore', 'compose.yaml', '.github/workflows/docker.yml']
schedule:
- cron: '0 20 * * 3'

jobs:
tests:
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@v4
- name: Build image
run: docker compose build
- name: Test notebooks
shell: bash
run: docker compose run notebook "bash" "-c" "pip install pytest nbmake && pytest --nbmake docs"
- name: Test that persistent-volume is writable
shell: bash
run: docker compose run notebook "bash" "-c" "touch persistent-volume/empty-notebook.ipynb"
15 changes: 7 additions & 8 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,17 @@ RUN apt update && apt install -y libssl-dev rustc cargo libopenblas-dev pkg-conf
USER ${NB_UID}

# Copy files
COPY docs docs/
RUN mkdir .src
COPY python .src/ffsim/python/
COPY src .src/ffsim/src/
COPY tests .src/ffsim/tests/
COPY Cargo.lock Cargo.toml LICENSE pyproject.toml README.md .src/ffsim/
COPY . .src/ffsim

# Fix file permissions
# Fix the permissions of ~/.src and ~/persistent-volume
USER root
RUN fix-permissions docs && fix-permissions .src && \
RUN fix-permissions .src && \
mkdir persistent-volume && fix-permissions persistent-volume
USER ${NB_UID}

# Consolidate the docs into the home directory
RUN mkdir docs && \
cp -a .src/ffsim/docs docs/ffsim

# Pip install ffsim
RUN pip install -e .src/ffsim

0 comments on commit c019db1

Please sign in to comment.