Skip to content

Commit cfc7715

Browse files
authored
Split dockerfiles (#386)
* split up dockerfiles * push base image once * push once * only build base-image if file has changed * reduce number of build-threads * do not upload as asset anymore * remove base build from extpar build * build base image too * drop arm64 for regular pipelines * same for base image * remove wrong comment
1 parent 0a7f55d commit cfc7715

File tree

7 files changed

+124
-86
lines changed

7 files changed

+124
-86
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: Build Base image
2+
3+
on:
4+
push:
5+
paths:
6+
- '.github/workflows/build-base-container.yml'
7+
- 'Dockerfile.base'
8+
9+
jobs:
10+
build-base:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- name: Checkout repository
15+
uses: actions/checkout@v2
16+
with:
17+
submodules: true
18+
19+
- name: Set up Docker Buildx
20+
uses: docker/setup-buildx-action@v1
21+
22+
- name: Log in to Docker Hub
23+
uses: docker/login-action@v1
24+
with:
25+
username: c2sm
26+
password: ${{ secrets.DOCKER_PASSWORD }}
27+
28+
- name: Build base image
29+
uses: docker/build-push-action@v2
30+
with:
31+
context: .
32+
file: ./Dockerfile.base
33+
push: false
34+
tags: c2sm/extpar-base:latest
35+
platforms: linux/amd64

.github/workflows/build-container.yml

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,18 +21,11 @@ jobs:
2121
username: c2sm
2222
password: ${{ secrets.DOCKER_PASSWORD }}
2323

24-
- name: Build Docker image
24+
- name: Build extpar image
2525
uses: docker/build-push-action@v2
2626
with:
2727
context: .
28-
file: ./Dockerfile
28+
file: ./Dockerfile.extpar
2929
push: false
3030
tags: c2sm/extpar:latest
31-
outputs: type=oci,dest=extpar_image.tar
32-
platforms: linux/amd64,linux/arm64
33-
34-
- name: Upload Docker image as artifact
35-
uses: actions/upload-artifact@v4
36-
with:
37-
name: extpar_image.tar
38-
path: extpar_image.tar
31+
platforms: linux/amd64

.github/workflows/deploy-container-as-release-asset.yml renamed to .github/workflows/upload_to_dockerhub.yml

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
name: Build Docker Image and Upload as Release Asset
1+
name: Build Base and Extpar images and upload to Docker Hub
22

33
on:
44
push:
55
tags:
66
- '*'
77

88
jobs:
9-
build_and_release:
9+
build_and_upload:
1010
runs-on: ubuntu-latest
1111

1212
steps:
@@ -24,14 +24,20 @@ jobs:
2424
username: c2sm
2525
password: ${{ secrets.DOCKER_PASSWORD }}
2626

27-
- name: Build and Save Docker image
28-
id: build_docker_image
27+
- name: Build base image
2928
uses: docker/build-push-action@v2
3029
with:
3130
context: .
32-
file: ./Dockerfile
31+
file: ./Dockerfile.base
32+
push: true
33+
tags: c2sm/extpar-base:latest
34+
platforms: linux/amd64,linux/arm64
35+
36+
- name: Build extpar image
37+
uses: docker/build-push-action@v2
38+
with:
39+
context: .
40+
file: ./Dockerfile.extpar
3341
push: true
3442
tags: c2sm/extpar:${{ github.ref_name }}
3543
platforms: linux/amd64,linux/arm64
36-
asset_name: extpar_image.tar
37-
asset_content_type: application/x-tar

Dockerfile

Lines changed: 0 additions & 68 deletions
This file was deleted.

Dockerfile.base

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Use the latest Debian image
2+
FROM debian:bookworm-slim
3+
4+
# Set environment variables to avoid interactive prompts during package installation
5+
ENV DEBIAN_FRONTEND=noninteractive
6+
7+
# Needed for testsuite to pick correct path to input-data
8+
ENV HOSTNAME=docker
9+
10+
# Update the package list and install required packages
11+
RUN apt-get update && \
12+
apt-get install -y \
13+
git \
14+
vim \
15+
gcc \
16+
gfortran \
17+
libnetcdf-dev \
18+
libnetcdff-dev \
19+
libsz2 \
20+
libomp-dev \
21+
python3 \
22+
python3-pip \
23+
python3-venv \
24+
bc \
25+
cdo \
26+
wget \
27+
&& apt-get clean
28+
29+
# Verify installations
30+
RUN gcc --version && \
31+
gfortran --version && \
32+
git --version && \
33+
vim --version && \
34+
nc-config --version && \
35+
nf-config --version
36+
37+
CMD ["/bin/bash"]

Dockerfile.extpar

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
FROM c2sm/extpar-base:latest
2+
3+
# set pipefail for make command
4+
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
5+
6+
# Set the working directory
7+
WORKDIR /workspace
8+
9+
# Copy the configuration script into the container
10+
COPY . /workspace/
11+
12+
# Run the configuration script
13+
RUN /workspace/configure.docker.gcc
14+
15+
# Build extpar
16+
RUN cd /workspace && make -j 2 2>&1 | tee -a compile.log
17+
18+
# Create a virtual environment and install the package
19+
RUN python3 -m venv /workspace/venv && \
20+
. /workspace/venv/bin/activate && \
21+
cd /workspace && \
22+
pip install -r requirements.txt && \
23+
pip install setuptools && \
24+
python3 setup.py sdist && \
25+
pip install dist/extpar-*.tar.gz
26+
27+
# Add the virtual environment to the PATH
28+
ENV PATH="/workspace/venv/bin:$PATH"
29+
30+
# Set the working directory
31+
WORKDIR /workspace/python
32+
33+
# Default command
34+
CMD ["/bin/bash"]

test/jenkins/build.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ case "$(hostname)" in
3333

3434
# container build run at CO2
3535
*co2*)
36-
run_command podman build -t extpar:$ghprbPullId -f Dockerfile .
36+
run_command podman build -t extpar-base:latest -f Dockerfile.base .
37+
run_command podman build -t extpar:$ghprbPullId -f Dockerfile.extpar .
3738
;;
3839
esac

0 commit comments

Comments
 (0)