-
Notifications
You must be signed in to change notification settings - Fork 0
93 lines (78 loc) · 2.47 KB
/
docker-build.yml
File metadata and controls
93 lines (78 loc) · 2.47 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
name: Docker Build
on:
push:
branches: [ "dev" ]
pull_request:
branches: [ "dev" ]
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
jobs:
build-and-test:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to the Container registry
if: github.event_name == 'push'
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=sha
# 1. Build and Load to Docker Daemon for Testing
- name: Build and load Docker image
uses: docker/build-push-action@v5
with:
context: .
load: true
tags: super-rpc:test
cache-from: type=gha
cache-to: type=gha,mode=max
# 2. Run Tests
- name: Start services and Test
run: |
# Create data directory permissions
mkdir -p data
chmod 777 data
# Prepare config
cp config.example.yaml config.yaml
# Start using the image we just built (tagged super-rpc:test)
# We need to override the build in docker-compose to use our pre-built image
# OR just rely on compose building it again (it's fast with layer cache)
# Let's use compose to ensure environment consistency
docker compose up -d --build
echo "Waiting for service to be healthy..."
sleep 10
curl --retry 5 --retry-connrefused http://localhost:4500/health
echo "Running Integration Tests..."
chmod +x ./scripts/test_rpc.sh
./scripts/test_rpc.sh
- name: Show Container Logs
if: always()
run: docker compose logs
# 3. Push to Registry (Only on Push event)
- name: Build and push Docker image
if: github.event_name == 'push'
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max