forked from dokku-community/dokku-apt
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathpre-build-buildpack
executable file
·47 lines (43 loc) · 1.26 KB
/
pre-build-buildpack
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
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
APP="$1"; IMAGE="dokku/$APP"
echo "-----> Injecting apt repositories and packages ..."
DIR=/app
COMMAND=$(cat <<EOF
export DEBIAN_FRONTEND=noninteractive
if [ -f $DIR/apt-repositories ]; then
apt-get update
apt-get install -y software-properties-common apt-transport-https
cat "$DIR/apt-repositories" | while read repository; do
if [ -n "\$repository" ]; then
add-apt-repository -y "\$repository"
fi
done
fi
if [ -f $DIR/apt-debconf ]; then
cat "$DIR/apt-debconf" | while read conf; do
if [ -n "\$conf" ]; then
echo \$conf | debconf-set-selections
fi
done
fi
if [ -f $DIR/apt-packages ]; then
PACKAGES=\$(cat "$DIR/apt-packages" | tr "\\n" " ")
apt-get update
apt-get install -y \$PACKAGES
echo "-----> Injected packages: \$PACKAGES"
fi
if [ -d $DIR/dpkg-packages ]; then
for pkg in $DIR/dpkg-packages/*.deb; do
dpkg -i \$pkg
echo "-----> Injected package: \$pkg"
done
fi
sleep 1 # wait so that docker run has not exited before docker attach
EOF
)
id=$(docker run -d $IMAGE /bin/bash -e -c "$COMMAND")
#enable logs
docker attach $id
test $(docker wait $id) -eq 0
docker commit $id $IMAGE > /dev/null