Add support for pygit2

This commit is contained in:
Carlos Álvaro
2018-11-07 22:42:56 +01:00
parent 1bb94cac4e
commit 2f701fbef8
3 changed files with 39 additions and 5 deletions

View File

@@ -5,7 +5,11 @@ LABEL description="SaltStack master"
LABEL version="2018.3.3"
# https://github.com/saltstack/salt/releases
ENV SALT_VERSION="2018.3.3"
ENV SALT_VERSION="2018.3.3" \
PYTHON_VERSION="3.5" \
LIBSSH2_VERSION="1.8.0" \
LIBGIT2_VERSION="0.27.7" \
PYGIT2_VERSION="0.27.2"
ENV SALT_DOCKER_DIR="/etc/docker-salt" \
SALT_ROOT_DIR="/etc/salt" \
@@ -29,8 +33,9 @@ WORKDIR ${SALT_BUILD_DIR}
# Install packages
RUN apt-get update
RUN apt-get install --yes --quiet --no-install-recommends \
ca-certificates wget apt-transport-https git locales \
openssh-client python3 python-git
ca-certificates wget locales pkg-config openssh-client \
python${PYTHON_VERSION} python${PYTHON_VERSION}-dev \
python3-pip python3-setuptools python3-wheel
# Configure locales
RUN update-locale LANG=C.UTF-8 LC_MESSAGES=POSIX \

View File

@@ -2,6 +2,34 @@
set -e
# Install build dependencies
echo "Installing dependencies ..."
BUILD_DEPENDENCIES="gnupg git cmake gcc g++ make \
libhttp-parser-dev libssl-dev zlib1g-dev \
libzmq-dev libcurl4-openssl-dev libffi-dev"
apt-get install --yes --quiet --no-install-recommends ${BUILD_DEPENDENCIES}
# Compile libssh2
echo "Building libssh2 v${LIBSSH2_VERSION} ..."
wget https://github.com/libssh2/libssh2/archive/libssh2-${LIBSSH2_VERSION}.tar.gz
tar xzf libssh2-${LIBSSH2_VERSION}.tar.gz
cd libssh2-libssh2-${LIBSSH2_VERSION}/
cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=ON -DENABLE_ZLIB_COMPRESSION=ON .
cmake --build . --target install
# Compile libgit2
echo "Building libgit2 v${LIBGIT2_VERSION} ..."
wget https://github.com/libgit2/libgit2/archive/v${LIBGIT2_VERSION}.tar.gz
tar xzf v${LIBGIT2_VERSION}.tar.gz
cd libgit2-${LIBGIT2_VERSION}/
cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=ON -DBUILD_CLAR=OFF -DTHREADSAFE=ON .
cmake --build . --target install
# Install python packages
echo "Installing python packages ..."
pip3 install "pygit2==v${PYGIT2_VERSION}" gitpython
# Salt user
echo "Creating ${SALT_USER} user ..."
useradd -d ${SALT_HOME} -ms /bin/bash -U -G root,sudo ${SALT_USER}
@@ -13,7 +41,7 @@ useradd -d ${SALT_HOME} -ms /bin/bash -U -G root,sudo ${SALT_USER}
## -X: Do not start daemons after installation
## -P: Allow pip based installations
## -x: Changes the python version used to install a git version of salt
SALT_BOOTSTRAP_OPTS='-M -N -X -P -x python3'
SALT_BOOTSTRAP_OPTS="-M -N -X -P -x python${PYTHON_VERSION}"
echo "Installing saltstack ..."
wget -O bootstrap-salt.sh https://bootstrap.saltstack.com

View File

@@ -64,7 +64,7 @@ EOF
salt-key --gen-signature --auto-create --pub ${SALT_KEYS_DIR}/master.pub --signature-path ${SALT_KEYS_DIR}
fi
for pub_key in $(find ${SALT_KEYS_DIR} -type f -maxdepth 2); do
for pub_key in $(find ${SALT_KEYS_DIR} -type f -maxdepth 1); do
if [[ ${pub_key} =~ .*\.pem$ ]]; then
chmod 400 ${pub_key}
else
@@ -72,6 +72,7 @@ EOF
fi
done
find ${SALT_KEYS_DIR}/minions* -type f -maxdepth 1 -exec chmod 644 {} \;
find ${SALT_HOME} -path ${SALT_KEYS_DIR}/\* -prune -o -print0 | xargs -0 chown -h ${SALT_USER}:
}