Install python packages from ubuntu's repositories
Also reduces image size by updating, installing and cleaning packages in one single step
This commit is contained in:
34
Dockerfile
34
Dockerfile
@@ -9,16 +9,7 @@ ENV SALT_VERSION="2018.3.4" \
|
|||||||
LIBSSH2_VERSION="1.8.0" \
|
LIBSSH2_VERSION="1.8.0" \
|
||||||
LIBGIT2_VERSION="0.27.7" \
|
LIBGIT2_VERSION="0.27.7" \
|
||||||
PYGIT2_VERSION="0.27.2" \
|
PYGIT2_VERSION="0.27.2" \
|
||||||
GITPYTHON_VERSION="2.1.11" \
|
M2CRYPTO_VERSION="0.31.0"
|
||||||
M2CRYPTO_VERSION="0.31.0" \
|
|
||||||
MAKO_VERSION="1.0.7" \
|
|
||||||
PYCRYPTODOME_VERSION="3.7.2" \
|
|
||||||
LIBNACL_VERSION="1.6.1" \
|
|
||||||
RAET_VERSION="0.6.8" \
|
|
||||||
CHERRYPY_VERSION="18.0.1" \
|
|
||||||
TIMELIB_VERSION="0.2.4" \
|
|
||||||
DOCKERPY_VERSION="1.10.6" \
|
|
||||||
MSGPACKPURE_VERSION="0.1.3"
|
|
||||||
|
|
||||||
ENV SALT_DOCKER_DIR="/etc/docker-salt" \
|
ENV SALT_DOCKER_DIR="/etc/docker-salt" \
|
||||||
SALT_ROOT_DIR="/etc/salt" \
|
SALT_ROOT_DIR="/etc/salt" \
|
||||||
@@ -35,24 +26,21 @@ ENV SALT_CONFS_DIR="${SALT_DATA_DIR}/config" \
|
|||||||
SALT_BASE_DIR="${SALT_DATA_DIR}/srv" \
|
SALT_BASE_DIR="${SALT_DATA_DIR}/srv" \
|
||||||
SALT_LOGS_DIR="${SALT_DATA_DIR}/logs"
|
SALT_LOGS_DIR="${SALT_DATA_DIR}/logs"
|
||||||
|
|
||||||
# Set non interactive mode
|
|
||||||
ENV DEBIAN_FRONTEND=noninteractive
|
|
||||||
|
|
||||||
RUN mkdir -p ${SALT_BUILD_DIR}
|
RUN mkdir -p ${SALT_BUILD_DIR}
|
||||||
WORKDIR ${SALT_BUILD_DIR}
|
WORKDIR ${SALT_BUILD_DIR}
|
||||||
|
|
||||||
# Install packages
|
# Install packages
|
||||||
RUN apt-get update
|
RUN apt-get update \
|
||||||
RUN apt-get install --yes --quiet --no-install-recommends \
|
&& DEBIAN_FRONTEND=noninteractive apt-get install --yes --quiet --no-install-recommends \
|
||||||
sudo ca-certificates wget locales pkg-config openssh-client \
|
sudo ca-certificates apt-transport-https wget locales pkg-config openssh-client \
|
||||||
python${PYTHON_VERSION} python${PYTHON_VERSION}-dev \
|
python${PYTHON_VERSION} python${PYTHON_VERSION}-dev \
|
||||||
python3-pip python3-setuptools python3-wheel gettext-base \
|
python3-pip python3-setuptools python3-wheel \
|
||||||
supervisor logrotate
|
supervisor logrotate git gettext-base tzdata \
|
||||||
|
&& DEBIAN_FRONTEND=noninteractive update-locale LANG=C.UTF-8 LC_MESSAGES=POSIX \
|
||||||
# Configure locales
|
|
||||||
RUN update-locale LANG=C.UTF-8 LC_MESSAGES=POSIX \
|
|
||||||
locale-gen en_US.UTF-8 \
|
locale-gen en_US.UTF-8 \
|
||||||
dpkg-reconfigure locales
|
dpkg-reconfigure locales \
|
||||||
|
&& DEBIAN_FRONTEND=noninteractive apt-get clean --yes \
|
||||||
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
# Install saltstack
|
# Install saltstack
|
||||||
COPY assets/build ${SALT_BUILD_DIR}
|
COPY assets/build ${SALT_BUILD_DIR}
|
||||||
@@ -67,8 +55,6 @@ COPY assets/runtime ${SALT_RUNTIME_DIR}
|
|||||||
RUN chmod -R +x ${SALT_RUNTIME_DIR}
|
RUN chmod -R +x ${SALT_RUNTIME_DIR}
|
||||||
|
|
||||||
# Cleaning tasks
|
# Cleaning tasks
|
||||||
RUN apt-get clean --yes
|
|
||||||
RUN rm -rf /var/lib/apt/lists/*
|
|
||||||
RUN rm -rf ${SALT_BUILD_DIR}/*
|
RUN rm -rf ${SALT_BUILD_DIR}/*
|
||||||
|
|
||||||
# Entrypoint
|
# Entrypoint
|
||||||
|
|||||||
@@ -6,11 +6,12 @@ source ${SALT_BUILD_DIR}/functions.sh
|
|||||||
|
|
||||||
# Install build dependencies
|
# Install build dependencies
|
||||||
echo "Installing dependencies ..."
|
echo "Installing dependencies ..."
|
||||||
BUILD_DEPENDENCIES="gnupg git cmake gcc g++ make \
|
BUILD_DEPENDENCIES="cmake gcc g++ make \
|
||||||
libhttp-parser-dev libssl-dev zlib1g-dev \
|
libhttp-parser-dev libssl-dev zlib1g-dev \
|
||||||
libzmq-dev libcurl4-openssl-dev libffi-dev"
|
libcurl4-openssl-dev libffi-dev swig"
|
||||||
|
|
||||||
apt-get install --yes --quiet --no-install-recommends ${BUILD_DEPENDENCIES}
|
apt-get update
|
||||||
|
DEBIAN_FRONTEND=noninteractive apt-get install --yes --quiet --no-install-recommends ${BUILD_DEPENDENCIES}
|
||||||
|
|
||||||
# Create salt user
|
# Create salt user
|
||||||
echo "Creating ${SALT_USER} user ..."
|
echo "Creating ${SALT_USER} user ..."
|
||||||
@@ -37,20 +38,6 @@ cd libgit2-${LIBGIT2_VERSION}/
|
|||||||
cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=ON -DBUILD_CLAR=OFF -DTHREADSAFE=ON .
|
cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=ON -DBUILD_CLAR=OFF -DTHREADSAFE=ON .
|
||||||
cmake --build . --target install
|
cmake --build . --target install
|
||||||
|
|
||||||
# Install python packages
|
|
||||||
echo "Installing python packages ..."
|
|
||||||
pip3 install "pygit2==v${PYGIT2_VERSION}" \
|
|
||||||
"gitpython==v${GITPYTHON_VERSION}" \
|
|
||||||
"M2Crypto==v${M2CRYPTO_VERSION}" \
|
|
||||||
"Mako==v${MAKO_VERSION}" \
|
|
||||||
"pycryptodome==v${PYCRYPTODOME_VERSION}" \
|
|
||||||
"libnacl==v${LIBNACL_VERSION}" \
|
|
||||||
"raet==v${RAET_VERSION}" \
|
|
||||||
"CherryPy==v${CHERRYPY_VERSION}" \
|
|
||||||
"timelib==v${TIMELIB_VERSION}" \
|
|
||||||
"docker-py==v${DOCKERPY_VERSION}" \
|
|
||||||
"msgpack-pure==v${MSGPACKPURE_VERSION}"
|
|
||||||
|
|
||||||
# Bootstrap script options:
|
# Bootstrap script options:
|
||||||
# https://docs.saltstack.com/en/latest/topics/tutorials/salt_bootstrap.html#command-line-options
|
# https://docs.saltstack.com/en/latest/topics/tutorials/salt_bootstrap.html#command-line-options
|
||||||
## -M: install Salt Master by default
|
## -M: install Salt Master by default
|
||||||
@@ -65,6 +52,18 @@ wget -O bootstrap-salt.sh https://bootstrap.saltstack.com
|
|||||||
sh bootstrap-salt.sh ${SALT_BOOTSTRAP_OPTS} git v${SALT_VERSION}
|
sh bootstrap-salt.sh ${SALT_BOOTSTRAP_OPTS} git v${SALT_VERSION}
|
||||||
chown -R ${SALT_USER}: ${SALT_ROOT_DIR}
|
chown -R ${SALT_USER}: ${SALT_ROOT_DIR}
|
||||||
|
|
||||||
|
# Install python3 packages
|
||||||
|
echo "Installing python3 packages ..."
|
||||||
|
DEBIAN_FRONTEND=noninteractive apt-get install --yes --quiet --no-install-recommends \
|
||||||
|
python3-mako python3-pycryptodome python3-cherrypy3 python3-git python3-u-msgpack \
|
||||||
|
python3-ioflo python3-redis python3-gnupg python3-mysqldb python3-dateutil python3-timelib \
|
||||||
|
python3-raet python3-libnacl
|
||||||
|
|
||||||
|
# Install pip3 python packages
|
||||||
|
echo "Installing pip3 python packages ..."
|
||||||
|
pip3 install "pygit2==v${PYGIT2_VERSION}" \
|
||||||
|
"M2Crypto==v${M2CRYPTO_VERSION}"
|
||||||
|
|
||||||
# Configure ssh
|
# Configure ssh
|
||||||
echo "Configuring ssh ..."
|
echo "Configuring ssh ..."
|
||||||
sed -i -e "s|^[# ]*StrictHostKeyChecking.*$| StrictHostKeyChecking no|" /etc/ssh/ssh_config
|
sed -i -e "s|^[# ]*StrictHostKeyChecking.*$| StrictHostKeyChecking no|" /etc/ssh/ssh_config
|
||||||
@@ -111,3 +110,7 @@ autorestart=true
|
|||||||
stdout_logfile=${SALT_LOGS_DIR}/supervisor/%(program_name)s.log
|
stdout_logfile=${SALT_LOGS_DIR}/supervisor/%(program_name)s.log
|
||||||
stderr_logfile=${SALT_LOGS_DIR}/supervisor/%(program_name)s.log
|
stderr_logfile=${SALT_LOGS_DIR}/supervisor/%(program_name)s.log
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
|
# purge build dependencies and cleanup apt
|
||||||
|
DEBIAN_FRONTEND=noninteractive apt-get clean --yes
|
||||||
|
rm -rf /var/lib/apt/lists/*
|
||||||
|
|||||||
Reference in New Issue
Block a user