2018-04-06 12:07:02 +00:00
|
|
|
#!/bin/bash
|
|
|
|
set -euxo pipefail
|
|
|
|
|
|
|
|
export DEBIAN_FRONTEND=noninteractive
|
|
|
|
|
2018-11-30 14:13:49 +00:00
|
|
|
build_packages=(
|
|
|
|
apt-transport-https
|
|
|
|
lsb-release
|
|
|
|
)
|
2018-04-06 12:07:02 +00:00
|
|
|
|
2018-11-30 14:13:49 +00:00
|
|
|
install_packages=(
|
|
|
|
docker-ce
|
|
|
|
jq
|
|
|
|
make
|
2018-04-06 12:07:02 +00:00
|
|
|
sudo
|
2018-11-30 14:13:49 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
apt-get update
|
2018-04-06 12:07:02 +00:00
|
|
|
|
2018-11-30 14:13:49 +00:00
|
|
|
# Install packages required for building the image
|
|
|
|
apt-get install -y --no-install-recommends ${build_packages[@]}
|
2018-04-06 12:07:02 +00:00
|
|
|
|
2018-11-30 14:13:49 +00:00
|
|
|
# Activate docker repo
|
|
|
|
curl -sSfL https://download.docker.com/linux/debian/gpg | apt-key add -
|
2018-04-06 12:07:02 +00:00
|
|
|
echo "deb [arch=amd64] https://download.docker.com/linux/debian $(lsb_release -sc) stable" >/etc/apt/sources.list.d/docker.list
|
|
|
|
apt-get update
|
2018-11-30 14:13:49 +00:00
|
|
|
|
|
|
|
# Install packages to stay in the image
|
|
|
|
apt-get install -y --no-install-recommends ${install_packages[@]}
|
2018-04-06 12:07:02 +00:00
|
|
|
|
|
|
|
# Allow jenkins to use `sudo` and docker
|
|
|
|
echo "jenkins ALL=(ALL) NOPASSWD: ALL" >>/etc/sudoers.d/jenkins
|
|
|
|
usermod -a -G docker jenkins
|
|
|
|
|
|
|
|
# Cleanup
|
2018-11-30 14:13:49 +00:00
|
|
|
apt-get purge -y ${build_packages[@]}
|
2018-04-06 12:07:02 +00:00
|
|
|
apt-get autoremove --purge -y
|
|
|
|
rm -rf /var/lib/apt/lists/*
|