1+ name : Docker Production Build & Push
2+
3+ on :
4+ workflow_run :
5+ workflows : ["Dockerfiles Quality Check"]
6+ types :
7+ - completed
8+ branches : [main, master]
9+ workflow_dispatch :
10+
11+ concurrency :
12+ group : docker-prod-${{ github.ref }}
13+ cancel-in-progress : false
14+
15+ permissions :
16+ contents : read
17+
18+ jobs :
19+ build-and-push :
20+ name : Build and Push Production Image
21+ runs-on : self-hosted # ubuntu-latest
22+ if : ${{ github.event.workflow_run.conclusion == 'success' || github.event_name == 'workflow_dispatch' }}
23+
24+ steps :
25+ - name : Checkout
26+ uses : actions/checkout@v4
27+
28+ - name : Set up Docker Buildx
29+ uses : docker/setup-buildx-action@v3
30+
31+ - name : Log in to Docker Hub
32+ uses : docker/login-action@v3
33+ with :
34+ username : ${{ secrets.DOCKER_USERNAME }}
35+ password : ${{ secrets.DOCKER_PASSWORD }}
36+
37+ - name : Extract metadata
38+ id : meta
39+ uses : docker/metadata-action@v5
40+ with :
41+ images : ${{ secrets.DOCKER_USERNAME }}/thesis-app
42+ tags : |
43+ type=ref,event=branch
44+ type=ref,event=pr
45+ type=sha,prefix={{branch}}-
46+ type=raw,value=latest,enable={{is_default_branch}}
47+ labels : |
48+ org.opencontainers.image.title=Thesis Defense Scheduling System
49+ org.opencontainers.image.description=Complete application for thesis defense scheduling with PostgreSQL, Python API, and Nginx in single container
50+ org.opencontainers.image.vendor=WinterWollf
51+ org.opencontainers.image.source=https://github.com/WinterWollf/Engineering-thesis
52+
53+ - name : Build base images for production
54+ run : |
55+ echo "Building base images required for Dockerfile.prod..."
56+ docker build -f Dockerfile.api -t engineering-thesis-api:latest .
57+ docker build -f Dockerfile.nginx -t engineering-thesis-nginx:latest .
58+ echo "Base images built successfully"
59+
60+ - name : Build and push production image
61+ uses : docker/build-push-action@v6
62+ with :
63+ context : .
64+ file : Dockerfile.prod
65+ push : true
66+ tags : ${{ steps.meta.outputs.tags }}
67+ labels : ${{ steps.meta.outputs.labels }}
68+ platforms : linux/amd64,linux/arm64
69+ cache-from : type=gha,scope=prod
70+ cache-to : type=gha,mode=max,scope=prod
71+ provenance : false
72+ sbom : false
73+
74+ - name : Show pushed image info
75+ run : |
76+ echo "Successfully pushed image with tags:"
77+ echo "${{ steps.meta.outputs.tags }}"
78+ echo ""
79+ echo "Image labels:"
80+ echo "${{ steps.meta.outputs.labels }}"
81+ echo ""
82+ echo "Pull command for latest:"
83+ echo "docker pull ${{ secrets.DOCKER_USERNAME }}/thesis-app:latest"
0 commit comments