You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dlab.apache.org by dm...@apache.org on 2019/04/26 15:39:42 UTC
[incubator-dlab] 01/01: [DLAB-docker-script] Created script that
rebuilds docker images on ssn
This is an automated email from the ASF dual-hosted git repository.
dmysakovets pushed a commit to branch docker-script
in repository https://gitbox.apache.org/repos/asf/incubator-dlab.git
commit 6ce69645628409d89016d0cabc48b8cb0aba9b91
Author: Dyoma33 <de...@gmail.com>
AuthorDate: Fri Apr 26 18:39:26 2019 +0300
[DLAB-docker-script] Created script that rebuilds docker images on ssn
---
.../src/ssn/scripts/configure_ssn_node.py | 14 ++++-
.../src/ssn/templates/docker_build.py | 71 ++++++++++++++++++++++
2 files changed, 84 insertions(+), 1 deletion(-)
diff --git a/infrastructure-provisioning/src/ssn/scripts/configure_ssn_node.py b/infrastructure-provisioning/src/ssn/scripts/configure_ssn_node.py
index b9247b8..5fa353e 100644
--- a/infrastructure-provisioning/src/ssn/scripts/configure_ssn_node.py
+++ b/infrastructure-provisioning/src/ssn/scripts/configure_ssn_node.py
@@ -136,6 +136,15 @@ def configure_ssl_certs(hostname, custom_ssl_cert):
print('Failed to configure SSL certificates: ', str(err))
sys.exit(1)
+def docker_build_script()
+ try:
+ put('/root/templates/docker_build.py', 'docker_build')
+ sudo('chmod +x docker_build')
+ sudo('mv docker_build /usr/bin/docker_build')
+ except Exception as err:
+ traceback.print_exc()
+ print('Failed to configure docker_build script: ', str(err))
+ sys.exit(1)
##############
# Run script #
@@ -192,4 +201,7 @@ if __name__ == "__main__":
cp_gitlab_scripts(args.dlab_path)
print("Ensuring safest ssh ciphers")
- ensure_ciphers()
\ No newline at end of file
+ ensure_ciphers()
+
+ print("Configuring docker_build script")
+ docker_build_script()
\ No newline at end of file
diff --git a/infrastructure-provisioning/src/ssn/templates/docker_build.py b/infrastructure-provisioning/src/ssn/templates/docker_build.py
new file mode 100644
index 0000000..5d0f30b
--- /dev/null
+++ b/infrastructure-provisioning/src/ssn/templates/docker_build.py
@@ -0,0 +1,71 @@
+#!/usr/bin/python
+
+# *****************************************************************************
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+# ******************************************************************************
+
+
+from fabric.api import *
+import sys
+import os
+import traceback
+
+src_path = '/opt/dlab/sources/infrastructure-provisioning/src/'
+node = [
+ 'edge',
+ 'jupyter',
+ 'rstudio',
+ 'zeppelin',
+ 'tensor',
+ 'tensor-rstudio',
+ 'deeplearning',
+ 'dataengine'
+ ] #for building the certain image just comment unnecessary nodes
+ #you can also comment line 57 if you don't need to rebuild ssn image
+
+
+def image_build(src_path, node):
+ try:
+ if local("cat /etc/lsb-release | grep DISTRIB_ID | awk -F '=' '{print $2}'", capture=True).stdout == 'Ubuntu':
+ os_family = 'debian'
+ else:
+ os_family = 'redhat'
+ if local("uname -r | awk -F '-' '{print $3}'", capture=True).stdout == 'aws':
+ cloud_provider = 'aws'
+ elif local("uname -r | awk -F '-' '{print $3}'", capture=True).stdout == 'azure':
+ cloud_provider = 'azure'
+ local('cp /home/dlab-user/keys/azure_auth.json {}base/azure_auth.json'.format(src_path))
+ else:
+ cloud_provider = 'gcp'
+ with lcd(src_path):
+ local('docker build --build-arg OS={0} --build-arg SRC_PATH= --file general/files/{1}/base_Dockerfile -t docker.dlab-base:latest .'.format(os_family, cloud_provider))
+ try:
+ for i in range(len(node)):
+ local('docker build --build-arg OS={0} --file general/files/{1}/{2}_Dockerfile -t docker.dlab-{2} .'.format(os_family, cloud_provider, node[i]))
+ except Exception as err:
+ print("Failed to build {} image".format(node[i]), str(err))
+ raise Exception
+ except Exception as err:
+ traceback.print_exc()
+ sys.exit(1)
+
+
+if __name__ == "__main__":
+ image_build(src_path, node)
\ No newline at end of file
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@dlab.apache.org
For additional commands, e-mail: commits-help@dlab.apache.org