You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by ji...@apache.org on 2018/02/12 00:01:54 UTC

[1/2] mesos git commit: Added scripts to build Mesos mini Docker container.

Repository: mesos
Updated Branches:
  refs/heads/master 934681e91 -> d4b000ff8


Added scripts to build Mesos mini Docker container.


Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/d4b000ff
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/d4b000ff
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/d4b000ff

Branch: refs/heads/master
Commit: d4b000ff8dfdf17b5681d9662d22e6d3993b1cc4
Parents: 4201071
Author: Jie Yu <yu...@gmail.com>
Authored: Sat Feb 10 10:47:58 2018 -0800
Committer: Jie Yu <yu...@gmail.com>
Committed: Sun Feb 11 16:01:47 2018 -0800

----------------------------------------------------------------------
 support/jenkins/mini.sh                     | 31 +++++++++++++
 support/mesos-mini/Dockerfile               | 56 ++++++++++++++++++++++++
 support/mesos-mini/build.sh                 | 27 ++++++++++++
 support/mesos-mini/marathon.service         | 14 ++++++
 support/mesos-mini/marathon.sh              | 23 ++++++++++
 support/mesos-mini/mesos_agent_environment  |  7 +++
 support/mesos-mini/mesos_master_environment |  3 ++
 7 files changed, 161 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/d4b000ff/support/jenkins/mini.sh
----------------------------------------------------------------------
diff --git a/support/jenkins/mini.sh b/support/jenkins/mini.sh
new file mode 100755
index 0000000..4a07181
--- /dev/null
+++ b/support/jenkins/mini.sh
@@ -0,0 +1,31 @@
+#!/usr/bin/env bash
+
+set -o errexit -o nounset -o pipefail -o verbose
+
+CURRENT_DIR="$(cd "$(dirname "$0")"; pwd -P)"
+SUPPORT_DIR="${CURRENT_DIR}/.."
+
+: ${USERNAME:?"Environment variable 'USERNAME' must be set to the username of the 'Mesos DockerBot' Docker hub account."}
+: ${PASSWORD:?"Environment variable 'PASSWORD' must be set to the password of the 'Mesos DockerBot' Docker hub account."}
+
+DOCKER_IMAGE_MINI=${DOCKER_IMAGE_MINI:-"mesos/mesos-mini"}
+DOCKER_IMAGE_PACKAGING=${DOCKER_IMAGE_PACKAGING:-"mesos/mesos-centos-packaging"}
+DOCKER_IMAGE_DISTRO=${DOCKER_IMAGE_DISTRO:-"mesos/mesos-centos"}
+DOCKER_IMAGE_TAG=`date +%F`
+
+function cleanup {
+  docker rmi $(docker images -q ${DOCKER_IMAGE_PACKAGING}:${DOCKER_IMAGE_TAG}) || true
+  docker rmi $(docker images -q ${DOCKER_IMAGE_DISTRO}:${DOCKER_IMAGE_TAG}) || true
+  docker rmi $(docker images -q ${DOCKER_IMAGE_MINI}:${DOCKER_IMAGE_TAG}) || true
+}
+
+trap cleanup EXIT
+
+DOCKER_IMAGE_MINI=${DOCKER_IMAGE_MINI} \
+DOCKER_IMAGE_PACKAGING=${DOCKER_IMAGE_PACKAGING} \
+DOCKER_IMAGE_DISTRO=${DOCKER_IMAGE_DISTRO} \
+DOCKER_IMAGE_TAG=${DOCKER_IMAGE_TAG} \
+"${SUPPORT_DIR}/mesos-mini/build.sh"
+
+docker login -u ${USERNAME} -p ${PASSWORD}
+docker push ${DOCKER_IMAGE_MINI}:${DOCKER_IMAGE_TAG}

http://git-wip-us.apache.org/repos/asf/mesos/blob/d4b000ff/support/mesos-mini/Dockerfile
----------------------------------------------------------------------
diff --git a/support/mesos-mini/Dockerfile b/support/mesos-mini/Dockerfile
new file mode 100644
index 0000000..23568a3
--- /dev/null
+++ b/support/mesos-mini/Dockerfile
@@ -0,0 +1,56 @@
+FROM mesos/mesos-centos
+
+RUN yum install -y java-1.8.0-openjdk
+
+# Prepare systemd environment.
+ENV container docker
+
+RUN (cd /lib/systemd/system/sysinit.target.wants/; for i in *; do [ $i == systemd-tmpfiles-setup.service ] || rm -f $i; done); \
+    rm -f /lib/systemd/system/multi-user.target.wants/*; \
+    rm -f /etc/systemd/system/*.wants/*; \
+    rm -f /lib/systemd/system/local-fs.target.wants/*; \
+    rm -f /lib/systemd/system/sockets.target.wants/*udev*; \
+    rm -f /lib/systemd/system/sockets.target.wants/*initctl*; \
+    rm -f /lib/systemd/system/basic.target.wants/*; \
+    rm -f /lib/systemd/system/anaconda.target.wants/*; \
+    ln -vf /lib/systemd/system/multi-user.target /lib/systemd/system/default.target
+
+RUN for service in\
+    console-getty.service\
+    dbus.service\
+    dbus.socket\
+    dev-hugepages.mount\
+    getty.target\
+    sys-fs-fuse-connections.mount\
+    systemd-logind.service\
+    systemd-remount-fs.service\
+    systemd-vconsole-setup.service\
+    ; do systemctl mask $service; done
+
+CMD ["/usr/sbin/init"]
+
+STOPSIGNAL SIGRTMIN+3
+
+# Prepare Mesos environment.
+RUN chmod +x /usr/bin/mesos-init-wrapper && \
+    rm -f /etc/mesos-master/work_dir && \
+    rm -f /etc/mesos-slave/work_dir
+
+COPY mesos_master_environment /etc/default/mesos-master
+COPY mesos_agent_environment /etc/default/mesos-agent
+
+# Prepare Marathon environment.
+ARG MARATHON_URL=https://downloads.mesosphere.com/marathon/releases/1.5.5/marathon-1.5.5.tgz
+ARG MARATHON_INSTALL_DIR=/usr/local/marathon
+
+RUN mkdir -p $MARATHON_INSTALL_DIR && \
+    curl -s $MARATHON_URL -o /marathon.tgz && \
+    tar -xzvf /marathon.tgz -C $MARATHON_INSTALL_DIR --strip 1 && \
+    rm -f /marathon.tgz
+
+COPY marathon.sh $MARATHON_INSTALL_DIR/bin/
+COPY marathon.service /usr/lib/systemd/system/marathon.service
+
+RUN systemctl enable mesos-slave && \
+    systemctl enable mesos-master && \
+    systemctl enable marathon

http://git-wip-us.apache.org/repos/asf/mesos/blob/d4b000ff/support/mesos-mini/build.sh
----------------------------------------------------------------------
diff --git a/support/mesos-mini/build.sh b/support/mesos-mini/build.sh
new file mode 100755
index 0000000..dc9c2bb
--- /dev/null
+++ b/support/mesos-mini/build.sh
@@ -0,0 +1,27 @@
+#!/usr/bin/env bash
+
+set -o errexit -o nounset -o pipefail -o verbose
+
+# This script builds a Docker image that has one master, one agent and
+# one example framework (Marathon) running.
+
+CURRENT_DIR="$(cd "$(dirname "$0")"; pwd -P)"
+SUPPORT_DIR="${CURRENT_DIR}/.."
+
+DOCKER_IMAGE_MINI=${DOCKER_IMAGE_MINI:-"mesos/mesos-mini"}
+DOCKER_IMAGE_PACKAGING=${DOCKER_IMAGE_PACKAGING:-"mesos/mesos-centos-packaging"}
+DOCKER_IMAGE_DISTRO=${DOCKER_IMAGE_DISTRO:-"mesos/mesos-centos"}
+DOCKER_IMAGE_TAG=${DOCKER_IMAGE_TAG:-"latest"}
+
+if ! [ -x "$(command -v docker)" ]; then
+  echo 'Error: docker is not installed.' >&2
+  exit 1
+fi
+
+DOCKER_IMAGE_PACKAGING=${DOCKER_IMAGE_PACKAGING} \
+DOCKER_IMAGE_DISTRO=${DOCKER_IMAGE_DISTRO} \
+DOCKER_IMAGE_TAG=${DOCKER_IMAGE_TAG} \
+"${SUPPORT_DIR}/packaging/centos/build-docker-image.sh"
+
+docker tag ${DOCKER_IMAGE_DISTRO}:${DOCKER_IMAGE_TAG} "mesos/mesos-centos"
+docker build -t ${DOCKER_IMAGE_MINI}:${DOCKER_IMAGE_TAG} "${CURRENT_DIR}/"

http://git-wip-us.apache.org/repos/asf/mesos/blob/d4b000ff/support/mesos-mini/marathon.service
----------------------------------------------------------------------
diff --git a/support/mesos-mini/marathon.service b/support/mesos-mini/marathon.service
new file mode 100644
index 0000000..906a1f7
--- /dev/null
+++ b/support/mesos-mini/marathon.service
@@ -0,0 +1,14 @@
+[Unit]
+Description=Marathon: container orchestration engine.
+
+[Service]
+Restart=always
+StartLimitInterval=0
+RestartSec=5
+LimitNOFILE=16384
+Environment="LIBPROCESS_IP=0.0.0.0"
+Environment="MARATHON_HOSTNAME=localhost"
+ExecStart=/usr/local/marathon/bin/marathon.sh
+
+[Install]
+WantedBy=multi-user.target

http://git-wip-us.apache.org/repos/asf/mesos/blob/d4b000ff/support/mesos-mini/marathon.sh
----------------------------------------------------------------------
diff --git a/support/mesos-mini/marathon.sh b/support/mesos-mini/marathon.sh
new file mode 100755
index 0000000..7234674
--- /dev/null
+++ b/support/mesos-mini/marathon.sh
@@ -0,0 +1,23 @@
+#!/usr/bin/env bash
+
+set -o errexit -o nounset -o pipefail -o verbose
+
+exec /usr/local/marathon/bin/marathon \
+    -Duser.dir=/var/lib/marathon \
+    -J-server \
+    -J-verbose:gc \
+    -J-XX:+PrintGCDetails \
+    -J-XX:+PrintGCTimeStamps \
+    --master "localhost:5050" \
+    --default_accepted_resource_roles "*" \
+    --mesos_role "marathon" \
+    --max_instances_per_offer 100 \
+    --task_launch_timeout 86400000 \
+    --decline_offer_duration 300000 \
+    --revive_offers_for_new_apps \
+    --mesos_leader_ui_url "/mesos" \
+    --enable_features "task_killing" \
+    --mesos_user "root" \
+    --mesos_authentication_principal "marathon" \
+    --internal_store_backend "mem" \
+    --disable_ha

http://git-wip-us.apache.org/repos/asf/mesos/blob/d4b000ff/support/mesos-mini/mesos_agent_environment
----------------------------------------------------------------------
diff --git a/support/mesos-mini/mesos_agent_environment b/support/mesos-mini/mesos_agent_environment
new file mode 100644
index 0000000..8390f15
--- /dev/null
+++ b/support/mesos-mini/mesos_agent_environment
@@ -0,0 +1,7 @@
+MESOS_ADVERTISE_IP=127.0.0.1
+MESOS_HOSTNAME_LOOKUP=false
+MESOS_WORK_DIR=/var/lib/mesos/agent
+MESOS_MASTER=127.0.0.1:5050
+MESOS_ISOLATION=filesystem/posix,posix/cpu,posix/mem
+MESOS_LAUNCHER=posix
+MESOS_SYSTEMD_ENABLE_SUPPORT=false

http://git-wip-us.apache.org/repos/asf/mesos/blob/d4b000ff/support/mesos-mini/mesos_master_environment
----------------------------------------------------------------------
diff --git a/support/mesos-mini/mesos_master_environment b/support/mesos-mini/mesos_master_environment
new file mode 100644
index 0000000..0382558
--- /dev/null
+++ b/support/mesos-mini/mesos_master_environment
@@ -0,0 +1,3 @@
+MESOS_ADVERTISE_IP=127.0.0.1
+MESOS_HOSTNAME_LOOKUP=false
+MESOS_WORK_DIR=/var/lib/mesos/master


[2/2] mesos git commit: Updated the docker build script for building distro in Docker.

Posted by ji...@apache.org.
Updated the docker build script for building distro in Docker.


Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/42010716
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/42010716
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/42010716

Branch: refs/heads/master
Commit: 420107161c6277830a0adbe34b93da2c277e2820
Parents: 934681e
Author: Jie Yu <yu...@gmail.com>
Authored: Fri Feb 9 17:03:17 2018 -0800
Committer: Jie Yu <yu...@gmail.com>
Committed: Sun Feb 11 16:01:47 2018 -0800

----------------------------------------------------------------------
 support/packaging/centos/build-docker-image.sh | 45 +++++++++++++--------
 1 file changed, 28 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/42010716/support/packaging/centos/build-docker-image.sh
----------------------------------------------------------------------
diff --git a/support/packaging/centos/build-docker-image.sh b/support/packaging/centos/build-docker-image.sh
index bca6ea5..6965cc0 100755
--- a/support/packaging/centos/build-docker-image.sh
+++ b/support/packaging/centos/build-docker-image.sh
@@ -1,49 +1,60 @@
 #!/usr/bin/env bash
 
+set -o errexit -o nounset -o pipefail -o verbose
+
 # This script builds a CentOS based docker image with Mesos installed
 # using the current head of the source tree.
 
 CENTOS_DIR="$(cd "$(dirname "$0")"; pwd -P)"
-SOURCE_DIR="$(cd $CENTOS_DIR/../../..; pwd -P)"
+SOURCE_DIR="$(cd ${CENTOS_DIR}/../../..; pwd -P)"
 
-BUILD_IMAGE="mesos/packaging-centos7"
-MESOS_IMAGE="mesos"
+DOCKER_IMAGE_PACKAGING=${DOCKER_IMAGE_PACKAGING:-"mesos/mesos-centos-packaging"}
+DOCKER_IMAGE_DISTRO=${DOCKER_IMAGE_DISTRO:-"mesos/mesos-centos"}
+DOCKER_IMAGE_TAG=${DOCKER_IMAGE_TAG:-"latest"}
 
 if ! [ -x "$(command -v docker)" ]; then
   echo 'Error: docker is not installed.' >&2
   exit 1
 fi
 
-if [ -d "$SOURCE_DIR/centos7" ]; then
+if [ -d "${SOURCE_DIR}/centos7" ]; then
   echo "Please cleanup 'centos7' under your Mesos source directory"
   exit 1
 fi
 
+TMP_BUILD_DIR=$(mktemp -d)
+
+function cleanup {
+  rm -rf "${TMP_BUILD_DIR}"
+  rm -rf "${SOURCE_DIR}/centos7"
+}
+
+trap cleanup EXIT
+
 # Build the image for building Mesos packages.
 docker build \
   --rm \
-  -t $BUILD_IMAGE \
-  -f $SOURCE_DIR/support/packaging/centos/centos7.dockerfile \
-  $SOURCE_DIR/support/packaging/centos/
+  -t ${DOCKER_IMAGE_PACKAGING}:${DOCKER_IMAGE_TAG} \
+  -f "${SOURCE_DIR}/support/packaging/centos/centos7.dockerfile" \
+  "${SOURCE_DIR}/support/packaging/centos/"
 
 # Build the RPM.
+USER_ID=`id -u`
+GROUP_ID=`id -g`
+
 docker run \
   --rm \
-  -v $SOURCE_DIR:$SOURCE_DIR \
-  $BUILD_IMAGE \
-  $SOURCE_DIR/support/packaging/centos/build_rpm.sh
+  -v "${SOURCE_DIR}:${SOURCE_DIR}" \
+  ${DOCKER_IMAGE_PACKAGING}:${DOCKER_IMAGE_TAG} \
+  /bin/bash -c "${SOURCE_DIR}/support/packaging/centos/build_rpm.sh && chown -R ${USER_ID}:${GROUP_ID} ${SOURCE_DIR}/centos7"
 
 # Build the image for running Mesos.
-TMP_BUILD_DIR=$(mktemp -d)
+cp "${SOURCE_DIR}"/centos7/rpmbuild/RPMS/x86_64/*.rpm "${TMP_BUILD_DIR}"
 
-cp $SOURCE_DIR/centos7/rpmbuild/RPMS/x86_64/*.rpm $TMP_BUILD_DIR
-
-cat <<EOF > $TMP_BUILD_DIR/Dockerfile
+cat <<EOF > "${TMP_BUILD_DIR}/Dockerfile"
 FROM centos:7
 ADD mesos-?.?.?-*.rpm /
 RUN yum --nogpgcheck -y localinstall /mesos-*.rpm
 EOF
 
-docker build --rm -t $MESOS_IMAGE $TMP_BUILD_DIR
-
-rm -rf $TMP_BUILD_DIR
+docker build --rm -t ${DOCKER_IMAGE_DISTRO}:${DOCKER_IMAGE_TAG} ${TMP_BUILD_DIR}