-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathconfig.yml
More file actions
91 lines (83 loc) · 3.11 KB
/
Copy pathconfig.yml
File metadata and controls
91 lines (83 loc) · 3.11 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
version: 2.1
orbs:
# docker vulnerability scanning with AWS ECR
# reference this is the orb usage guide for aws-ecr:
# https://circleci.com/orbs/registry/orb/circleci/aws-ecr
# required environment variables:
# https://circleci.com/docs/2.0/ecs-ecr/#configure-circleci-environment-variables
aws-ecr: circleci/aws-ecr@8.1.2
workflows:
version: 2
build-and-test:
jobs:
- docker_image:
context: docker-hub
- test
# use aws-ecr CircleCI Orb as a docker image vulnerability scanner.
- aws-ecr/build-and-push-image:
name: docker_image_and_vuln_scanning_with_ecr
# docker vulnerability scanning with AWS ECR!
# references:
#
# https://circleci.com/orbs/registry/orb/circleci/aws-ecr
# https://circleci.com/docs/2.0/ecs-ecr/
#
# The AWS ECR repo name, example: remind101/acme-inc
repo: "$CIRCLE_PROJECT_USERNAME/$CIRCLE_PROJECT_REPONAME"
# tags for this image, comma separated.
tag: "latest,$CIRCLE_BRANCH,$CIRCLE_SHA1"
# create the AWS ECR repo if it does not exist already.
create-repo: true
lifecycle-policy-path: >
{
"rules": [
{
"rulePriority": 1,
"description": "Keep latest master image",
"selection": {
"tagStatus": "tagged",
"tagPrefixList": ["master", "main"],
"countType": "imageCountMoreThan",
"countNumber": 5
},
"action": {
"type": "expire"
}
},
{
"rulePriority": 2,
"description": "Expire all images older than 90 days.",
"selection": {
"countType": "sinceImagePushed",
"countNumber": 90,
"countUnit": "days"
},
"action": {
"type": "expire"
}
}
]
}
# provide the aws-ecr context (environment variables) to push docker_image into ecr.
# https://circleci.com/docs/2.0/ecs-ecr/#configure-circleci-environment-variables
context: aws-ecr
jobs:
# docker-build is a small script for building, tagging and pushing docker images within CircleCI.
docker_image:
docker:
# build docker images and push them into a remote docker hub.
# https://github.com/remind101/docker-build/commits/5af523d5343bb852aa41c56b47dd470b9d3beccd
- image: remind101/docker-build@sha256:d8087702ebd201855dd98dff98bb122a2cb18149edb1e1d6ee3b09e635b0f43b
steps:
- checkout
- setup_remote_docker
- run: docker login -u $DOCKER_USER -p $DOCKER_PASS
- run: docker-build # build, tag and push
test:
working_directory: /go/src/github.com/remind101/acme-inc
docker:
# Primary container image where all the steps run.
- image: circleci/golang:1.10
steps:
- checkout
- run: go test