Skip to content

Commit 8d83e45

Browse files
authored
Enhance Docker image build workflow
Updated the GitHub Actions workflow to include DockerHub login, setup Buildx, and build & push Docker image with caching.
1 parent 50d1764 commit 8d83e45

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed

.github/workflows/docker-image.yml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: Docker Image CI
2+
3+
on:
4+
push:
5+
branches: [ "master" ]
6+
pull_request:
7+
branches: [ "master" ]
8+
9+
jobs:
10+
build:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
# Step 1 — Checkout code
15+
- name: Checkout Repository
16+
uses: actions/checkout@v4
17+
18+
# Step 2 — Login to DockerHub
19+
- name: Login to DockerHub
20+
uses: docker/login-action@v3
21+
with:
22+
username: ${{ secrets.DOCKERHUB_USERNAME }}
23+
password: ${{ secrets.DOCKERHUB_TOKEN }}
24+
25+
# Step 3 — Setup Buildx (for caching + multi-platform)
26+
- name: Set up Docker Buildx
27+
uses: docker/setup-buildx-action@v3
28+
29+
# Step 4 — Build and Push
30+
- name: Build & Push Docker Image
31+
uses: docker/build-push-action@v6
32+
with:
33+
context: .
34+
file: ./Dockerfile
35+
push: true
36+
platforms: linux/amd64
37+
tags: |
38+
${{ secrets.DOCKERHUB_USERNAME }}/streamvision:latest
39+
${{ secrets.DOCKERHUB_USERNAME }}/streamvision:${{ github.run_number }}
40+
cache-from: type=gha
41+
cache-to: type=gha,mode=max
42+
43+
# (Optional) Step 5 — Output final image tag
44+
- name: Show Image Tag
45+
run: echo "Pushed version: ${{ secrets.DOCKERHUB_USERNAME }}/streamvision:${{ github.run_number }}"

0 commit comments

Comments
 (0)