Skip to content

Commit

Permalink
Merge pull request #144 from gerlero/dockerfile
Browse files Browse the repository at this point in the history
Update Dockerfile
  • Loading branch information
gerlero authored Aug 17, 2024
2 parents 83abfc0 + f58bedf commit 62ed895
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 40 deletions.
21 changes: 11 additions & 10 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,20 +40,21 @@ jobs:
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Docker meta (default)
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.IMAGES }}
tags: |
type=raw,value=latest,enable={{is_default_branch}}
flavor: latest=false
- name: Docker meta (run)
id: meta_run
- name: Docker meta (slim)
id: meta_slim
uses: docker/metadata-action@v5
with:
images: ${{ env.IMAGES }}
tags: |
type=raw,value=slim,enable={{is_default_branch}}
type=raw,value=run,enable={{is_default_branch}}
flavor: latest=false
- name: Login to GitHub Container Registry
Expand All @@ -70,7 +71,7 @@ jobs:
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push (default)
- name: Build and push
uses: docker/build-push-action@v6
with:
platforms: ${{ env.PLATFORMS }}
Expand All @@ -80,13 +81,13 @@ jobs:
type=registry,ref=ghcr.io/${{ steps.lowercase.outputs.repository }}:buildcache-amd64
type=registry,ref=ghcr.io/${{ steps.lowercase.outputs.repository }}:buildcache-arm64
push: ${{ env.PUSH }}
- name: Build and push (run)
- name: Build and push (slim)
uses: docker/build-push-action@v6
with:
platforms: ${{ env.PLATFORMS }}
tags: ${{ steps.meta_run.outputs.tags }}
labels: ${{ steps.meta_run.outputs.labels }}
target: run
tags: ${{ steps.meta_slim.outputs.tags }}
labels: ${{ steps.meta_slim.outputs.labels }}
target: slim
cache-from: |
type=registry,ref=ghcr.io/${{ steps.lowercase.outputs.repository }}:buildcache-amd64
type=registry,ref=ghcr.io/${{ steps.lowercase.outputs.repository }}:buildcache-arm64
Expand All @@ -96,7 +97,7 @@ jobs:
uses: docker/build-push-action@v6
with:
platforms: linux/amd64
target: run
target: slim
cache-from: |
type=registry,ref=ghcr.io/${{ steps.lowercase.outputs.repository }}:buildcache-amd64
type=registry,ref=ghcr.io/${{ steps.lowercase.outputs.repository }}:buildcache-arm64
Expand All @@ -107,7 +108,7 @@ jobs:
uses: docker/build-push-action@v6
with:
platforms: linux/arm64
target: run
target: slim
cache-from: |
type=registry,ref=ghcr.io/${{ steps.lowercase.outputs.repository }}:buildcache-amd64
type=registry,ref=ghcr.io/${{ steps.lowercase.outputs.repository }}:buildcache-arm64
Expand Down
37 changes: 9 additions & 28 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
ARG FOAM_VERSION=2406
ARG OPENFOAM_VERSION=2406

FROM opencfd/openfoam-dev:${FOAM_VERSION} as dev
FROM microfluidica/openfoam:${OPENFOAM_VERSION} AS dev

ARG FOAM_VERSION

ARG PMT_DIR=/usr/local/porousMicroTransport
ARG PMT_DIR=/usr/local/src/porousMicroTransport

ENV PMT_SRC=${PMT_DIR}/libraries
ENV PMT_SOLVERS=${PMT_DIR}/solvers
Expand All @@ -14,39 +12,22 @@ COPY libraries ${PMT_SRC}
COPY solvers ${PMT_SOLVERS}
COPY Allwmake Allwclean LICENSE ${PMT_DIR}/

RUN . /openfoam/profile.rc \
# build and install for all users
&& ${PMT_DIR}/Allwmake -j -prefix=group \
# build and install for all users
RUN ${PMT_DIR}/Allwmake -j -prefix=group \
# clean up
&& ${PMT_DIR}/Allwclean \
# smoke test
&& moistureDiffusivityTransportFoam -help

ARG PMT_URL=https://github.com/gerlero/porousMicroTransport

COPY <<EOF /openfoam/assets/welcome.sh
echo "---------------------------------------------------------------------------"
echo " porousMicroTransport"
echo "---------------------------------------------------------------------------"
echo "Homepage: ${PMT_URL}"
echo "OpenFOAM: v${FOAM_VERSION} (www.openfoam.com)"
[ ! -e "${PMT_DIR}" ] || echo "Source code: ${PMT_DIR}"
[ ! -e "\${PMT_TUTORIALS}" ] || echo "Tutorials: \${PMT_TUTORIALS}"
echo "---------------------------------------------------------------------------"
EOF


FROM opencfd/openfoam-run:${FOAM_VERSION} as run
FROM microfluidica/openfoam:${OPENFOAM_VERSION}-slim AS slim

ARG FOAM_VERSION
ARG OPENFOAM_VERSION

COPY --from=dev /usr/lib/openfoam/openfoam${FOAM_VERSION}/site/ /usr/lib/openfoam/openfoam${FOAM_VERSION}/site/

COPY --from=dev /openfoam/assets/welcome.sh /openfoam/assets/welcome.sh
COPY --from=dev /usr/lib/openfoam/openfoam${OPENFOAM_VERSION}/site/ /usr/lib/openfoam/openfoam${OPENFOAM_VERSION}/site/

# smoke test
RUN . /openfoam/profile.rc \
&& moistureDiffusivityTransportFoam -help
RUN moistureDiffusivityTransportFoam -help


FROM dev
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ tests/Alltest

### Docker image

Alternatively, **porousMicroTransport** is also [available in the form of Docker images](https://hub.docker.com/r/microfluidica/porousmicrotransport/). These images are based on the official OpenFOAM Docker images and include **porousMicroTransport** precompiled and ready to use. Assuming [Docker](https://www.docker.com) is installed, you can run the latest image of **porousMicroTransport** in a new container with:
Alternatively, **porousMicroTransport** is also [available in the form of Docker images](https://hub.docker.com/r/microfluidica/porousmicrotransport/). These images include **porousMicroTransport** precompiled and ready to use. Assuming [Docker](https://www.docker.com) is installed, you can run the latest image of **porousMicroTransport** in a new container with:

```sh
docker run -it microfluidica/porousmicrotransport
Expand All @@ -56,7 +56,7 @@ Or, if you use OpenFOAM's [`openfoam-docker` script](https://develop.openfoam.co
openfoam-docker -image=microfluidica/porousmicrotransport
```

A slimmer image variant that does not include source code, development tools or tutorial cases is available as `microfluidica/porousmicrotransport:run`.
A slimmer image variant that does not include source code, development tools or tutorial cases is available as `microfluidica/porousmicrotransport:slim` (`run` is a deprecated alias for `slim`).

Docker images can also be used with other compatible containerization software, such as Podman and Singularity/Apptainer.

Expand Down

0 comments on commit 62ed895

Please sign in to comment.