From ac9b1bb3cdb70a2cec58ef3ff751360362d0bd7f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20=C3=81lvaro?= Date: Sat, 23 Feb 2019 17:07:00 +0100 Subject: [PATCH] Install python packages from ubuntu's repositories Also reduces image size by updating, installing and cleaning packages in one single step --- Dockerfile | 34 ++++++++++------------------------ assets/build/install.sh | 37 ++++++++++++++++++++----------------- 2 files changed, 30 insertions(+), 41 deletions(-) diff --git a/Dockerfile b/Dockerfile index ea7b45d..313a951 100644 --- a/Dockerfile +++ b/Dockerfile @@ -9,16 +9,7 @@ ENV SALT_VERSION="2018.3.4" \ LIBSSH2_VERSION="1.8.0" \ LIBGIT2_VERSION="0.27.7" \ PYGIT2_VERSION="0.27.2" \ - GITPYTHON_VERSION="2.1.11" \ - 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" + M2CRYPTO_VERSION="0.31.0" ENV SALT_DOCKER_DIR="/etc/docker-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_LOGS_DIR="${SALT_DATA_DIR}/logs" -# Set non interactive mode -ENV DEBIAN_FRONTEND=noninteractive - RUN mkdir -p ${SALT_BUILD_DIR} WORKDIR ${SALT_BUILD_DIR} # Install packages -RUN apt-get update -RUN apt-get install --yes --quiet --no-install-recommends \ - sudo ca-certificates wget locales pkg-config openssh-client \ +RUN apt-get update \ + && DEBIAN_FRONTEND=noninteractive apt-get install --yes --quiet --no-install-recommends \ + sudo ca-certificates apt-transport-https wget locales pkg-config openssh-client \ python${PYTHON_VERSION} python${PYTHON_VERSION}-dev \ - python3-pip python3-setuptools python3-wheel gettext-base \ - supervisor logrotate - -# Configure locales -RUN update-locale LANG=C.UTF-8 LC_MESSAGES=POSIX \ + python3-pip python3-setuptools python3-wheel \ + supervisor logrotate git gettext-base tzdata \ + && DEBIAN_FRONTEND=noninteractive update-locale LANG=C.UTF-8 LC_MESSAGES=POSIX \ 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 COPY assets/build ${SALT_BUILD_DIR} @@ -67,8 +55,6 @@ COPY assets/runtime ${SALT_RUNTIME_DIR} RUN chmod -R +x ${SALT_RUNTIME_DIR} # Cleaning tasks -RUN apt-get clean --yes -RUN rm -rf /var/lib/apt/lists/* RUN rm -rf ${SALT_BUILD_DIR}/* # Entrypoint diff --git a/assets/build/install.sh b/assets/build/install.sh index e7389c6..cc1753d 100755 --- a/assets/build/install.sh +++ b/assets/build/install.sh @@ -6,11 +6,12 @@ source ${SALT_BUILD_DIR}/functions.sh # Install build 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 \ - 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 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 --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: # https://docs.saltstack.com/en/latest/topics/tutorials/salt_bootstrap.html#command-line-options ## -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} 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 echo "Configuring ssh ..." 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 stderr_logfile=${SALT_LOGS_DIR}/supervisor/%(program_name)s.log EOF + +# purge build dependencies and cleanup apt +DEBIAN_FRONTEND=noninteractive apt-get clean --yes +rm -rf /var/lib/apt/lists/*