Skip to content

Commit

Permalink
Add Github workflow actions to build and push docker images (#3) (#5) (
Browse files Browse the repository at this point in the history
…#4)

Co-authored-by: Mohamadamin Karami <[email protected]>
  • Loading branch information
mohamadaminkarami and Mohamadamin Karami authored Nov 19, 2024
1 parent 3473140 commit 82f674d
Showing 1 changed file with 118 additions and 0 deletions.
118 changes: 118 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 82f674d

Please sign in to comment.