This repository has been archived by the owner on Jun 19, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
/
build_with_docker
executable file
·71 lines (57 loc) · 1.93 KB
/
build_with_docker
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
#!/bin/bash
#
# use this script to build the R binaries with the `heroku/cedar:14` docker image locally
#
shopt -s extglob
# fail fast
set -e
# debug
# set -x
# for checking which version of the build script was used, output to STDOUT
# so that it gets included in the build log output file
echo "#======================================================================"
echo "# $0"
cat $0
echo "#======================================================================"
echo "# Environment"
set
echo "#======================================================================"
R_VERSION="${1:-3.4.0}"
BUILD_NO="${2:-`date +%Y%m%d-%H%M`}"
STACK="${3:-cedar-14}"
BUILDPACK_ARCHIVE="R-$R_VERSION-binaries-$BUILD_NO.tar.gz"
BUILDPACK_ARCHIVE_LATEST="R-$R_VERSION-binaries-latest.tar.gz"
# build the buildpack
docker run -t \
-v $(pwd):/var/tmp/scripts \
--name "$R_VERSION-$BUILD_NO" \
heroku/cedar:14 \
/var/tmp/scripts/build_r $R_VERSION $BUILD_NO $STACK
# commit for debugging
docker commit "$R_VERSION-$BUILD_NO" "vsv/$R_VERSION-$BUILD_NO"
# package up the binaries
docker run -t \
-v $(pwd):/var/tmp/scripts \
--name "$R_VERSION-$BUILD_NO-PKG" \
"vsv/$R_VERSION-$BUILD_NO" \
/var/tmp/scripts/package_r $R_VERSION $BUILD_NO $STACK
# get the binaries archive
docker cp "$R_VERSION-$BUILD_NO-PKG:/app/R-$R_VERSION-binaries-$BUILD_NO.tar.gz" .
# upload to S3
aws s3 cp $BUILDPACK_ARCHIVE \
"s3://heroku-buildpack-r/$STACK/$BUILDPACK_ARCHIVE" \
--acl=public-read \
--profile=heroku-buildpack-r
# clean up
# comment these out when debugging
docker rm "$R_VERSION-$BUILD_NO-PKG"
docker rm "$R_VERSION-$BUILD_NO"
docker rmi "vsv/$R_VERSION-$BUILD_NO"
echo
echo "After testing the build, make it current by running the following:"
echo
echo " aws s3 cp s3://heroku-buildpack-r/$STACK/$BUILDPACK_ARCHIVE \\ "
echo " s3://heroku-buildpack-r/$STACK/$BUILDPACK_ARCHIVE_LATEST \\ "
echo " --acl=public-read \\ "
echo " --profile=heroku-buildpack-r "
echo