From 43dcb466b4aa4916fd52e4fcbba6bdf2b9e163d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marte=20Julie=20S=C3=A6tra?= Date: Tue, 14 Feb 2023 13:56:02 +0100 Subject: [PATCH] conda environment + dockerfile --- .github/workflows/build_docker.yml | 57 ++++++++++++++++++++++++++++++ docker/Dockerfile | 23 ++++++++++++ environment.yml | 7 ++++ 3 files changed, 87 insertions(+) create mode 100644 .github/workflows/build_docker.yml create mode 100644 docker/Dockerfile create mode 100644 environment.yml diff --git a/.github/workflows/build_docker.yml b/.github/workflows/build_docker.yml new file mode 100644 index 0000000..62c5400 --- /dev/null +++ b/.github/workflows/build_docker.yml @@ -0,0 +1,57 @@ +# This workflow uses actions that are not certified by GitHub. +# They are provided by a third-party and are governed by +# separate terms of service, privacy policy, and support +# documentation. + +name: Create and publish a Docker image + +on: + push: + branches: + - "!*" + tags: + - "v*" + +env: + REGISTRY: ghcr.io + IMAGE_NAME: ${{ github.repository }} + +jobs: + build-and-push-image: + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Set up QEMU + uses: docker/setup-qemu-action@v2 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + + - name: Log in to the Container registry + uses: docker/login-action@v2 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@v4 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + + - name: Build and push Docker image + uses: docker/build-push-action@v3 + with: + context: . + push: true + platforms: linux/amd64,linux/arm64 + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + file: docker/Dockerfile diff --git a/docker/Dockerfile b/docker/Dockerfile new file mode 100644 index 0000000..9df0595 --- /dev/null +++ b/docker/Dockerfile @@ -0,0 +1,23 @@ +FROM condaforge/mambaforge + +ENV DEBIAN_FRONTEND=noninteractive + +# Install ssh (missing dependency to run conda envs) +RUN apt-get update && \ + apt-get install -y ssh build-essential + +# Upgrade mamba +RUN mamba upgrade -y mamba + +# Copy environment and requirements files into docker env +COPY environment.yml . + +# Update environment file with new environment name +RUN mamba env update --file environment.yml --name dockerenv +SHELL ["mamba", "run", "-n", "dockerenv", "/bin/bash", "-c"] + +# Install package +COPY . ffian/ +RUN python3 -m pip install ./ffian + +RUN echo "source activate dockerenv" > ~/.bashrc diff --git a/environment.yml b/environment.yml new file mode 100644 index 0000000..0f517b1 --- /dev/null +++ b/environment.yml @@ -0,0 +1,7 @@ +name: test-env +channels: + - conda-forge +dependencies: + - fenics-dolfin + - numpy + - python=3.10