forked from docker-32bit/debian
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild-image.sh
executable file
·45 lines (35 loc) · 1.19 KB
/
build-image.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
42
43
44
45
#!/bin/bash -x
### Build a docker image for debian i386.
### settings
arch=i386
suite=${1:-jessie}
chroot_dir="/var/chroot/$suite"
apt_mirror="http://http.debian.net/debian"
docker_image="32bit/debian:$suite"
### make sure that the required tools are installed
apt-get install -y docker-ce debootstrap schroot
### install a minbase system with debootstrap
export DEBIAN_FRONTEND=noninteractive
debootstrap --arch $arch $suite $chroot_dir $apt_mirror
### update the list of package sources
cat <<EOF > $chroot_dir/etc/apt/sources.list
deb $apt_mirror $suite main contrib non-free
deb $apt_mirror $suite-updates main contrib non-free
deb http://security.debian.org/ $suite/updates main contrib non-free
EOF
### upgrade packages
chroot $chroot_dir apt-get update
chroot $chroot_dir apt-get upgrade -y
### cleanup
chroot $chroot_dir apt-get autoclean
chroot $chroot_dir apt-get clean
chroot $chroot_dir apt-get autoremove
### create a tar archive from the chroot directory
tar cfz debian.tgz -C $chroot_dir .
### import this tar archive into a docker image:
cat debian.tgz | docker import - $docker_image
# ### push image to Docker Hub
# docker push $docker_image
### cleanup
rm debian.tgz
rm -rf $chroot_dir