From 82f674dee204d74a2462c3eec830fa1a841e41cb Mon Sep 17 00:00:00 2001 From: Mohamadamin Karami Date: Wed, 20 Nov 2024 01:31:20 +0330 Subject: [PATCH] Add Github workflow actions to build and push docker images (#3) (#5) (#4) Co-authored-by: Mohamadamin Karami --- .github/workflows/release.yml | 118 ++++++++++++++++++++++++++++++++++ 1 file changed, 118 insertions(+) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..ea9c765 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,118 @@ +name: Docker Build, Push Images + +on: + release: + types: [published] +env: + RELEASE: ${{ github.event.release.tag_name || 'latest' }} + +jobs: + build-base-images: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v3 + with: + submodules: true + + - name: Log in to Docker Hub + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + + - name: Build and tag dish pash base image + run: | + cd docker-hadoop + + docker build -t ${{ secrets.DOCKERHUB_USERNAME }}/dish-pash-base:${{ env.RELEASE }} ./pash-base \ + --build-arg RELEASE=${{ env.RELEASE }} + + # Tag the image with 'latest' + docker tag ${{ secrets.DOCKERHUB_USERNAME }}/dish-pash-base:${{ env.RELEASE }} \ + ${{ secrets.DOCKERHUB_USERNAME }}/dish-pash-base:latest + + - name: Push dish pash base image + run: | + docker push ${{ secrets.DOCKERHUB_USERNAME }}/dish-pash-base:${{ env.RELEASE }} + docker push ${{ secrets.DOCKERHUB_USERNAME }}/dish-pash-base:latest + + - name: Build and tag hadoop pash base image + run: | + cd docker-hadoop + + docker build -t ${{ secrets.DOCKERHUB_USERNAME }}/hadoop-pash-base:${{ env.RELEASE }} ./base \ + --build-arg RELEASE=${{ env.RELEASE }} --build-arg BASE=${{ secrets.DOCKERHUB_USERNAME }}/dish-pash-base + + # Tag the image with 'latest' + docker tag ${{ secrets.DOCKERHUB_USERNAME }}/hadoop-pash-base:${{ env.RELEASE }} \ + ${{ secrets.DOCKERHUB_USERNAME }}/hadoop-pash-base:latest + + - name: Push hadoop pash base image + run: | + docker push ${{ secrets.DOCKERHUB_USERNAME }}/hadoop-pash-base:${{ env.RELEASE }} + docker push ${{ secrets.DOCKERHUB_USERNAME }}/hadoop-pash-base:latest + + build-dependant-images: + runs-on: ubuntu-latest + needs: build-base-images + + strategy: + matrix: + image: + - name: hadoop-namenode + path: ./namenode + base_image: hadoop-pash-base + + - name: hadoop-datanode + path: ./datanode + base_image: hadoop-pash-base + + - name: hadoop-resourcemanager + path: ./resourcemanager + base_image: hadoop-pash-base + + - name: hadoop-nodemanager + path: ./nodemanager + base_image: hadoop-pash-base + + - name: hadoop-historyserver + path: ./historyserver + base_image: hadoop-pash-base + + - name: hadoop-submit + path: ./submit + base_image: hadoop-pash-base + + steps: + - name: Checkout code + uses: actions/checkout@v3 + with: + submodules: true + + - name: Log in to Docker Hub + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + + - name: Build and tag Docker image + run: | + cd docker-hadoop + + # Build Image + docker build -t ${{ secrets.DOCKERHUB_USERNAME }}/${{ matrix.image.name }}:${{ env.RELEASE }} ${{ matrix.image.path }} \ + --build-arg RELEASE=${{ env.RELEASE }} --build-arg BASE=${{ secrets.DOCKERHUB_USERNAME }}/${{ matrix.image.base_image }} + # Tag the image with 'latest' + docker tag ${{ secrets.DOCKERHUB_USERNAME }}/${{ matrix.image.name }}:${{ env.RELEASE }} ${{ secrets.DOCKERHUB_USERNAME }}/${{ matrix.image.name }}:latest + - name: Push Docker image + run: | + docker push ${{ secrets.DOCKERHUB_USERNAME }}/${{ matrix.image.name }}:${{ env.RELEASE }} + docker push ${{ secrets.DOCKERHUB_USERNAME }}/${{ matrix.image.name }}:latest