mirror of
https://github.com/1C-Company/docker_fresh.git
synced 2024-12-12 10:45:25 +02:00
9e409bd5fe
Адаптировали для развертывания на платформах 8.3.20+ * renew serts (#27) * renew sert * Добавил описание развертывания с учетом расширения БТС #21 * renew sert * renew sert * renew sert * renew sert * renew sert * renew sert * renew sert * renew sert * renew sert * renew sert * renew sert * renew sert * renew sert * init (#28) Co-authored-by: WizaXxX <wizax01@gmail.com> Co-authored-by: WizaXxX <wizax01@gmail.com>
92 lines
2.6 KiB
Python
92 lines
2.6 KiB
Python
import subprocess
|
|
import sys
|
|
import platform
|
|
from datetime import datetime
|
|
|
|
import modules.site as site
|
|
import modules.centos as centos
|
|
import modules.db as db
|
|
import modules.forum as forum
|
|
import modules.core as core
|
|
import modules.gate as gate
|
|
|
|
class colors:
|
|
GREEN = '\033[92m'
|
|
WHITE = '\033[97m'
|
|
RED = '\033[91m'
|
|
|
|
def get_docker_image_command():
|
|
if platform.system().lower() == 'windows':
|
|
return ['docker', 'images']
|
|
else:
|
|
return ['docker images']
|
|
|
|
def image_exist(image_name):
|
|
full_image_name = 'fresh/' + image.name
|
|
result = subprocess.run(get_docker_image_command(), shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
|
|
|
return full_image_name in str(result.stdout)
|
|
|
|
if '-v' not in sys.argv:
|
|
print('parameter -v not specified')
|
|
exit(1)
|
|
else:
|
|
platform_ver = sys.argv[sys.argv.index('-v') + 1]
|
|
is_new_path_to_platform = int(platform_ver.split('.')[2]) >= 20
|
|
|
|
images = []
|
|
images.append(centos.New())
|
|
images.append(db.New())
|
|
images.append(site.New())
|
|
images.append(forum.New())
|
|
images.append(core.New(is_new_path_to_platform))
|
|
images.append(gate.New())
|
|
|
|
debug = '-debug' in sys.argv
|
|
|
|
start_time = datetime.now()
|
|
print('{}Build is starting{}'.format(colors.GREEN, colors.WHITE))
|
|
|
|
if debug:
|
|
stdout = None
|
|
stderr = None
|
|
else:
|
|
stdout = subprocess.PIPE
|
|
stderr = subprocess.PIPE
|
|
|
|
for image in images:
|
|
|
|
print('Building', image.name, '...', end='\r')
|
|
|
|
for command in image.commands_before:
|
|
if debug: print(command)
|
|
subprocess.call(' '.join(command), shell=True, stdout=stdout, stderr=stderr)
|
|
|
|
command_to_run = [
|
|
'docker',
|
|
'build',
|
|
'-t',
|
|
'fresh/' + image.name]
|
|
|
|
if image.name == 'core' and is_new_path_to_platform:
|
|
command_to_run.append('-f')
|
|
command_to_run.append('images/' + image.name + '/Dockerfile_20')
|
|
command_to_run.append('--build-arg')
|
|
command_to_run.append('DISTR_VERSION=' + platform_ver)
|
|
command_to_run.append('images/' + image.name)
|
|
|
|
result = subprocess.run(command_to_run, stdout=stdout, stderr=stderr)
|
|
|
|
if result.returncode != 0 or not image_exist(image.name):
|
|
print('Building', image.name , '...', '{}error'.format(colors.RED), colors.WHITE)
|
|
exit(1)
|
|
|
|
for command in image.commands_after:
|
|
if debug: print(command)
|
|
subprocess.call(' '.join(command), shell=True, stdout=stdout, stderr=stderr)
|
|
|
|
print('Building', image.name , '...', '{}done'.format(colors.GREEN), colors.WHITE)
|
|
|
|
end_time = datetime.now() - start_time
|
|
print('{}Build finished{}'.format(colors.GREEN, colors.WHITE), 'Duration:', end_time)
|