-
-
Notifications
You must be signed in to change notification settings - Fork 137
102 lines (98 loc) · 2.85 KB
/
docker-build.yml
File metadata and controls
102 lines (98 loc) · 2.85 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
name: "Docker Build"
on:
push:
branches:
- master
tags:
- "v*.*.*"
jobs:
test:
runs-on: ubuntu-latest
steps:
-
name: Checkout repository
uses: actions/checkout@v6
-
name: Setup Docker Buildx
uses: docker/setup-buildx-action@v4
-
name: Build test image
uses: docker/build-push-action@v7
with:
context: .
file: ./docker/Dockerfile.dev
load: true
tags: photonix-test:latest
-
name: Start Redis
run: docker run -d --name redis --network host redis:8-alpine
-
name: Run tests
run: docker run --rm --network host photonix-test:latest python test.py
build-and-push:
needs: test
runs-on: ubuntu-latest
steps:
-
name: Checkout repository
uses: actions/checkout@v6
-
name: Docker meta
id: meta
uses: docker/metadata-action@v6
with:
images: photonixapp/photonix
tags: |
type=raw,value=edge,enable={{is_default_branch}}
type=raw,value=latest,enable=${{ startsWith(github.ref, 'refs/tags/v') }}
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
-
name: Setup Docker Buildx
uses: docker/setup-buildx-action@v4
-
name: Login to DockerHub
uses: docker/login-action@v4
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
-
name: Set up QEMU
uses: docker/setup-qemu-action@v4
-
name: Build and push
uses: docker/build-push-action@v7
with:
context: .
file: ./docker/Dockerfile.prd
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.meta.outputs.tags }}
cache-from: type=gha,scope=prod
cache-to: type=gha,mode=max,scope=prod
deploy-k8s:
needs: build-and-push
if: startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-latest
steps:
-
name: Set up kubectl
uses: azure/setup-kubectl@v5
-
name: Set up kubeconfig
uses: azure/k8s-set-context@v5
with:
method: kubeconfig
kubeconfig: ${{ secrets.KUBE_CONFIG }}
-
name: Deploy
run: |
echo "Deploying image: photonixapp/photonix:latest"
kubectl set image deployment/photonix-demo photonix-demo=photonixapp/photonix:latest -n photonix
kubectl rollout restart deployment/photonix-demo -n photonix
-
name: Wait for pod to start
run: |
echo "Waiting for photonix-demo deployment to complete..."
kubectl rollout status deployment/photonix-demo -n photonix --timeout=600s