Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add db-client scripts #74

Merged
merged 3 commits into from
Nov 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions docker_atom/work/script-setup-db-clients.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
source /opt/utils/script-utils.sh


setup_postgresql_client() {
local VER_PG=${VERSION_PG:-"14"}
# from: https://www.postgresql.org/download/linux/ubuntu/
echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list
curl https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
sudo apt-get update
# will download ~9MB files and use ~55MB disk after installation
sudo apt-get -y install "postgresql-client-${VER_PG}"
echo "@ Version of psql client: $(psql --version)"
}


setup_mysql_client() {
sudo apt-get update
# will download ~5MB files and use ~76MB disk after installation
sudo apt-get -y install mysql-client
echo "@ Version of mysql client: $(mysql --version)"
}


setup_mongosh_client() {
# from: https://www.mongodb.com/docs/mongodb-shell/install/
echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu $(lsb_release -cs)/mongodb-org/6.0 multiverse" > /etc/apt/sources.list.d/mongodb-org-6.0.list
curl -sL https://www.mongodb.org/static/pgp/server-6.0.asc | sudo apt-key add -
sudo apt-get update
# will download ~38MB files and use ~218MB disk after installation
sudo apt-get -y install mongodb-mongosh
echo "@ Version of mongosh client: $(mongosh --version)"
}


setup_redis_client() {
# from https://redis.io/docs/getting-started/installation/install-redis-on-linux/
curl -fsSL https://packages.redis.io/gpg | sudo gpg --dearmor -o /usr/share/keyrings/redis-archive-keyring.gpg
echo "deb [signed-by=/usr/share/keyrings/redis-archive-keyring.gpg] https://packages.redis.io/deb $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/redis.list
sudo apt-get update
sudo apt-get -y install redis-tools
echo "@ Version of redis-cli: $(redis-cli --version)"
}
7 changes: 4 additions & 3 deletions docker_atom/work/script-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ trusted-host=pypi.python.org pypi.org files.pythonhosted.org
EOF
fi

echo "export PATH=$PATH:${CONDA_PREFIX}/bin" >> /etc/profile
echo 'export PATH=${PATH}:${CONDA_PREFIX:-"/opt/conda"}/bin' >> /etc/profile
ln -sf "${CONDA_PREFIX}/bin/conda" /usr/bin/

conda config --system --prepend channels conda-forge \
Expand All @@ -53,9 +53,10 @@ EOF
}

setup_conda_with_mamba() {
mkdir -pv "${CONDA_PREFIX}"
local PREFIX="${CONDA_PREFIX:-/opt/conda}"
mkdir -pv "${PREFIX}"
VERSION_PYTHON=${1:-"3.10"}; shift 1;
mamba install -y --root-prefix="${CONDA_PREFIX}" --prefix="${CONDA_PREFIX}" -c "conda-forge" conda pip python="${VERSION_PYTHON}"
mamba install -y --root-prefix="${PREFIX}" --prefix="${PREFIX}" -c "conda-forge" conda pip python="${VERSION_PYTHON}"
setup_conda_postprocess
}

Expand Down
16 changes: 8 additions & 8 deletions docker_atom/work/script-utils.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ set -x
install_echo() { cat $1 | cut -d "%" -f 1 | sed '/^$/d' | xargs -r -n1 printf '%s\n' ; }

# function to install apt-get packages from a text file which lists package names (add comments with % char)
install_apt() { apt-get -qq update -yq --fix-missing && apt-get -qq install -yq --no-install-recommends `cat $1 | cut -d '%' -f 1` ; }
install_apt() { apt-get -qq update -yq --fix-missing && apt-get -qq install -yq --no-install-recommends $(cat "$1" | cut -d '%' -f 1) ; }

# function to install conda packages from a text file which lists package names (add comments with % char)
install_conda() { cat $1 | cut -d "%" -f 1 | sed '/^$/d' | xargs -r -n1 conda install -yq ; }
Expand Down Expand Up @@ -44,8 +44,8 @@ install_mvn() { cat $1 | cut -d "%" -f 1 | xargs -r -n1 -I {} mvn dependency:cop
install__clean(){
which apt-get && apt-get autoremove -y && apt-get clean && rm -rf /var/lib/apt/lists/*
which mamba && mamba clean -ya && rm -rf ~/micromamba
which conda && conda clean -ya && ( rm -rf /opt/conda/pkgs/* || true )
find /opt/conda/lib | grep -E "(__pycache__|\.pyc|\.pyo$)" | xargs rm -rf
which conda && conda clean -ya && ( rm -rf "${CONDA_PREFIX:-/opt/conda}"/pkgs/* || true )
find "${CONDA_PREFIX:-/opt/conda}"/lib | grep -E "(__pycache__|\.pyc|\.pyo$)" | xargs rm -rf
which npm && npm cache clean --force
rm -rf /opt/conda/share/jupyter/lab/staging
( rm -rf /tmp/.* /tmp/* /var/log/* /var/cache/* /root/.cache /root/.* || true )
Expand All @@ -72,21 +72,21 @@ list_installed_packages() {
}

fix_permission() {
DIRECTORY=$1; GROUP_ID=$2; shift 2;
for d in "$DIRECTORY"; do
GROUP_ID=${1:-0}; shift 1;
for d in "$@"; do
find "${d}" \
! \( \
-group "${GROUP_ID}" \
-a -perm -g+rwX \
\) \
-exec chgrp "${GROUP_ID}" {} \; \
-exec chmod g+rwX {} \;
-exec chgrp "${GROUP_ID}" -- {} \+ \
-exec chmod g+rwX -- {} \+
# setuid, setgid *on directories only*
find "${d}" \
\( \
-type d \
-a ! -perm -6000 \
\) \
-exec chmod +6000 {} \;
-exec chmod +6000 -- {} \+;
done
}
1 change: 1 addition & 0 deletions docker_base/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ RUN source /opt/utils/script-setup.sh \
&& echo "Install tini:" && setup_tini \
&& echo "Install Mamba:" && setup_mamba \
&& echo "Install Python ${PYTHON_VERSION} and conda:" && setup_conda_with_mamba ${PYTHON_VERSION} \
&& fix_permission 0 ${CONDA_PREFIX} \
&& echo "Replace system Python3 with conda Python - note that /bin and /sbin are symlinks of /usr/bin in docker image ubuntu" \
&& PYTHON_VERSION_DEFAULT=$(py3versions -v -i) \
&& sed -i "s/${PYTHON_VERSION_DEFAULT}/${PYTHON_VERSION}/g" /usr/share/python3/debian_defaults \
Expand Down
3 changes: 3 additions & 0 deletions docker_cuda/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ FROM ${BASE_NAMESPACE:+$BASE_NAMESPACE/}${BASE_IMG}

LABEL maintainer="haobibo@gmail.com"

# Let NVIDIA docker ignore cuda requirement check
ENV NVIDIA_DISABLE_REUIRE=1

# For cuda version 10.0, the image is solely serverd for legacy tensorflow 1.15, which requires python 3.7
# For tensorflow 2.x or torch, python>=3.9 is supported.
RUN echo ${CUDA_VERSION} && nvcc --version \
Expand Down