Skip to content

Commit

Permalink
Fix postgresql client versions mismatch & refactor base script (#149)
Browse files Browse the repository at this point in the history
* fix(base): make pgsql client version consistent across images

* refactor(base): install binaries through individual scripts

* fix name

* add gnupg2

* add lsb-core
  • Loading branch information
avouacr authored Oct 25, 2023
1 parent ee80b38 commit 18a466d
Show file tree
Hide file tree
Showing 10 changed files with 74 additions and 34 deletions.
46 changes: 13 additions & 33 deletions base/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -29,57 +29,37 @@ USER root
COPY scripts/ /opt/

RUN chmod -R +x /opt/ && \
# Install essential system libraries
/opt/install-system-libs.sh && \
apt-get upgrade -y && \
# Make sudo passwordless
echo 'onyxia ALL=(ALL) NOPASSWD: ALL' >> /etc/sudoers && \
# Generate locales
locale-gen en_US.UTF-8 && \
## Install common binaries required for Onyxia
## Install common clients required for Onyxia
# kubectl
curl -LO https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl && \
chmod +x ./kubectl && \
mv ./kubectl /usr/local/bin/kubectl && \
/opt/install-kubectl.sh && \
echo 'source <(kubectl completion bash)' >> /home/${USERNAME}/.bashrc && \
# kubectl krew plugin
set -x && \
TMPDIR="$(mktemp -d)" && \
cd $TMPDIR && \
OS="$(uname | tr '[:upper:]' '[:lower:]')" && \
ARCH="$(uname -m | sed -e 's/x86_64/amd64/' -e 's/\(arm\)\(64\)\?.*/\1\2/' -e 's/aarch64$/arm64/')" && \
KREW="krew-${OS}_${ARCH}" && \
curl -fsSLO "https://github.com/kubernetes-sigs/krew/releases/latest/download/${KREW}.tar.gz" && \
tar zxvf "${KREW}.tar.gz" && \
./"${KREW}" install krew && \
cd ${WORKSPACE_DIR} && \
rm -rf $TMPDIR && \
/opt/install-kubectl-krew.sh && \
echo 'export PATH="${KREW_ROOT:-$HOME/.krew}/bin:$PATH"' >> /home/${USERNAME}/.bashrc && \
# helm
curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3 && \
chmod +x get_helm.sh && \
./get_helm.sh && \
/opt/install-helm.sh && \
echo 'source <(helm completion bash)' >> /home/${USERNAME}/.bashrc && \
# mc
wget -q https://dl.min.io/client/mc/release/linux-amd64/mc -O /usr/local/bin/mc && \
chmod +x /usr/local/bin/mc && \
# vault
VAULT_LATEST_VERSION=$(curl --silent "https://api.github.com/repos/hashicorp/vault/releases/latest" | grep -Po '"tag_name": "v\K.*?(?=")') && \
wget -q https://releases.hashicorp.com/vault/${VAULT_LATEST_VERSION}/vault_${VAULT_LATEST_VERSION}_linux_amd64.zip -O vault.zip && \
unzip vault.zip -d /usr/local/bin/ && \
vault -autocomplete-install && \
# minio cli
/opt/install-mc.sh && \
# vault cli
/opt/install-vault-cli.sh && \
# argo-workflows cli
curl -sLO https://github.com/argoproj/argo-workflows/releases/latest/download/argo-linux-amd64.gz && \
gunzip argo-linux-amd64.gz && \
chmod +x argo-linux-amd64 && \
mv ./argo-linux-amd64 /usr/local/bin/argo && \
/opt/install-argo-workflows-cli.sh && \
# postgresql cli
/opt/install-postgresql-cli.sh && \
# duckdb cli
wget -q https://github.com/duckdb/duckdb/releases/latest/download/duckdb_cli-linux-amd64.zip && \
unzip duckdb_cli-linux-amd64.zip -d /usr/local/bin/ && \
/opt/install-duckdb-cli.sh && \
# Fix permissions
chown -R ${USERNAME}:${GROUPNAME} ${HOME} && \
chmod +x /opt/onyxia-init.sh && \
# Clean
rm get_helm.sh vault.zip duckdb_cli-linux-amd64.zip && \
rm -rf /var/lib/apt/lists/*

# Set locales
Expand Down
7 changes: 7 additions & 0 deletions scripts/install-argo-workflows-cli.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash
set -e

curl -sLO https://github.com/argoproj/argo-workflows/releases/latest/download/argo-linux-amd64.gz
gunzip argo-linux-amd64.gz
chmod +x argo-linux-amd64
mv ./argo-linux-amd64 /usr/local/bin/argo
6 changes: 6 additions & 0 deletions scripts/install-duckdb-cli.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash
set -e

wget -q https://github.com/duckdb/duckdb/releases/latest/download/duckdb_cli-linux-amd64.zip
unzip duckdb_cli-linux-amd64.zip -d /usr/local/bin/
rm duckdb_cli-linux-amd64.zip
7 changes: 7 additions & 0 deletions scripts/install-helm.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash
set -e

curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3
chmod +x get_helm.sh
./get_helm.sh
rm get_helm.sh
13 changes: 13 additions & 0 deletions scripts/install-kubectl-krew.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash
set -e

TMPDIR="$(mktemp -d)"
cd $TMPDIR
OS="$(uname | tr '[:upper:]' '[:lower:]')"
ARCH="$(uname -m | sed -e 's/x86_64/amd64/' -e 's/\(arm\)\(64\)\?.*/\1\2/' -e 's/aarch64$/arm64/')"
KREW="krew-${OS}_${ARCH}"
curl -fsSLO "https://github.com/kubernetes-sigs/krew/releases/latest/download/${KREW}.tar.gz"
tar zxvf "${KREW}.tar.gz"
./"${KREW}" install krew
cd ..
rm -rf $TMPDIR
6 changes: 6 additions & 0 deletions scripts/install-kubectl.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash
set -e

curl -LO https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl
chmod +x ./kubectl
mv ./kubectl /usr/local/bin/kubectl
5 changes: 5 additions & 0 deletions scripts/install-mc.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash
set -e

wget -q https://dl.min.io/client/mc/release/linux-amd64/mc -O /usr/local/bin/mc
chmod +x /usr/local/bin/mc
7 changes: 7 additions & 0 deletions scripts/install-postgresql-cli.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash
set -e

echo "deb https://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
apt-get update
apt-get -y install postgresql-client
3 changes: 2 additions & 1 deletion scripts/install-system-libs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,13 @@ apt_install \
ca-certificates \
curl \
git \
gnupg2 \
jq \
less \
locales \
lsb-core \
nano \
openssh-client \
postgresql-client \
sudo \
tini \
unzip \
Expand Down
8 changes: 8 additions & 0 deletions scripts/install-vault-cli.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash
set -e

VAULT_LATEST_VERSION=$(curl --silent "https://api.github.com/repos/hashicorp/vault/releases/latest" | grep -Po '"tag_name": "v\K.*?(?=")')
wget -q https://releases.hashicorp.com/vault/${VAULT_LATEST_VERSION}/vault_${VAULT_LATEST_VERSION}_linux_amd64.zip -O vault.zip
unzip vault.zip -d /usr/local/bin/
vault -autocomplete-install
rm vault.zip

0 comments on commit 18a466d

Please sign in to comment.