-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.sh
executable file
·41 lines (33 loc) · 1.21 KB
/
build.sh
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
#!/bin/bash
BASE_IMAGE=docker://docker.io/phusion/baseimage:0.11
HERE=$(cd $(dirname $0) && echo $PWD)
set -e -x
# Create directories needed for caching
while read dirname; do
mkdir -p $HERE/$dirname
done <<DIRs
root/artifacts
var/lib/apt/lists
var/cache/apt/archives
DIRs
# Start building image:
ctr=$(buildah from --name warsaw-banking --pull $BASE_IMAGE)
mnt=$(buildah mount $ctr)
# Add file structure from `fs` to the image root
buildah copy --chown root:root $ctr $HERE/fs
# Mount into the image the root home and directories that contain caches used by the installation
VOLUMES="\
-v $HERE/root:/root \
-v $HERE/var/lib/apt/lists:/var/lib/apt/lists \
-v $HERE/var/cache/apt/archives:/var/cache/apt/archives \
"
buildah run $VOLUMES --net=host $ctr -- /root/install.sh $(id -u $USER)
buildah run $VOLUMES $ctr -- /sbin/my_init -- /root/savecert.sh
buildah run $ctr -- rm /var/lib/syslog-ng/syslog-ng.ctl
# TODO: perhaps clean up `/var/lib` or `/var/log` directories (or mount a volume over them as well)
buildah config \
--workingdir /home/ubuntu \
--entrypoint '["/sbin/my_init", "--", "/sbin/setuser", "ubuntu"]' \
--cmd bash \
$ctr
buildah commit --squash $ctr warsaw-banking