From fde59422a03d2001edc894b347d3947e52c9dc53 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Dutheillet-Lamonth=C3=A9zie?= Date: Thu, 18 Jul 2024 19:27:45 +0200 Subject: [PATCH] #32: make configurable docker image push action --- .../workflows/pushbasedockerimage-config.yml | 47 +++++++++++++ ...k9.2.2.dockerfile => make-base.dockerfile} | 69 ++++++++++--------- 2 files changed, 85 insertions(+), 31 deletions(-) create mode 100644 .github/workflows/pushbasedockerimage-config.yml rename ci/docker/{ubuntu22.04-gcc11-vtk9.2.2.dockerfile => make-base.dockerfile} (70%) diff --git a/.github/workflows/pushbasedockerimage-config.yml b/.github/workflows/pushbasedockerimage-config.yml new file mode 100644 index 0000000000..4ac610264b --- /dev/null +++ b/.github/workflows/pushbasedockerimage-config.yml @@ -0,0 +1,47 @@ +name: Build dependencies and push base Docker Image to dockerhub (configure) + +on: + workflow_dispatch: + inputs: + BASE_IMAGE: + default: "ubuntu:22.04" + CC: + default: gcc-11 + CXX: + default: g++-11 + PYTHON: + description: The python version to use in the inner 'deves' conda environment + default: "3.8" + VTK_TAG: + description: The VTK tag to build + default: "v9.2.2" + IMAGE_NAME: + description: The docker image name + default: "ubuntu22.04-gcc11-vtk9.2.2" + IMAGE_TAG: + description: The docker image tag + default: latest + +jobs: + push_to_registry: + name: Push Docker image to Docker Hub + runs-on: ubuntu-latest + steps: + - name: Check out the repo + uses: actions/checkout@v4 + + - name: Log in to Docker Hub + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Build and push Docker image + uses: docker/build-push-action@v6 + with: + context: . + build-args: BASE=${{ inputs.BASE_IMAGE }},VTK_TAG=${{ inputs.VTK_TAG }} + file: ci/docker/make-base.dockerfile + push: true + tags: pierrpebay/${{ inputs.IMAGE_NAME }}:${{ inputs.IMAGE_TAG }} + diff --git a/ci/docker/ubuntu22.04-gcc11-vtk9.2.2.dockerfile b/ci/docker/make-base.dockerfile similarity index 70% rename from ci/docker/ubuntu22.04-gcc11-vtk9.2.2.dockerfile rename to ci/docker/make-base.dockerfile index 5c9764f238..065cae950a 100644 --- a/ci/docker/ubuntu22.04-gcc11-vtk9.2.2.dockerfile +++ b/ci/docker/make-base.dockerfile @@ -1,11 +1,14 @@ -ARG BASE=ubuntu:22.04 +# A common base docker file that can be built with some configurations + +# Arguments +ARG BASE_IMAGE=ubuntu:22.04 ARG CC=gcc-11 ARG CXX=g++-11 ARG VTK_TAG=v9.2.2 ARG PYTHON=3.8 # Base image & requirements -FROM ${BASE} AS base +FROM ${BASE_IMAGE} AS base ARG CC CXX VTK_TAG VTK_DIR PYTHON @@ -98,33 +101,37 @@ RUN cmake --build ${VTK_DIR} -j$(nproc) RUN echo "Base creation success" +# WIP Tests to be removed: + # Build -FROM base AS build - -COPY . /opt/src/vt-tv -RUN mkdir -p /opt/build/vt-tv - -RUN chmod +x /opt/src/vt-tv/build.sh -RUN CMAKE_BINARY_DIR=/opt/build/vt-tv \ - VTK_DIR=${VTK_DIR} \ - VT_TV_TESTS_ENABLED=ON \ - VT_TV_COVERAGE_ENABLED=ON \ - /opt/src/vt-tv/build.sh - -RUN echo "VT-TV build success" - -# Unit tests -FROM build AS test -RUN ["chmod", "+x", "/opt/src/vt-tv/ci/test.sh"] -RUN ["/bin/sh", "/opt/src/vt-tv/ci/test.sh"] -RUN bash /opt/src/vt-tv/ci/docker/test.sh - -# Bindings tests -FROM build AS test-bindings -RUN ["chmod", "+x", "/opt/src/vt-tv/ci/test-bindings.sh"] -RUN ["/bin/sh", "/opt/src/vt-tv/ci/test-bindings.sh"] - -# Artifacts -FROM scratch AS artifacts -COPY --from=test /tmp/artifacts /tmp/artifacts -COPY --from=test-bindings /tmp/artifacts /tmp/artifacts +# FROM base AS build + +# COPY . /opt/src/vt-tv +# RUN mkdir -p /opt/build/vt-tv + +# RUN chmod +x /opt/src/vt-tv/build.sh +# RUN CMAKE_BINARY_DIR=/opt/build/vt-tv \ +# VTK_DIR=${VTK_DIR} \ +# VT_TV_TESTS_ENABLED=ON \ +# VT_TV_COVERAGE_ENABLED=ON \ +# /opt/src/vt-tv/build.sh + +# RUN echo "VT-TV build success" + +# # WIP: Test part + +# # Unit tests +# FROM build AS test +# RUN ["chmod", "+x", "/opt/src/vt-tv/ci/test.sh"] +# RUN ["/bin/sh", "/opt/src/vt-tv/ci/test.sh"] +# RUN bash /opt/src/vt-tv/ci/docker/test.sh + +# # Bindings tests +# FROM build AS test-bindings +# RUN ["chmod", "+x", "/opt/src/vt-tv/ci/test-bindings.sh"] +# RUN ["/bin/sh", "/opt/src/vt-tv/ci/test-bindings.sh"] + +# # Artifacts +# FROM scratch AS artifacts +# COPY --from=test /tmp/artifacts /tmp/artifacts +# COPY --from=test-bindings /tmp/artifacts /tmp/artifacts