Skip to content

Commit c4ab7d7

Browse files
committed
feat: Update CI workflow and dashboard Dockerfile
- Modify GitHub Actions CI to separate image build and push steps - Add security-events write permission to CI job - Remove standalone security-scan job; integrate Trivy scan into build pipeline - Add image push steps after scanning in CI workflow - Update Makefile with new security-scan target using Trivy for Docker images - Upgrade dashboard Dockerfile base image from node 20 to 22 alpine - Patch picomatch package in dashboard image to fix potential vulnerabilities during build
1 parent 372919e commit c4ab7d7

3 files changed

Lines changed: 56 additions & 34 deletions

File tree

.github/workflows/ci.yml

Lines changed: 40 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ jobs:
122122
if: github.repository == 'haesookimDev/xgen-sandbox' && github.event_name == 'push' && github.ref == 'refs/heads/main'
123123
permissions:
124124
packages: write
125+
security-events: write
125126
env:
126127
REGISTRY_IMAGE: ghcr.io/${{ github.repository }}
127128
steps:
@@ -137,54 +138,33 @@ jobs:
137138
username: ${{ github.actor }}
138139
password: ${{ secrets.GITHUB_TOKEN }}
139140

140-
- name: Build and push agent image
141+
- name: Build agent image
141142
uses: docker/build-push-action@v6
142143
with:
143144
context: ./agent
144-
push: true
145-
tags: |
146-
${{ env.REGISTRY_IMAGE }}/agent:latest
147-
${{ env.REGISTRY_IMAGE }}/agent:${{ github.sha }}
145+
load: true
146+
tags: ${{ env.REGISTRY_IMAGE }}/agent:${{ github.sha }}
148147
cache-from: type=gha
149148
cache-to: type=gha,mode=max
150149

151-
- name: Build and push sidecar image
150+
- name: Build sidecar image
152151
uses: docker/build-push-action@v6
153152
with:
154153
context: ./sidecar
155-
push: true
156-
tags: |
157-
${{ env.REGISTRY_IMAGE }}/sidecar:latest
158-
${{ env.REGISTRY_IMAGE }}/sidecar:${{ github.sha }}
154+
load: true
155+
tags: ${{ env.REGISTRY_IMAGE }}/sidecar:${{ github.sha }}
159156
cache-from: type=gha
160157
cache-to: type=gha,mode=max
161158

162-
- name: Build and push dashboard image
159+
- name: Build dashboard image
163160
uses: docker/build-push-action@v6
164161
with:
165162
context: ./dashboard
166-
push: true
167-
tags: |
168-
${{ env.REGISTRY_IMAGE }}/dashboard:latest
169-
${{ env.REGISTRY_IMAGE }}/dashboard:${{ github.sha }}
163+
load: true
164+
tags: ${{ env.REGISTRY_IMAGE }}/dashboard:${{ github.sha }}
170165
cache-from: type=gha
171166
cache-to: type=gha,mode=max
172167

173-
security-scan:
174-
runs-on: ubuntu-latest
175-
needs: [docker]
176-
if: github.repository == 'haesookimDev/xgen-sandbox' && github.event_name == 'push' && github.ref == 'refs/heads/main'
177-
permissions:
178-
packages: read
179-
security-events: write
180-
env:
181-
REGISTRY_IMAGE: ghcr.io/${{ github.repository }}
182-
steps:
183-
- uses: actions/checkout@v4
184-
185-
- name: Lowercase registry image name
186-
run: echo "REGISTRY_IMAGE=${REGISTRY_IMAGE,,}" >> "$GITHUB_ENV"
187-
188168
- name: Scan agent image
189169
uses: aquasecurity/trivy-action@v0.35.0
190170
with:
@@ -208,3 +188,33 @@ jobs:
208188
format: table
209189
exit-code: '1'
210190
severity: CRITICAL,HIGH
191+
192+
- name: Push agent image
193+
uses: docker/build-push-action@v6
194+
with:
195+
context: ./agent
196+
push: true
197+
tags: |
198+
${{ env.REGISTRY_IMAGE }}/agent:latest
199+
${{ env.REGISTRY_IMAGE }}/agent:${{ github.sha }}
200+
cache-from: type=gha
201+
202+
- name: Push sidecar image
203+
uses: docker/build-push-action@v6
204+
with:
205+
context: ./sidecar
206+
push: true
207+
tags: |
208+
${{ env.REGISTRY_IMAGE }}/sidecar:latest
209+
${{ env.REGISTRY_IMAGE }}/sidecar:${{ github.sha }}
210+
cache-from: type=gha
211+
212+
- name: Push dashboard image
213+
uses: docker/build-push-action@v6
214+
with:
215+
context: ./dashboard
216+
push: true
217+
tags: |
218+
${{ env.REGISTRY_IMAGE }}/dashboard:latest
219+
${{ env.REGISTRY_IMAGE }}/dashboard:${{ github.sha }}
220+
cache-from: type=gha

Makefile

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
-include .env
22
export
33

4-
.PHONY: all build build-agent build-sidecar build-dashboard build-images dev-cluster dev-deploy dev-dashboard dev-teardown test lint help
4+
.PHONY: all build build-agent build-sidecar build-dashboard build-images dev-cluster dev-deploy dev-dashboard dev-teardown test lint security-scan help
55

66
# --- Help ---
77

@@ -92,6 +92,13 @@ tidy: ## Run go mod tidy for agent and sidecar
9292
cd agent && go mod tidy
9393
cd sidecar && go mod tidy
9494

95+
# --- Security ---
96+
97+
security-scan: build-images ## Run Trivy security scan on Docker images (requires: brew install trivy)
98+
trivy image --severity CRITICAL,HIGH --exit-code 1 ghcr.io/xgen-sandbox/agent:latest
99+
trivy image --severity CRITICAL,HIGH --exit-code 1 ghcr.io/xgen-sandbox/sidecar:latest
100+
trivy image --severity CRITICAL,HIGH --exit-code 1 ghcr.io/xgen-sandbox/dashboard:latest
101+
95102
# --- Hot Reload Development ---
96103

97104
dev-agent: ## Run agent with hot reload (requires: go install github.com/air-verse/air@latest)

dashboard/Dockerfile

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM node:20-alpine AS builder
1+
FROM node:22-alpine AS builder
22
WORKDIR /app
33

44
COPY package.json package-lock.json* ./
@@ -7,11 +7,16 @@ RUN npm install --frozen-lockfile 2>/dev/null || npm install
77
COPY . .
88
RUN npm run build
99

10-
FROM node:20-alpine AS runner
10+
FROM node:22-alpine AS runner
1111
WORKDIR /app
1212
ENV NODE_ENV=production
1313

14-
RUN apk upgrade --no-cache
14+
RUN apk upgrade --no-cache && \
15+
PICO_DIR=$(find /usr/local/lib/node_modules/npm -type d -name picomatch | head -1) && \
16+
wget -qO /tmp/p.tgz https://registry.npmjs.org/picomatch/-/picomatch-4.0.4.tgz && \
17+
rm -rf "$PICO_DIR"/* && \
18+
tar xzf /tmp/p.tgz --strip-components=1 -C "$PICO_DIR" && \
19+
rm /tmp/p.tgz
1520

1621
RUN addgroup --system --gid 1001 nodejs && \
1722
adduser --system --uid 1001 nextjs

0 commit comments

Comments
 (0)