Skip to content

Commit fa7ecd0

Browse files
authored
add bitbucket example (#56)
1 parent bad59e6 commit fa7ecd0

File tree

4 files changed

+59
-0
lines changed

4 files changed

+59
-0
lines changed

bitbucket/Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
FROM alpine

bitbucket/Dockerfile.log4j

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
FROM alpine:latest
2+
ADD https://archive.apache.org/dist/logging/log4j/2.14.1/apache-log4j-2.14.1-bin.tar.gz /root
3+
RUN tar xzvf /root/apache-log4j-2.14.1-bin.tar.gz

bitbucket/README.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Bitbucket pipelines demo
2+
3+
In this demo we will use Bitbucket pipelines to build, scan and push a container image.
4+
The workflow is as follows:
5+
6+
1. Download the sysdig-cli-scanner
7+
2. Build the container image and store it locally
8+
3. Perform the scan
9+
4. Login to the registry and push the image
10+
11+
## Setup
12+
13+
It is required to create a few repository secrets in order to be able to push the
14+
container image:
15+
16+
* `DOCKER_USER`: Docker username
17+
* `DOCKER_PASSWORD`: Docker user password
18+
* `DOCKER_REGISTRY`: Docker registry URL
19+
* `SECURE_API_TOKEN`: Sysdig Token

bitbucket/bitbucket-pipelines.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# Prerequisites: $DOCKER_USERNAME, $DOCKER_PASSWORD, $DOCKER_REGISTRY and $SECURE_API_TOKEN setup as deployment variables
2+
3+
image: atlassian/default-image:3
4+
5+
pipelines:
6+
default:
7+
- step:
8+
name: Download Sysdig CLI Scanner
9+
script:
10+
- curl -LO "https://download.sysdig.com/scanning/bin/sysdig-cli-scanner/$(curl -L -s https://download.sysdig.com/scanning/sysdig-cli-scanner/latest_version.txt)/linux/amd64/sysdig-cli-scanner"
11+
- chmod +x sysdig-cli-scanner
12+
artifacts:
13+
- sysdig-cli-scanner
14+
- step:
15+
name: Build image
16+
script:
17+
- IMAGE=${DOCKER_REGISTRY}/${BITBUCKET_REPO_SLUG}:${BITBUCKET_BUILD_NUMBER}
18+
- docker build . --file Dockerfile.log4j --tag ${IMAGE}
19+
- docker save ${IMAGE} --output "${BITBUCKET_REPO_SLUG}.tar"
20+
services:
21+
- docker
22+
artifacts:
23+
- "*.tar"
24+
- step:
25+
name: Scan image
26+
script:
27+
- ./sysdig-cli-scanner --apiurl https://us2.app.sysdig.com --console-log file://${BITBUCKET_REPO_SLUG}.tar
28+
- step:
29+
name: Push image
30+
script:
31+
- echo ${DOCKER_PASSWORD} | docker login --username "$DOCKER_USERNAME" --password-stdin ${DOCKER_REGISTRY}
32+
- IMAGE=${DOCKER_REGISTRY}/${BITBUCKET_REPO_SLUG}:${BITBUCKET_BUILD_NUMBER}
33+
- docker load --input "${BITBUCKET_REPO_SLUG}.tar"
34+
- docker push ${IMAGE}
35+
services:
36+
- docker

0 commit comments

Comments
 (0)