Skip to content

Commit

Permalink
Add GitHub Actions workflow for building and pushing Docker images
Browse files Browse the repository at this point in the history
- Created a new workflow file 'build-and-push.yml' to automate the building and pushing of Docker images for API and Streamlit services.
- Configured triggers for pushes to version tags and releases.
- Included steps for logging into Docker Hub, setting up Docker Buildx, and building/pushing images with appropriate tags based on the commit SHA and branch name.
  • Loading branch information
mikhaelbenilouz committed Dec 1, 2024
1 parent ccabc36 commit a5d48cb
Showing 1 changed file with 49 additions and 0 deletions.
49 changes: 49 additions & 0 deletions .github/workflows/build-and-push.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Build and Push Docker Images

on:
push:
# branches:
# - master
tags:
- 'v*.*.*'
release:
types: [published]
workflow_dispatch:

jobs:
build-and-push:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- name: Login 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 push API image
uses: docker/build-push-action@v4
with:
context: .
file: ./app/Dockerfile.apipredict
push: true
tags: |
${{ secrets.DOCKERHUB_USERNAME }}/api-predict:latest
${{ secrets.DOCKERHUB_USERNAME }}/api-predict:${{ github.sha }}
${{ secrets.DOCKERHUB_USERNAME }}/api-predict:${{ github.ref_name }}
- name: Build and push Streamlit image
uses: docker/build-push-action@v4
with:
context: ./app
file: Dockerfile.streamlit
push: true
tags: |
${{ secrets.DOCKERHUB_USERNAME }}/streamlit:latest
${{ secrets.DOCKERHUB_USERNAME }}/streamlit:${{ github.sha }}
${{ secrets.DOCKERHUB_USERNAME }}/streamlit:${{ github.ref_name }}

0 comments on commit a5d48cb

Please sign in to comment.