Skip to content

Commit

Permalink
Select apt packages to install from config.json
Browse files Browse the repository at this point in the history
  • Loading branch information
vyadh committed Sep 26, 2024
1 parent 29667cc commit 11d8d4c
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 34 deletions.
45 changes: 44 additions & 1 deletion build/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,48 @@
"user": {
"user-id": 1001,
"group-id": 121
}
},
"install": [
{
"category": "development",
"source": "apt",
"packages": [
"build-essential",
"zlib1g-dev",
"zstd",
"gettext",
"libcurl4-openssl-dev",
"libpq-dev",
"pkg-config",
"software-properties-common"
]
},
{
"category": "network-tools",
"source": "apt",
"packages": [
"inetutils-ping",
"wget",
"openssh-client",
"rsync"
]
},
{
"category": "nodejs",
"source": "apt",
"packages": [
"nodejs"
]
},
{
"category": "python",
"source": "apt",
"packages": [
"python3",
"python3-pip",
"python3-setuptools",
"python3-venv"
]
}
]
}
12 changes: 10 additions & 2 deletions build/config.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
#!/usr/bin/env bash
set -euo pipefail

function config_file() {
echo "$(dirname "${BASH_SOURCE[0]}")/config.json"
}

function user_id() {
jq -r '.user."user-id"' "$(dirname "${BASH_SOURCE[0]}")/config.json"
jq -r '.user."user-id"' "$(config_file)"
}

function group_id() {
jq -r '.user."group-id"' "$(dirname "${BASH_SOURCE[0]}")/config.json"
jq -r '.user."group-id"' "$(config_file)"
}

function apt_packages() {
jq -r '.install[] | select(.source == "apt") | .packages[]' "$(config_file)" | paste -sd ' ' -
}
46 changes: 15 additions & 31 deletions build/install_base.sh
Original file line number Diff line number Diff line change
@@ -1,43 +1,27 @@
#!/usr/bin/env bash
set -euo pipefail

function install_bootstrap() {
# Required by the build or runner operation
function install_essentials() {
apt-get install -y --no-install-recommends \
ca-certificates \
curl \
jq \
gnupg
gnupg \
tar \
unzip \
zip \
apt-transport-https \
sudo \
dirmngr \
locales \
gosu \
gpg-agent \
dumb-init
}

function install_tools_apt() {
apt-get install -y --no-install-recommends \
tar \
unzip \
zip \
apt-transport-https \
sudo \
gpg-agent \
software-properties-common \
dirmngr \
locales \
dumb-init \
gosu \
build-essential \
zlib1g-dev \
zstd \
gettext \
libcurl4-openssl-dev \
inetutils-ping \
wget \
openssh-client \
python3-pip \
python3-setuptools \
python3-venv \
python3 \
nodejs \
rsync \
libpq-dev \
pkg-config
apt_packages | xargs apt-get install -y --no-install-recommends
}

function remove_caches() {
Expand All @@ -61,7 +45,7 @@ source "$scripts_dir/tools.sh"
source "$scripts_dir/config.sh"

apt-get update
install_bootstrap
install_essentials
configure_sources

apt-get update
Expand Down

0 comments on commit 11d8d4c

Please sign in to comment.