-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sh
executable file
·52 lines (41 loc) · 1.3 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
42
43
44
45
46
47
48
49
50
51
52
#!/bin/bash
set -euxo pipefail
export DEBIAN_FRONTEND=noninteractive
build_packages=(
apt-transport-https
lsb-release
)
install_packages=(
docker-buildx-plugin
docker-ce
jq
locales
make
sudo
zip
)
apt-get update
# Install packages required for building the image
apt-get install -y --no-install-recommends ${build_packages[@]}
# Activate docker repo
curl -sSfL https://download.docker.com/linux/debian/gpg | apt-key add -
echo "deb [arch=amd64] https://download.docker.com/linux/debian $(lsb_release -sc) stable" >/etc/apt/sources.list.d/docker.list
apt-get update
# Install packages to stay in the image
apt-get install -y --no-install-recommends ${install_packages[@]}
# Install en_US locale
sed -Ei 's/# (en_US.UTF-8.*)/\1/' /etc/locale.gen
locale-gen
# Allow jenkins to use `sudo` and docker
echo "jenkins ALL=(ALL) NOPASSWD: ALL" >>/etc/sudoers.d/jenkins
usermod -a -G docker jenkins
# Install Vault for global usage
VAULT_VERSION=$(curl -sSfL "https://lv.luzifer.io/v1/catalog/vault/latest/version")
curl -sSfLo vault.zip "https://releases.hashicorp.com/vault/${VAULT_VERSION}/vault_${VAULT_VERSION}_linux_amd64.zip"
unzip vault.zip
rm vault.zip
install -Dm0755 -t /usr/local/bin vault
# Cleanup
apt-get purge -y ${build_packages[@]}
apt-get autoremove --purge -y
rm -rf /var/lib/apt/lists/*