Skip to content

Commit 54ccd5a

Browse files
committed
Docker apt-cacher
1 parent 0ef83cf commit 54ccd5a

File tree

2 files changed

+19
-8
lines changed

2 files changed

+19
-8
lines changed

bin/make-base-vm

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ LXC=0
99
VBOX=0
1010
DOCKER=0
1111
DOCKER_IMAGE_HASH=""
12+
APT_CACHER_DEFAULT=0
1213

1314
usage() {
1415
echo "Usage: ${0##*/} [OPTION]..."
@@ -24,6 +25,7 @@ usage() {
2425
--vbox use VirtualBox instead of kvm
2526
--docker use docker instead of kvm
2627
--docker-image-hash D digest of the docker image to build from
28+
--enable-apt-cacher enable APT Cacher
2729
2830
The MIRROR_HOST environment variable can be used to change the
2931
apt-cacher host. It should be something that both the host and the
@@ -88,6 +90,10 @@ if [ $# != 0 ] ; then
8890
DOCKER=1
8991
shift 1
9092
;;
93+
--enable-apt-cacher)
94+
APT_CACHER=1
95+
shift 1
96+
;;
9197
--docker-image-digest)
9298
DOCKER_IMAGE_HASH="$2"
9399
shift 2
@@ -103,13 +109,11 @@ if [ $# != 0 ] ; then
103109
done
104110
fi
105111

106-
if [ $DOCKER = "1" ]; then
107-
MIRROR_DEFAULT=172.17.0.1
108-
else
109-
MIRROR_DEFAULT=127.0.0.1
110-
fi
112+
MIRROR_DEFAULT=127.0.0.1
111113
MIRROR_BASE=http://${MIRROR_HOST:-$MIRROR_DEFAULT}:3142
112114

115+
APT_CACHER=${APT_CACHER:-$APT_CACHER_DEFAULT}
116+
113117
if [ $DISTRO = "ubuntu" ]; then
114118
MIRROR=$MIRROR_BASE/archive.ubuntu.com/ubuntu
115119
SECURITY_MIRROR=$MIRROR_BASE/security.ubuntu.com/ubuntu
@@ -193,12 +197,19 @@ if [ $DOCKER = "1" ]; then
193197
base_image="$DISTRO:$SUITE"
194198
fi
195199

200+
apt_cacher=""
201+
if [ "$APT_CACHER" = 1 ]; then
202+
apt_cacher="RUN echo 'Acquire::http { Proxy "$MIRROR_BASE"; };' > /etc/apt/apt.conf.d/50cacher"
203+
fi
204+
196205
# Generate the dockerfile
197206
cat << EOF > $OUT.Dockerfile
198207
FROM $base_image
199208
200209
ENV DEBIAN_FRONTEND=noninteractive
201-
RUN echo 'Acquire::http { Proxy "$MIRROR_BASE"; };' > /etc/apt/apt.conf.d/50cacher
210+
# DELETE ESM Files: W: Failed to fetch https://esm.ubuntu.com/ubuntu/dists/trusty-infra-security/main/binary-amd64/Packages Received HTTP code 403 from proxy after CONNECT
211+
RUN [ -f /etc/apt/sources.list.d/*esm*.list ] && rm /etc/apt/sources.list.d/*esm*.list
212+
$apt_cacher
202213
RUN apt-get update && apt-get --no-install-recommends -y install $addpkg
203214
204215
RUN useradd -ms /bin/bash -U $DISTRO
@@ -208,7 +219,7 @@ WORKDIR /home/$DISTRO
208219
CMD ["sleep", "infinity"]
209220
EOF
210221

211-
docker build --pull -f $OUT.Dockerfile -t $OUT .
222+
docker build --network host --pull -f $OUT.Dockerfile -t $OUT .
212223

213224
exit 0
214225
fi

libexec/start-target

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,6 @@ case $VMSW in
3737
echo "Gitian-${2}" > var/target.vmname
3838
;;
3939
DOCKER)
40-
docker run -d --name gitian-target base-$SUFFIX:latest > /dev/null
40+
docker run --network host -d --name gitian-target base-$SUFFIX:latest > /dev/null
4141
;;
4242
esac

0 commit comments

Comments
 (0)