Skip to content

Commit 08b2bdf

Browse files
authored
Merge pull request diffblue#560 from diffblue/smowton/feature/platform-build-script
Add platform build scripts
2 parents d51a092 + 9830c1b commit 08b2bdf

File tree

5 files changed

+109
-0
lines changed

5 files changed

+109
-0
lines changed

platform-image-builder/Dockerfile

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Copyright 2018 DiffBlue Limited. All Rights Reserved.
2+
ARG MODULE_TAG=latest
3+
FROM eu.gcr.io/diffblue-cr/deeptest-base:${MODULE_TAG} AS deeptest-master
4+
5+
LABEL vendor="DiffBlue Ltd."
6+
7+
RUN apt-get update
8+
RUN apt-get install -y cmake g++ flex bison doxygen patch python3
9+
10+
ADD build-security-analyzer.sh /build-security-analyzer.sh
11+
12+
ENTRYPOINT bash /build-security-analyzer.sh

platform-image-builder/README

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
These scripts build the security-analyser product within the Docker container
2+
expected by Diffblue's platform and export a tarball suitable for building the
3+
security scanner platform image.
4+
5+
Pre-requisite: the deeptest-base Docker image must be available to build
6+
against. If it isn't already present (try
7+
`docker image inspect eu.gcr.io/diffblue-cr/deeptest-base`),
8+
build it by:
9+
10+
$ git clone https://github.com/diffblue/platform
11+
$ cd platform/docker/docker-jobs
12+
$ make deeptest-base
13+
14+
Now we can make a security-analyser release tarball:
15+
16+
$ cd $REPO_ROOT/platform-image-builder
17+
$ mkdir -p /tmp/output-dir # for example
18+
$ ./make-security-release.sh /tmp/output-dir [branch-or-commit]
19+
20+
If 'branch-or-commit' is not specified we'll build a release tarball from the
21+
tip of 'develop'.
22+
23+
Note this maps your .ssh directory onto /root/.ssh within the build container,
24+
so if you're prompted for a passphrase for /root/.ssh/id_rsa or similar you
25+
should enter the passphrase for your private key.
26+
27+
If all goes well this will generate `/tmp/output-dir/sec-test.tar.gz`.
28+
See platform/docker/docker-jobs/security-analyser/README to create a final
29+
security docker image from this (or any other) release tarball.
30+
31+
============
32+
33+
Guide to components:
34+
35+
make-security-release.sh: driver script, invoked to build a release tarball.
36+
37+
Dockerfile: recipe for the build environment image, derived from deeptest-base
38+
plus some packages required to build the security product.
39+
40+
create-builder-image.sh: creates the build environment image; invoked on demand
41+
by make-security-release.sh.
42+
43+
build-security-analyzer.sh: runs inside the build environment image; builds
44+
and packages the security product.
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Runs inside the security-analyzer-builder container.
2+
3+
set -e
4+
5+
if [ ! -d /output ]; then
6+
echo "Directory /output should exist, e.g. by 'docker run ... -v /tmp/real-output-dir:/output security-analyzer-builder:latest'"
7+
exit 1
8+
fi
9+
10+
cd /
11+
git clone [email protected]:diffblue/security-scanner
12+
if [ $# -eq 1 ]; then git checkout $1; fi
13+
14+
cd security-scanner
15+
git submodule update --init
16+
17+
mkdir build
18+
cd build
19+
cmake .. -DCMAKE_BUILD_TYPE=Release
20+
make --jobs $(getconf _NPROCESSORS_ONLN)
21+
make install
22+
23+
cd ..
24+
mkdir /tmp/release
25+
cp -r trace-transformer /tmp/release/trace-transformer
26+
cp -r dist/bin /tmp/release/bin
27+
mkdir /tmp/release/lib
28+
cp dist/lib/libboost* /tmp/release/lib/
29+
cp -r dist/lib/driver/*.py /tmp/release
30+
cp src/java-class-info/default_config.json /tmp/release
31+
32+
cd /tmp/release
33+
tar cvzf /output/release.tar.gz .
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/bash
2+
3+
docker build -t security-analyzer-builder:latest .
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"
6+
cd $DIR
7+
8+
if [ $# -lt 1 ]; then
9+
echo "Usage: make-security-release.sh output-directory [branch-or-commit]"
10+
exit 1
11+
fi
12+
13+
docker image inspect security-analyzer-builder:latest >/dev/null 2>&1 || ./create-builder-image.sh
14+
15+
mkdir -p $1
16+
17+
docker run -i -t -v ~/.ssh:/root/.ssh:ro -v $1:/output security-analyzer-builder:latest $2

0 commit comments

Comments
 (0)