Skip to content

Commit

Permalink
Merge pull request #130 from gerlero/dockerfile
Browse files Browse the repository at this point in the history
Update Dockerfile
  • Loading branch information
gerlero authored Jul 25, 2024
2 parents f5990a2 + 8cc876d commit 9bf627c
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 57 deletions.
57 changes: 14 additions & 43 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,20 @@ jobs:
cache-to: type=gha,mode=max
push: ${{ github.event_name == 'push' }}

com:
openfoam:
runs-on: ubuntu-latest
strategy:
matrix:
openfoam-version: [2306, 2312]
include:
- openfoam-distro: openfoam-com
openfoam-version: 2406
- openfoam-distro: openfoam-com
openfoam-version: 2312
- openfoam-distro: openfoam-org
openfoam-version: 12
- openfoam-distro: openfoam-org
openfoam-version: 11
fail-fast: false
steps:
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
Expand Down Expand Up @@ -89,44 +98,6 @@ jobs:
cache-from: type=gha
cache-to: type=gha,mode=max
push: ${{ github.event_name == 'push' }}
target: openfoam
build-args: BASE=opencfd/openfoam-default:${{ matrix.openfoam-version }}

org:
runs-on: ubuntu-latest
strategy:
matrix:
openfoam-version: [10, 11]
steps:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.IMAGES }}
tags: |
type=ref,event=branch,suffix=-openfoam${{ matrix.openfoam-version }}
type=ref,event=pr,suffix=-openfoam${{ matrix.openfoam-version }}
type=pep440,pattern=openfoam${{ matrix.openfoam-version }}
type=pep440,pattern={{version}}-openfoam${{ matrix.openfoam-version }}
type=pep440,pattern={{major}}.{{minor}}-openfoam${{ matrix.openfoam-version }}
type=pep440,pattern={{major}}-openfoam${{ matrix.openfoam-version }},enable=${{ !startsWith(github.ref, 'refs/tags/v0.') }}
flavor: latest=false
- name: Login to DockerHub
if: vars.DOCKERHUB_REPOSITORY
continue-on-error: ${{ github.event_name == 'pull_request' }}
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v6
with:
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
push: ${{ github.event_name == 'push' }}
target: openfoam
build-args: BASE=openfoam/openfoam${{ matrix.openfoam-version }}-graphical-apps
build-args: |
BASE=${{ matrix.openfoam-distro }}
OPENFOAM_VERSION=${{ matrix.openfoam-version }}
34 changes: 20 additions & 14 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,31 +1,37 @@

ARG BASE=opencfd/openfoam-default:2312
FROM ${BASE} as openfoam
ARG BASE=python:3.12-slim

USER root
ARG OPENFOAM_VERSION=2406
FROM opencfd/openfoam-default:${OPENFOAM_VERSION} AS openfoam-com

RUN apt-get update \
&& DEBIAN_FRONTEND=noninteractive apt-get -y install --no-install-recommends \
python3-pip \
&& rm -rf /var/lib/apt/lists/* \
&& pip install --no-cache-dir --upgrade pip
&& (python3 -m pip install --upgrade --no-cache-dir pip || true) \
&& rm -rf /var/lib/apt/lists/*

COPY . /src/

RUN pip install --no-cache-dir /src \
&& rm -rf /src \
# smoke test
&& python3 -c 'import foamlib'
ARG OPENFOAM_VERSION=12
FROM ubuntu:24.04 AS openfoam-org

ENTRYPOINT []
CMD ["python3"]
RUN apt-get update \
&& DEBIAN_FRONTEND=noninteractive apt-get -y install --no-install-recommends \
wget \
software-properties-common \
&& sh -c "wget -O - https://dl.openfoam.org/gpg.key > /etc/apt/trusted.gpg.d/openfoam.asc" \
&& add-apt-repository http://dl.openfoam.org/ubuntu \
&& apt-get update \
&& DEBIAN_FRONTEND=noninteractive apt-get -y install --no-install-recommends \
python3-pip \
openfoam${OPENFOAM_VERSION} \
&& rm -rf /var/lib/apt/lists/*


FROM python:3.12-slim
FROM ${BASE}

COPY . /src/

RUN pip install --no-cache-dir /src \
RUN python3 -m pip install --no-cache-dir --break-system-packages /src || python3 -m pip install --no-cache-dir /src \
&& rm -rf /src \
# smoke test
&& python3 -c 'import foamlib'
Expand Down

0 comments on commit 9bf627c

Please sign in to comment.