-
Notifications
You must be signed in to change notification settings - Fork 0
183 lines (166 loc) · 6.36 KB
/
docker-build.yml
File metadata and controls
183 lines (166 loc) · 6.36 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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
name: Build and Push Docker Image
on:
push:
tags:
- 'v*.*.*' # Trigger on version tags (v1.0.0, v0.2.1, etc.)
branches:
- main # Also build main for latest tag
pull_request:
branches:
- main # Test builds on PRs
schedule:
- cron: '0 6 * * 1'
workflow_dispatch: # Allow manual triggers
inputs:
build_ingest_full:
description: "Build ingest-full image"
required: false
default: false
type: boolean
env:
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
jobs:
build-and-push:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
id-token: write # For OIDC signing (optional future use)
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to GitHub Container Registry
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels)
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
# Version tags (v1.0.0 → 1.0.0)
type=semver,pattern={{version}}
# Major.minor tags (v1.0.0 → 1.0)
type=semver,pattern={{major}}.{{minor}}
# Major tags (v1.0.0 → 1)
type=semver,pattern={{major}}
# Latest tag for main branch
type=raw,value=latest,enable={{is_default_branch}}
# PR tag (pr-15)
type=ref,event=pr,prefix=pr-
# Branch tag for main
type=ref,event=branch,enable=${{ github.ref == 'refs/heads/main' }}
# SHA tag for traceability
type=sha,prefix=sha-
labels: |
org.opencontainers.image.title=ReqIF-OPA-MCP
org.opencontainers.image.description=ReqIF compliance gate system with OPA and SARIF
org.opencontainers.image.vendor=PromptExecution
- name: Build and push Docker image
id: build
env:
BUILD_START: ${{ github.run_id }}-${{ github.run_attempt }}-${{ github.job }}
uses: docker/build-push-action@v6
with:
context: .
target: runtime-lite
platforms: linux/amd64,linux/arm64
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
build-args: |
PYTHON_VERSION=3.10
OPA_VERSION=0.71.0
- name: Build runtime-lite image locally for size metrics
if: always()
run: |
set -euo pipefail
START_SECONDS=$(date +%s)
docker buildx build \
--platform linux/amd64 \
--target runtime-lite \
--load \
-t local/reqif-opa-mcp:runtime-lite \
.
END_SECONDS=$(date +%s)
SIZE_BYTES=$(docker image inspect local/reqif-opa-mcp:runtime-lite --format '{{.Size}}')
DURATION_SECONDS=$((END_SECONDS - START_SECONDS))
echo "## Runtime-lite build metrics" >> "$GITHUB_STEP_SUMMARY"
echo "- Duration (s): ${DURATION_SECONDS}" >> "$GITHUB_STEP_SUMMARY"
echo "- Size (bytes): ${SIZE_BYTES}" >> "$GITHUB_STEP_SUMMARY"
- name: Generate artifact attestation
if: github.event_name != 'pull_request' && steps.build.outputs.digest != ''
uses: actions/attest-build-provenance@v2
with:
subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
subject-digest: ${{ steps.build.outputs.digest }}
push-to-registry: true
- name: Output image details
run: |
echo "## 🐳 Docker Image Published" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "**Registry:** \`${{ env.REGISTRY }}\`" >> $GITHUB_STEP_SUMMARY
echo "**Image:** \`${{ env.IMAGE_NAME }}\`" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "### Tags" >> $GITHUB_STEP_SUMMARY
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
echo "${{ steps.meta.outputs.tags }}" >> $GITHUB_STEP_SUMMARY
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "### Pull Command" >> $GITHUB_STEP_SUMMARY
echo "\`\`\`bash" >> $GITHUB_STEP_SUMMARY
echo "docker pull ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest" >> $GITHUB_STEP_SUMMARY
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
build-ingest-full:
runs-on: ubuntu-latest
if: github.event_name == 'schedule' || (github.event_name == 'workflow_dispatch' && inputs.build_ingest_full)
permissions:
contents: read
packages: write
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push ingest-full image
uses: docker/build-push-action@v6
with:
context: .
target: ingest-full
platforms: linux/amd64,linux/arm64
push: true
tags: |
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:ingest-full
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:sha-${{ github.sha }}-ingest-full
cache-from: type=gha
cache-to: type=gha,mode=max
build-args: |
PYTHON_VERSION=3.10
OPA_VERSION=0.71.0
- name: Smoke test ingest-full docling import
run: |
set -euo pipefail
docker buildx build \
--platform linux/amd64 \
--target ingest-full \
--load \
-t local/reqif-opa-mcp:ingest-full \
.
docker run --rm local/reqif-opa-mcp:ingest-full \
python -c "import docling; print(docling.__version__)"