From 8cc876df5450044efa20fb467dcae56c818f4fcc Mon Sep 17 00:00:00 2001 From: Gabriel Gerlero Date: Sat, 13 Jul 2024 23:56:50 -0300 Subject: [PATCH] Update Dockerfile --- .github/workflows/docker.yml | 57 +++++++++--------------------------- Dockerfile | 34 ++++++++++++--------- 2 files changed, 34 insertions(+), 57 deletions(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 63a4a27..d2ca93f 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -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 @@ -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 }} diff --git a/Dockerfile b/Dockerfile index e5b3e53..c1085e3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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'