@@ -21,27 +21,35 @@ jobs:
2121 - name : Run backend tests
2222 run : cd course-matrix/backend && npm install && npm run test
2323
24+ # Step 2: Set up Docker Buildx (optional for multi-platform support)
25+ - name : Set up Docker Buildx
26+ uses : docker/setup-buildx-action@v2
27+
2428 - name : Log in to Docker Hub
2529 uses : docker/login-action@v3
2630 with :
2731 username : ${{ secrets.DOCKERHUB_USERNAME }}
2832 password : ${{ secrets.DOCKERHUB_TOKEN }}
2933
3034 # Build and push frontend Docker image
31- - name : Build and push frontend Docker image
35+ - name : Build Docker Image
3236 run : |
33- docker build -t ${{ secrets.DOCKERHUB_USERNAME }}/frontend:${{ github.sha }} ./frontend
34- docker tag ${{ secrets.DOCKERHUB_USERNAME }}/frontend:${{ github.sha }} ${{ secrets.DOCKERHUB_USERNAME }}/frontend:latest
35- docker push ${{ secrets.DOCKERHUB_USERNAME }}/frontend:${{ github.sha }}
36- docker push ${{ secrets.DOCKERHUB_USERNAME }}/frontend:latest
37+ # Build the frontend image
38+ docker-compose -f docker-compose.yml build frontend
39+ docker tag frontend:latest course-matrix/frontend:latest # Tag frontend with the Docker Hub repository
40+
41+ # Build the backend image
42+ docker-compose -f docker-compose.yml build backend
43+ docker tag backend:latest course-matrix/backend:latest # Tag backend with the Docker Hub repository
3744
38- # Build and push backend Docker image
39- - name : Build and push backend Docker image
45+ # Step 5: Push Docker images to Docker Hub
46+ - name : Push Docker images to Docker Hub
4047 run : |
41- docker build -t ${{ secrets.DOCKERHUB_USERNAME }}/backend:${{ github.sha }} ./backend
42- docker tag ${{ secrets.DOCKERHUB_USERNAME }}/backend:${{ github.sha }} mydockerhubuser/backend:latest
43- docker push ${{ secrets.DOCKERHUB_USERNAME }}/backend:${{ github.sha }}
44- docker push ${{ secrets.DOCKERHUB_USERNAME }}/backend:latest
48+ # Push the frontend image
49+ docker push course-matrix/frontend:latest
50+
51+ # Push the backend image
52+ docker push course-matrix/backend:latest
4553
4654 deploy :
4755 needs : test
0 commit comments