-
Notifications
You must be signed in to change notification settings - Fork 1
172 lines (165 loc) · 6.98 KB
/
build_application_images.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
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
name: Build and Push Application Images
on:
workflow_call:
env:
GIT_HASH: ${{ github.sha }}
GIT_REF_NAME: ${{ github.ref }}
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
permissions:
id-token: write
contents: read
jobs:
anti_virus:
runs-on: ubuntu-latest
container:
image: clamav/clamav:0.104.0
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Run clamscan
run: |
clamscan --version
mkdir -p /store && chown clamav /store
freshclam --config-file /etc/clamav/freshclam.conf --datadir=/store
clamscan --recursive --infected --detect-pua=yes --max-scansize=300M --max-filesize=100M --max-recursion=30 --max-files=50000 --tempdir=/tmp --database=/store .
- name: Announce failure
if: ${{ failure() }}
run: |
./scripts/github-action-announce-broken-branch
build_db_migrate_image:
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Configure AWS credentials
uses: aws-actions/[email protected]
with:
role-to-assume: ${{ secrets.INFRA_ROLE_TO_ASSUME }}
aws-region: us-east-1
- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v2
- name: Build and push
uses: docker/build-push-action@v6
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
ECR_REPOSITORY: mint-db-migrate
with:
push: true
tags: ${{ env.ECR_REGISTRY }}/${{ env.ECR_REPOSITORY }}:${{ env.GIT_HASH }}
file: "Dockerfile.db_migrations"
platforms: "linux/amd64"
context: .
cache-from: type=gha,scope=${{ env.GIT_REF_NAME }}-db_migrate
build-args: |
TAG=10.15-alpine
# As of Buildx verion 0.10, image are build with provenance by default.
# Lambda currently does not support functions that use multi-architecture container images (https://docs.aws.amazon.com/lambda/latest/dg/images-create.html#images-reqs)
# As such, the Lambda for vulnerability scanning will fail if the image is built with provenance.
# More information can be found here: https://github.com/docker/buildx/issues/1533
provenance: false
- name: Announce failure
if: ${{ failure() }}
run: |
./scripts/github-action-announce-broken-branch
build_db_clean_image:
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Configure AWS credentials
uses: aws-actions/[email protected]
with:
role-to-assume: ${{ secrets.INFRA_ROLE_TO_ASSUME }}
aws-region: us-east-1
- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v2
- name: Build and push
uses: docker/build-push-action@v6
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
ECR_REPOSITORY: mint-db-clean
with:
push: true
tags: ${{ env.ECR_REGISTRY }}/${{ env.ECR_REPOSITORY }}:latest # Always tag with latest, since this image doesn't contain any build-specific contents
file: "Dockerfile.db_clean"
platforms: "linux/amd64"
cache-from: type=gha,scope=${{ env.GIT_REF_NAME }}-db_clean
cache-to: type=gha,mode=max,scope=${{ env.GIT_REF_NAME }}-db_clean
context: .
# As of Buildx verion 0.10, image are build with provenance by default.
# Lambda currently does not support functions that use multi-architecture container images (https://docs.aws.amazon.com/lambda/latest/dg/images-create.html#images-reqs)
# As such, the Lambda for vulnerability scanning will fail if the image is built with provenance.
# More information can be found here: https://github.com/docker/buildx/issues/1533
provenance: false
- name: Announce failure
if: ${{ failure() }}
run: |
./scripts/github-action-announce-broken-branch
build_server_image:
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Configure AWS credentials
uses: aws-actions/[email protected]
with:
role-to-assume: ${{ secrets.INFRA_ROLE_TO_ASSUME }}
aws-region: us-east-1
- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v2
- name: Calculate build args
id: calculate-build-args
run: |
APPLICATION_DATETIME="$(date --rfc-3339='seconds' --utc)"
APPLICATION_TS="$(date --date="$APPLICATION_DATETIME" '+%s')"
echo "APPLICATION_DATETIME=${APPLICATION_DATETIME}" >> $GITHUB_OUTPUT
echo "APPLICATION_TS=${APPLICATION_TS}" >> $GITHUB_OUTPUT
- name: Build and push
uses: docker/build-push-action@v6
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
ECR_REPOSITORY: mint-backend
with:
push: true
tags: ${{ env.ECR_REGISTRY }}/${{ env.ECR_REPOSITORY }}:${{ env.GIT_HASH }}
file: "Dockerfile"
platforms: "linux/amd64"
context: .
cache-from: type=gha,scope=${{ env.GIT_REF_NAME }}-mint
build-args: |
ARG_APPLICATION_DATETIME=${{ steps.calculate-build-args.outputs.APPLICATION_DATETIME }}
ARG_APPLICATION_TS=${{ steps.calculate-build-args.outputs.APPLICATION_TS }}
ARG_APPLICATION_VERSION=${{ env.GIT_HASH }}
# As of Buildx verion 0.10, image are build with provenance by default.
# Lambda currently does not support functions that use multi-architecture container images (https://docs.aws.amazon.com/lambda/latest/dg/images-create.html#images-reqs)
# As such, the Lambda for vulnerability scanning will fail if the image is built with provenance.
# More information can be found here: https://github.com/docker/buildx/issues/1533
provenance: false
- name: Announce failure
if: ${{ failure() }}
run: |
./scripts/github-action-announce-broken-branch