Skip to content

Commit

Permalink
Add Dockerfile
Browse files Browse the repository at this point in the history
  • Loading branch information
daurer committed Jul 15, 2024
1 parent 774ae64 commit 66946eb
Show file tree
Hide file tree
Showing 4 changed files with 111 additions and 2 deletions.
7 changes: 7 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/.*
build
doc
tutorial
extra
archive
*.md
58 changes: 58 additions & 0 deletions .github/workflows/containers.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: "Tests with Containers"

on:
push:
branches:
- master
pull_request:
branches:
- master
- dev
- hotfixes

jobs:
build-test:
runs-on: ubuntu-latest
strategy:
max-parallel: 10
fail-fast: true
matrix:
python-version: ['3.7','3.8','3.9','3.10']
platform: ['core', 'full'] # ['pycuda', 'cupy']
name: Testing ${{ matrix.platform }}/python=${{ matrix.python-version }}
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Build Image
uses: docker/build-push-action@v4
with:
context: .
tags: ptypy_${{ matrix.platform }}_py${{ matrix.python-version }}_dev:latest
load: true
cache-from: type=gha
cache-to: type=gha,mode=max
target: runtime
build-args: |
PYTHON_VERSION=${{ matrix.python-version }}
PLATFORM=${{ matrix.platform }}
- name: Run test inside container
run: docker run ptypy_${{ matrix.platform }}_py${{ matrix.python-version }}_dev:latest pytest

flake8-lint:
runs-on: ubuntu-latest
name: Lint
steps:
- name: Check out source repository
uses: actions/checkout@v3
- name: Set up Python environment
uses: actions/setup-python@v4
with:
python-version: "3.10"
- name: flake8 Lint
uses: py-actions/flake8@v2
with:
max-line-length: "120"
exclude: "./archive,./benchmark"
args: "--count --select=E9,F63,F7,F82 --show-source --statistics"
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ on:
pull_request:
branches:
- master
- dev
- hotfixes
# - dev
# - hotfixes
# Also trigger on page_build, as well as release created events
page_build:
release:
Expand Down
44 changes: 44 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Set global build arguments
ARG PLATFORM=cupy
n
# Pull from miniconda image and install core dependencies
FROM continuumio/miniconda3 as core

# Basic conda installation
COPY ./dependencies_core.yml ./dependencies.yml
RUN conda env update -n base -f dependencies.yml && conda install -y -n base pytest

# Pull from miniconda image and install full dependencies
FROM condaforge/mambaforge as full

ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update && apt-get install -y libxml2 ssh
COPY ./dependencies_full.yml ./dependencies.yml
RUN mamba env update -n base -f dependencies.yml && mamba install -y -n base pytest

# Pull mambaforge image and install accelerate/pycuda dependencies
FROM condaforge/mambaforge as pycuda

ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update && apt-get install -y libxml2 ssh
COPY ./ptypy/accelerate/cuda_pycuda/dependencies.yml ./dependencies.yml
COPY ./cufft/dependencies.yml ./dependencies_cufft.yml
RUN mamba env update -n base -f dependencies.yml && mamba env update -n base -f dependencies_cufft.yml

# Pull mambaforge image and install accelerate/cupy dependencies
FROM condaforge/mambaforge as cupy

ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update && apt-get install -y libxml2 ssh
COPY ./ptypy/accelerate/cuda_cupy/dependencies.yml ./dependencies.yml
COPY ./cufft/dependencies.yml ./dependencies_cufft.yml
RUN mamba env update -n base -f dependencies.yml && mamba env update -n base -f dependencies_cufft.yml

# Pull from existing image with ptypy dependencies and set up testing
FROM ${PLATFORM} as runtime
COPY ./ ./
RUN pip install .
RUN if [ "$PLATFORM" = "pycuda" ] || [ "$PLATFORM" = "cupy" ] ; then pip install ./cufft ; fi

# Run PtyPy CLI as entrypoint
ENTRYPOINT ["ptypy.cli"]

0 comments on commit 66946eb

Please sign in to comment.