-
Notifications
You must be signed in to change notification settings - Fork 56
102 lines (93 loc) · 3.23 KB
/
docker-image.v4.yml
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 Image v4 CI
on:
push:
branches: [master]
schedule:
- cron: "0 0 * * *"
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
env:
POSTGRES_IMAGE: "postgres:16-alpine"
CLAIR_VERSION: "4.7.4"
CLAIR_LOCAL_SCAN_IMAGE: "arminc/clair-local-scan-v4"
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Runner diskspace workaround
run: |
# Symlink docker image and containers folders to /mnt (GitHub Action space limitation work around)
docker system prune -a -f
sudo systemctl stop docker
sudo mv /var/lib/docker /mnt/docker
json_content='{
"exec-opts": ["native.cgroupdriver=cgroupfs"],
"cgroup-parent": "/actions_job",
"data-root": "/mnt/docker"
}'
echo "$json_content" > /tmp/daemon.json
sudo mv /tmp/daemon.json /etc/docker/daemon.json
sudo rm -fr /var/lib/docker
sudo systemctl start docker
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v3
with:
driver: docker
install: true
- name: Build image
run: docker build -t $CLAIR_LOCAL_SCAN_IMAGE --build-arg VERSION=$CLAIR_VERSION clair/v4
- name: Start Postgres and run clair
run: |
docker pull $POSTGRES_IMAGE
docker run -d --name postgres -e 'PGDATA=/var/lib/postgresql/clair' -e POSTGRES_PASSWORD=password $POSTGRES_IMAGE
- name: Wait for database
run: |
sleep 30
- name: Docker Postgres info
run: |
docker ps -a
docker logs postgres
- name: Run Clair
run: |
docker run --rm -d --link postgres:postgres -e PGPASSWORD=password $POSTGRES_IMAGE pg_isready -U postgres -h postgres
docker run -d --name clair --link postgres:postgres $CLAIR_LOCAL_SCAN_IMAGE
- name: Wait for clair
run: |
sleep 10
- name: Docker Postgres info
run: |
docker ps -a
docker logs postgres
- name: Docker Clair info
run: |
docker ps -a
docker logs clair
- name: Checking
run: |
./clair/v4/check.sh
- name: Docker logs
run: |
docker logs clair
- name: Tag images
run: |
docker stop clair
docker stop postgres
docker commit postgres arminc/clair-db-v4:$(date +%Y-%m-%d)
docker tag arminc/clair-db-v4:$(date +%Y-%m-%d) arminc/clair-db-v4:latest
docker tag $CLAIR_LOCAL_SCAN_IMAGE ${CLAIR_LOCAL_SCAN_IMAGE}:${CLAIR_VERSION}_${GITHUB_SHA}
docker images
- name: Login to DockerHub
if: github.repository_owner == 'arminc'
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Push images
if: github.repository_owner == 'arminc'
run: |
docker push ${CLAIR_LOCAL_SCAN_IMAGE}:${CLAIR_VERSION}_${GITHUB_SHA}
docker push $CLAIR_LOCAL_SCAN_IMAGE:latest
docker push arminc/clair-db-v4:$(date +%Y-%m-%d)
docker push arminc/clair-db-v4:latest