Skip to content
This repository was archived by the owner on Dec 22, 2022. It is now read-only.

Commit 7d02f1a

Browse files
author
Mathieu Benoit
committed
ci
1 parent 941b63e commit 7d02f1a

File tree

2 files changed

+108
-12
lines changed

2 files changed

+108
-12
lines changed

.github/workflows/ci.yml

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
name: ci
2+
on:
3+
push:
4+
branches:
5+
- main
6+
paths-ignore:
7+
- 'README.md'
8+
- '.github/dependabot.yml'
9+
pull_request:
10+
env:
11+
SEVERITY: CRITICAL
12+
jobs:
13+
job:
14+
runs-on: ubuntu-20.04
15+
steps:
16+
- uses: actions/[email protected]
17+
- uses: google-github-actions/[email protected]
18+
with:
19+
project_id: ${{ secrets.CONTAINER_REGISTRY_PROJECT_ID }}
20+
credentials_json: ${{ secrets.CONTAINER_REGISTRY_PUSH_PRIVATE_KEY }}
21+
- uses: google-github-actions/[email protected]
22+
with:
23+
version: latest
24+
- name: prepare environment variables
25+
run: |
26+
shortSha=`echo ${GITHUB_SHA} | cut -c1-7`
27+
echo "IMAGE_TAG=$shortSha" >> $GITHUB_ENV
28+
imageBaseName=${{ secrets.CONTAINER_REGISTRY_HOST_NAME }}/${{ secrets.CONTAINER_REGISTRY_PROJECT_ID }}/${{ secrets.CONTAINER_REGISTRY_NAME }}
29+
echo "IMAGE_BASE_NAME=$imageBaseName" >> $GITHUB_ENV
30+
- name: sign-in to artifact registry
31+
run: |
32+
gcloud auth configure-docker ${{ secrets.CONTAINER_REGISTRY_HOST_NAME }} --quiet
33+
- name: manage base images
34+
run: |
35+
# Grab the build base image in our private registry
36+
baseImage=$(cat ${_APP_NAME}/Dockerfile | grep 'FROM alpine')
37+
baseImage=($baseImage)
38+
docker pull ${baseImage[1]}
39+
newImage=$(echo ${baseImage[1]} | sed "s,alpine,${_CONTAINER_REGISTRY_NAME}/alpine,g")
40+
docker tag ${baseImage[1]} $newImage
41+
docker push $newImage
42+
# Grab the runtime base image in our private registry
43+
baseImage=$(cat ${_APP_NAME}/Dockerfile | grep 'FROM nginxinc')
44+
baseImage=($baseImage)
45+
docker pull ${baseImage[1]}
46+
newImage=$(echo ${baseImage[1]} | sed "s,nginxinc,${_CONTAINER_REGISTRY_NAME},g")
47+
docker tag ${baseImage[1]} $newImage
48+
docker push $newImage
49+
# Use the base images from our own private registry
50+
sed -i "s,FROM alpine,FROM ${_CONTAINER_REGISTRY_NAME}/alpine,g;s,FROM nginxinc,FROM ${_CONTAINER_REGISTRY_NAME},g" ${_APP_NAME}/Dockerfile
51+
- name: build container
52+
run: |
53+
docker build --tag ${IMAGE_NAME} .
54+
imageSize=$(printf %.2f "$(($(docker image inspect ${IMAGE_NAME} --format='{{.Size}}') * 10**2 / $(printf '%5.0f\n' 1e6)))e-2")
55+
echo "IMAGE_SIZE=$imageSize"
56+
- name: dockle
57+
run: |
58+
docker run -v /var/run/docker.sock:/var/run/docker.sock --rm goodwithtech/dockle:latest --exit-code 1 --exit-level fatal ${IMAGE_NAME}
59+
- name: run trivy vulnerability scanner
60+
uses: aquasecurity/[email protected]
61+
with:
62+
image-ref: ${{ env.IMAGE_NAME }}
63+
format: 'template'
64+
template: '@/contrib/sarif.tpl'
65+
output: 'trivy-results.sarif'
66+
severity: ${{ env.SEVERITY }}
67+
- name: upload trivy scan results to GitHub security tab
68+
uses: github/codeql-action/[email protected]
69+
with:
70+
sarif_file: 'trivy-results.sarif'
71+
- name: run container locally as a test
72+
run: |
73+
docker run -d -p 8080:8080 --read-only --cap-drop=ALL --user=1000 ${IMAGE_NAME}
74+
- name: gcloud scan
75+
run: |
76+
gcloud components install local-extract --quiet
77+
gcloud artifacts docker images scan ${IMAGE_NAME} --format='value(response.scan)' > scan_id.txt
78+
gcloud artifacts docker images list-vulnerabilities $(cat scan_id.txt) --format='table(vulnerability.effectiveSeverity, vulnerability.cvssScore, noteName, vulnerability.packageIssue[0].affectedPackage, vulnerability.packageIssue[0].affectedVersion.name, vulnerability.packageIssue[0].fixedVersion.name)'
79+
gcloud artifacts docker images list-vulnerabilities $(cat scan_id.txt) --format='value(vulnerability.effectiveSeverity)' | if grep -Fxq ${{ env.SEVERITY }}; then echo 'Failed vulnerability check' && exit 1; else exit 0; fi
80+
- name: push image in container registry
81+
if: ${{ github.event_name == 'push' }}
82+
run: |
83+
docker push ${IMAGE_NAME}

README.md

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,31 @@
22

33
Put this https://alwaysupalwayson.com/asm-security as a workshop.
44

5-
1. Create a GKE cluster
6-
1. Install ASM
7-
1. Install OnlineBoutique
8-
1. Enable mTLS
9-
1. Setup Sidecar
10-
1. Setup AuthorizationPolicies
11-
1. Setup Ingress Gateway
12-
1. Setup Egress Gateway
13-
1. Setup NetworkPolicies
14-
1. Setup SLOs
15-
1. Misc: any Istio's features about traffic management, etc.
5+
1. [ ] Create a GKE cluster
6+
1. [ ] Install ASM
7+
1. [ ] Ingress Gateway
8+
1. [ ] Egress Gateway
9+
1. [ ] Install OnlineBoutique
10+
1. [ ] mTLS
11+
1. [ ] Sidecar
12+
1. [ ] AuthorizationPolicies
13+
1. [ ] NetworkPolicies
14+
1. [ ] Monitoring: Topology, SLOs, Traces, etc.
15+
1. [ ] Misc: any Istio's features about traffic management, etc.
1616

17-
Rk:
17+
Further considerations:
1818
- Do the same with BankOfAnthos?
19+
- Multi-cluster?
20+
- MCP (control/data plane)?
1921
- Integrate CRfA in there? Or do another similar crfa-workshop?
22+
23+
24+
## Build and run this static web site locally
25+
26+
```
27+
git clone --recurse-submodules https://github.com/mathieu-benoit/asm-workshop
28+
docker build -t asm-workshop .
29+
docker run -d -p 8080:8080 asm-workshop
30+
```
31+
32+
##

0 commit comments

Comments
 (0)