From 75ca9e6d9dc63a6b9aae86f63364e3dedab576fd Mon Sep 17 00:00:00 2001 From: Victor Payno Date: Fri, 29 Mar 2024 21:41:59 -0700 Subject: [PATCH] ci(docker-build): split data science layers to new image --- .github/docker/layer-35.00-tools-tailscale.sh | 24 +++++---- .github/workflows/docker-build.yml | 26 +++++---- Dockerfile | 54 +++++++++++++++++++ 3 files changed, 84 insertions(+), 20 deletions(-) diff --git a/.github/docker/layer-35.00-tools-tailscale.sh b/.github/docker/layer-35.00-tools-tailscale.sh index ffd10a75..4916c792 100755 --- a/.github/docker/layer-35.00-tools-tailscale.sh +++ b/.github/docker/layer-35.00-tools-tailscale.sh @@ -38,17 +38,23 @@ main() { time apt install -y "${PACKAGES[@]}" || track_errors printf "\n" - declare -a GO_PKGS - GO_PKGS=( - golang.zx2c4.com/wireguard@latest - ) + if command -v go >&/dev/null; then + declare -a GO_PKGS + GO_PKGS=( + golang.zx2c4.com/wireguard@latest + ) - declare url - for url in "${GO_PKGS[@]}"; do - echo Running: go install "${url}" - go install "${url}" || track_errors + declare url + for url in "${GO_PKGS[@]}"; do + echo Running: go install "${url}" + go install "${url}" || track_errors + printf "\n" + done + else + printf "\n" + printf "Go not found, skipping installation of extra packages.\n" printf "\n" - done + fi layer_end "${0}" "$@" diff --git a/.github/workflows/docker-build.yml b/.github/workflows/docker-build.yml index 09064d35..bd71dff1 100644 --- a/.github/workflows/docker-build.yml +++ b/.github/workflows/docker-build.yml @@ -20,9 +20,6 @@ on: # yamllint disable-line rule:truthy workflow_dispatch: pull_request: -env: - IMAGE_NAME: ci-generic-debian - defaults: run: shell: bash @@ -103,43 +100,47 @@ jobs: strategy: matrix: os: ["ubuntu-latest"] + image: + - ci-generic-debian + - ci-anaconda-debian runs-on: "${{ matrix.os }}" needs: [stage1] if: needs.stage1.outputs.docs_changed == 'True' outputs: tag_date: ${{ steps.setup_image_info.outputs.tag_date }} steps: - - name: Setup Env [${{ matrix.os }}] + - name: Setup Env [${{ matrix.os }} - ${{ matrix.image }}] id: setup_image_info run: |- tag_date="$(date +%Y%m%d)" printf "%s=%s\n" "tag_date" "${tag_date}" >> "${GITHUB_OUTPUT}" - - name: Docker Build Checkout [${{ matrix.os }}] + - name: Docker Build Checkout [${{ matrix.os }} - ${{ matrix.image }}] uses: actions/checkout@v3 - - name: Login to Docker Hub [${{ matrix.os }}] + - name: Login to Docker Hub [${{ matrix.os }} - ${{ matrix.image }}] uses: docker/login-action@v2 with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} - - name: Set up Docker Buildx [${{ matrix.os }}] + - name: Set up Docker Buildx [${{ matrix.os }} - ${{ matrix.image }}] uses: docker/setup-buildx-action@v2 - - name: Build and push [${{ matrix.os }}] + - name: Build and push [${{ matrix.os }} - ${{ matrix.image }}] uses: docker/build-push-action@v4 with: context: . file: ./Dockerfile push: true - tags: ${{ secrets.DOCKERHUB_USERNAME }}/${{ env.IMAGE_NAME }}:latest,${{ secrets.DOCKERHUB_USERNAME }}/${{ env.IMAGE_NAME }}:${{ steps.setup_image_info.outputs.tag_date }} + tags: ${{ secrets.DOCKERHUB_USERNAME }}/${{ matrix.image }}:latest,${{ secrets.DOCKERHUB_USERNAME }}/${{ matrix.image }}:${{ steps.setup_image_info.outputs.tag_date }} stage3: name: Docker Build Check env: ORG: ${{ secrets.DOCKERHUB_USERNAME }} - IMAGE_NAME: ci-generic-debian strategy: matrix: os: - vpayno/ci-generic-debian:latest - vpayno/ci-generic-debian:${{ needs.stage2.outputs.tag_date }} + - vpayno/ci-anaconda-debian:latest + - vpayno/ci-anaconda-debian:${{ needs.stage2.outputs.tag_date }} runs-on: ubuntu-latest container: ${{ matrix.os }} needs: [stage2] @@ -149,7 +150,10 @@ jobs: printf "%s\n" "Hello World!" - name: Docker Build Summary [${{ matrix.os }}] run: |- - ORG_IMAGE="${{ secrets.DOCKERHUB_USERNAME }}/${{ env.IMAGE_NAME }}" + IMAGE_NAME="${{ matrix.os }}" + IMAGE_NAME="${IMAGE_NAME##*/}" + IMAGE_NAME="${IMAGE_NAME%%:*}" + ORG_IMAGE="${{ secrets.DOCKERHUB_USERNAME }}/${IMAGE_NAME}" TOKEN="$(curl "https://auth.docker.io/token?service=registry.docker.io&scope=repository:${ORG_IMAGE}:pull" | jq -r .access_token)" { printf "Docker Hub Image Info\n" diff --git a/Dockerfile b/Dockerfile index 2fbdd598..e8e3b955 100644 --- a/Dockerfile +++ b/Dockerfile @@ -26,6 +26,30 @@ RUN bash .github/docker/layer-10.00-exercism-gcc_clang_llvm.sh ci-generic-debian RUN bash .github/docker/layer-14.00-exercism-tools.sh ci-generic-debian && : 20240101-000 +RUN bash .github/docker/layer-99.00-summary.sh ci-generic-debian && : 20231103-000 + +# Copies your code file from your action repository to the filesystem path `/` of the container +COPY .github/docker/entrypoint.sh /entrypoint.sh + +RUN rm -rvf /.github + +SHELL ["bash", "-c"] + +# app + args +# Executes `entrypoint.sh` when the Docker container starts up +ENTRYPOINT ["/entrypoint.sh"] + +# Extra args +CMD [] + +# ============================================================================= + +From ci-generic-base As ci-generic-debian + +COPY .github/docker /.github/docker + +COPY .github/citools/ /.github/citools/ + RUN bash .github/docker/layer-15.00-exercism-rust.sh ci-generic-debian && : 20231103-000 RUN bash .github/docker/layer-16.00-exercism-go.sh ci-generic-debian && : 20240111-000 @@ -36,6 +60,36 @@ RUN bash .github/docker/layer-18.00-exercism-python.sh ci-generic-debian && : 20 RUN bash .github/docker/layer-19.00-exercism-gleam.sh ci-generic-debian && : 20240322-000 +RUN bash .github/docker/layer-25.00-tools-vscode.sh ci-generic-debian && : 20240102-000 + +RUN bash .github/docker/layer-35.00-tools-tailscale.sh ci-generic-debian && : 20240111-000 + +RUN bash .github/docker/layer-99.00-summary.sh ci-generic-debian && : 20231103-000 + +# Copies your code file from your action repository to the filesystem path `/` of the container +COPY .github/docker/entrypoint.sh /entrypoint.sh + +RUN rm -rvf /.github + +SHELL ["bash", "-c"] + +# app + args +# Executes `entrypoint.sh` when the Docker container starts up +ENTRYPOINT ["/entrypoint.sh"] + +# Extra args +CMD [] + +# ============================================================================= + +From ci-generic-base As ci-anaconda-debian + +COPY .github/docker /.github/docker + +COPY .github/citools/ /.github/citools/ + +RUN bash .github/docker/layer-18.00-exercism-python.sh ci-generic-debian && : 20240322-000 + RUN bash .github/docker/layer-20.00-exercism-r.sh ci-generic-debian && : 20240328-000 RUN bash .github/docker/layer-25.00-tools-vscode.sh ci-generic-debian && : 20240102-000