1
0
mirror of https://github.com/1C-Company/docker_fresh.git synced 2024-12-04 10:24:48 +02:00

add other images

This commit is contained in:
WizaXxX 2020-04-05 18:07:02 +03:00
parent 10664a9f6d
commit ea396bb2da
16 changed files with 447 additions and 28 deletions

33
images/core/Dockerfile Normal file
View File

@ -0,0 +1,33 @@
FROM fresh/centos
ADD ./distr/*.rpm /tmp/core/
RUN yum -y localinstall /tmp/core/*.rpm; \
rm -rf /tmp/core; \
sed -i '/User apache/ s//User usr1cv8/g' /etc/httpd/conf/httpd.conf; \
sed -i '/Group apache/ s//Group grp1cv8/g' /etc/httpd/conf/httpd.conf; \
sed -i '/#ServerName www.example.com:80/ s//ServerName localhost/g' /etc/httpd/conf/httpd.conf; \
yum -y install x11vnc metacity net-tools gdb perl tar git jq; \
yum -y install https://centos7.iuscommunity.org/ius-release.rpm; \
yum -y --setopt=tsflags=nodocs install python36u python36u-devel python36u-pip; \
cert-sync /etc/pki/tls/certs/ca-bundle.crt; \
oscript /usr/share/oscript/lib/opm/src/cmd/opm.os install deployka; \
chmod +x /usr/bin/deployka
ADD ./conf/conf.cfg /opt/1C/v8.3/x86_64/conf/
ADD ./conf/logcfg.xml /opt/1C/v8.3/x86_64/conf/
ENV COREDATA /var/lib/1c/data
ENV CORELOGS /var/log/1c
ENV AGENTBASEDIR /var/lib/1c/agent_data
ENV INFOBASECONNECTIONSTRING ""
VOLUME ["${COREDATA}", "${CORELOGS}", "${AGENTBASEDIR}"]
ADD ./entrypoint.sh /
RUN chmod +x /entrypoint.sh
ADD ./dumper.py /usr/bin/dumper
RUN chmod +x /usr/bin/dumper
ENTRYPOINT ["/entrypoint.sh"]

View File

@ -0,0 +1,2 @@
SystemLanguage=System
DisableUnsafeActionProtection=.*

View File

@ -0,0 +1,9 @@
<config xmlns="http://v8.1c.ru/v8/tech-log">
<log location="/var/log/1c" history="1">
<event>
<eq property="name" value="EXCP"/>
</event>
<property name="all">
</property>
</log>
</config>

2
images/core/distr/.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
*
!.gitignore

174
images/core/dumper.py Normal file
View File

@ -0,0 +1,174 @@
#!/usr/bin/python3
# -*- coding: utf-8 -*-
import glob
import re
import os
import sys
import subprocess
import urllib
import json
import time
import uuid
# define regexps
regex_process_pid = re.compile(r'/([^/.]+?)\.(\d+?)\.(\d+?)\.core')
regex_offset = re.compile(r'#0\s+?([\dxa-f]+?)\s')
regex_extension_replacement = re.compile(r'\.zip$')
regex_extension_replacement2 = re.compile(r'\.core$')
# BEGIN helper functions------------------------------------------------------------------------------------------------
def write_to_log(msg):
msg = time.ctime() + ' ' + msg
print(msg)
def run_shell(cmd):
pipe = subprocess.PIPE
p = subprocess.Popen(cmd, shell=True, stdin=pipe, stdout=pipe, stderr=pipe, close_fds=True, cwd='/')
return p.stdout.read(), p.stderr.read()
def run_shell_get_result(cmd):
result = subprocess.call(cmd, shell=True)
return result
def check_size_static(core_file):
size_1 = os.path.getsize(core_file)
time.sleep(5)
size_2 = os.path.getsize(core_file)
return size_1 == size_2
# END helper functions--------------------------------------------------------------------------------------------------
# BEGIN prepare date----------------------------------------------------------------------------------------------------
def get_pid_process_ctime(core_file):
rez = regex_process_pid.search(core_file)
process = rez.groups()[0]
ctime = rez.groups()[1]
pid = rez.groups()[2]
return process, ctime, pid
def get_platform_offset(core_file, process):
# run gdb for getting offset of core
cmd = 'echo -e "bt\nexit" | gdb /opt/1C/v8.3/x86_64/' + process + ' ' + core_file
(gdb_result, gdb_error) = run_shell(cmd)
if not gdb_result:
offset = '000000000000'
platform = '8.3.0.0000'
write_to_log('cant work with gdb: ' + gdb_error)
else:
rez = regex_offset.search(gdb_result)
if rez is None:
offset = '000000000000'
else:
offset = rez.groups()[0]
offset = offset[6:-1]
# getting platform version
cmd = 'strings /opt/1C/v8.3/x86_64/' + process + """ | grep -oP '[8-9]\.[3-90]\.\d\d?\.\d{2,4}' """
(ver_result, ver_error) = run_shell(cmd)
if ver_result:
platform = ver_result.strip()
else:
platform = '8.3.0.0000'
return platform, offset
def get_creation_date_string(ctime):
ctime_sturct = time.localtime(int(ctime))
ctime_string = '_%.4d%.2d%.2d%.2d%.2d%.2d_' % (ctime_sturct[0], ctime_sturct[1], ctime_sturct[2], ctime_sturct[3],
ctime_sturct[4], ctime_sturct[5])
creation_date = '%.4d-%.2d-%.2dT%.2d:%.2d:%.2d' % (ctime_sturct[0], ctime_sturct[1], ctime_sturct[2],
ctime_sturct[3], ctime_sturct[4], ctime_sturct[5])
return ctime_string, creation_date
def get_file_name(process, platform, offset, ctime_string, pid):
return process + '_' + platform + '_' + offset + ctime_string + pid + '.core'
def get_file_size_hostname(core_file):
file_size = os.path.getsize(core_file)
hostname = os.uname()[1]
return file_size, hostname
def make_libs_tar(core_file, process):
if os.path.exists(libs_file):
os.remove(libs_file)
cmd = """echo -e "info shared\nq" | """
cmd += """ gdb /opt/1C/v8.3/x86_64/""" + process + " " + core_file + """ 2>/dev/null | """
cmd += """ grep 0x0000 | grep -v /opt/1C/v8.3 | grep -v ?? | perl -alne 'print $F[-1]' | """
cmd += """ while read file; do tar --dereference --append -f """ + libs_file + """ $file 2> /dev/null ; done"""
stdout, stderr = run_shell(cmd)
# Если стек не раскрылся, то создадим пустой файл
if not os.path.exists(libs_file):
cmd = 'touch ' + libs_file
run_shell_get_result(cmd)
if stderr:
write_to_log('cant work with gdb and make libs tar, result: ' + str(stderr))
if os.path.getsize(libs_file) == 0:
write_to_log('libs_file size = 0.')
def change_extension(core_gz_file):
core_gz_file = regex_extension_replacement.sub('.tar.gz', core_gz_file)
return regex_extension_replacement2.sub('.tar.gz', core_gz_file)
# END prepare date------------------------------------------------------------------------------------------------------
def gz_core_file(core_file, file_name):
# Костыль, меняем расшинерие на gz
core_gz_file = os.path.basename(file_name)
core_gz_file = change_extension(core_gz_file)
# Зипуем
cmd = 'cd {} && mv {} {} && '.format(cores_dir, core_file, file_name)
cmd += 'tar -czf {} {} {} 2>/dev/null && '.format(core_gz_file, file_name, libs_short_file)
cmd += 'rm -f {} && rm -f {}'.format(file_name, libs_short_file)
rez = run_shell_get_result(cmd)
# Если не получилось загзиповать, то выходим из процедуры
if rez:
write_to_log('cant work with tar')
return
# BEGIN main program ---------------------------------------------------------------------------------------------------
def work_with_dump(core_file):
while not check_size_static(core_file):
print('{} file size: {}'.format(core_file, os.path.getsize(core_file)))
process, ctime, pid = get_pid_process_ctime(core_file)
platform, offset = get_platform_offset(core_file, process)
ctime_string, creation_date = get_creation_date_string(ctime)
make_libs_tar(core_file, process)
file_name = get_file_name(process, platform, offset, ctime_string, pid)
gz_core_file(core_file, file_name)
cores_dir = '/tmp/cores/' # директория в которой должны лежать дампы
libs_short_file = 'libs.tar'
libs_file = os.path.join(cores_dir, 'libs.tar')
if __name__ == "__main__":
# finding core files
cores_path = cores_dir + '*.core*'
for file in glob.glob(cores_path):
work_with_dump(file)

60
images/core/entrypoint.sh Normal file
View File

@ -0,0 +1,60 @@
#!/bin/bash
set -e
if [ "$1" = 'srv' ]
then
chown -R usr1cv8:grp1cv8 ${COREDATA} ${CORELOGS}
exec gosu usr1cv8 /opt/1C/v8.3/x86_64/ragent -debug -http /d ${COREDATA}
elif [ "$1" = 'srv+cli' ]
then
ulimit -c unlimited
chown -R usr1cv8:grp1cv8 ${COREDATA} ${CORELOGS}
exec gosu usr1cv8 /opt/1C/v8.3/x86_64/ragent -debug -http /d ${COREDATA} &
status=$?
if [ $status -ne 0 ]; then
echo "Failed to start ragent: $status"
exit $status
fi
exec /usr/bin/Xvfb :99 -screen 0 1680x1050x24 -shmem &
exec metacity --display=:99 &
exec /usr/bin/x11vnc &
status=$?
if [ $status -ne 0 ]; then
echo "Failed to start Xvfb: $status"
exit $status
fi
while sleep 60; do
ps aux | grep [r]agent
RAGENT_STATUS=$?
ps aux | grep [Xvfb]
XVFB_STATUS=$?
if [ $RAGENT_STATUS -ne 0 -o $XVFB_STATUS -ne 0 ]; then
echo "One of the processes has already exited."
exit 1
fi
done
elif [ "$1" = 'ras' ]
then
chown -R usr1cv8:grp1cv8 ${CORELOGS}
exec gosu usr1cv8 /opt/1C/v8.3/x86_64/ras cluster
elif [ "$1" = 'cli' ]
then
chown -R usr1cv8:grp1cv8 ${CORELOGS}
exec /usr/bin/Xvfb :99 -screen 0 1680x1050x24 -shmem &
exec metacity --display=:99 &
exec /usr/bin/x11vnc
elif [ "$1" = 'web' ]
then
chown -R usr1cv8:grp1cv8 ${CORELOGS}
rm -rf /run/httpd/* /tmp/httpd*
unset HOME
exec httpd -DFOREGROUND
elif [ "$1" = 'agent' ]
then
chown -R usr1cv8:grp1cv8 ${COREDATA} ${CORELOGS} ${AGENTBASEDIR}
exec /usr/bin/Xvfb :99 -screen 0 1680x1050x24 -shmem &
exec /opt/1C/v8.3/x86_64/1cv8 DESIGNER /AgentMode /IBConnectionString "${INFOBASECONNECTIONSTRING}" /AgentBaseDir "${AGENTBASEDIR}" /AgentSSHHostKey "/id_rsa.key" /Visible /AgentListenAddress 0.0.0.0
fi
exec "$@"

View File

@ -0,0 +1,14 @@
cd /out_files
DISTR_FILE_VERSION=$(ls | grep "client" | grep -Eo "[0-9]+\_[0-9]+\_[0-9]+\_[0-9]+")
DISTR_VERSION=$(ls | grep "client" | grep -Eo "[0-9]+\_[0-9]+\_[0-9]+\_[0-9]+" | sed 's/_/./g')
DISTR_VER1=$(echo $DISTR_VERSION | cut -d '.' -f 1-3)
DISTR_VER2=$(echo $DISTR_VERSION | cut -d '.' -f 4)
common_file_name=1C_Enterprise83-common-$DISTR_VER1-$DISTR_VER2.x86_64.rpm
server_file_name=1C_Enterprise83-server-$DISTR_VER1-$DISTR_VER2.x86_64.rpm
ws_file_name=1C_Enterprise83-ws-$DISTR_VER1-$DISTR_VER2.x86_64.rpm
client_file_name=1C_Enterprise83-client-$DISTR_VER1-$DISTR_VER2.x86_64.rpm
tar -xvf client_$DISTR_FILE_VERSION.rpm64.tar.gz $client_file_name -C /main_dir/distr
tar -xvf rpm64_$DISTR_FILE_VERSION.tar.gz $common_file_name $server_file_name $ws_file_name -C /main_dir/distr

11
images/gate/Dockerfile Normal file
View File

@ -0,0 +1,11 @@
FROM java:8-jre
COPY ./distr/appgate.deb /
RUN dpkg -i /appgate.deb; \
rm /appgate.deb; \
/opt/1C/1cfresh/appgate/setAuth.sh appgate 12345Qwer
EXPOSE 8080 9090
CMD ["/opt/1C/1cfresh/appgate/appgate_wrapper.sh"]

2
images/gate/distr/.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
*
!.gitignore

View File

@ -1,29 +1,39 @@
import subprocess
import pathlib
import os
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
sep = str(os.path.sep)
this_path = str(pathlib.Path().absolute()) + sep
distr_path = this_path + 'distr' + sep
images = []
images.append(centos.New())
images.append(db.New())
images.append(site.New())
images.append(forum.New())
# images.append(centos.New())
# images.append(db.New())
# images.append(site.New())
# images.append(forum.New())
# images.append(core.New())
images.append(gate.New())
print('Building start')
for image in images:
for command in image.commands:
for command in image.commands_before:
print(command)
subprocess.call(' '.join(command), shell=True)
subprocess.run(['docker', 'build', '-t', 'fresh/' + image.name, 'images/' + image.name])
for command in image.commands_after:
print(command)
subprocess.call(' '.join(command), shell=True)
print('Building', image.name, 'is fihish')
print('Building finish')

View File

@ -10,7 +10,7 @@ def download_postgresql_connector():
return command
def add_all_commands():
def add_all_before_commands():
commands = []
commands.append(download_postgresql_connector())
@ -20,8 +20,9 @@ def add_all_commands():
class New():
name = ''
commands = []
commands_before = []
commands_after = []
def __init__(self):
self.name = 'centos'
self.commands = add_all_commands()
self.commands_before = add_all_before_commands()

53
modules/core.py Normal file
View File

@ -0,0 +1,53 @@
import modules.helper as helper
def download_onescript():
command = helper.new_docker_command('images/core/distr/')
command.append('alpine')
command.append('wget')
command.append('-O')
command.append('/out_files/onescript.rpm')
command.append('http://oscript.io/downloads/1_1_1/onescript-engine-1.1.1-1.fc26.noarch.rpm')
return command
def unzip_platform_distr():
command = helper.new_docker_command()
command.append('-v')
command.append(helper.this_path + helper.replace_sep('images/core') + ':/main_dir')
command.append('alpine')
command.append('sh')
command.append('/main_dir/get_platform.sh')
return command
def add_all_before_commands():
commands = []
commands.append(download_onescript())
commands.append(unzip_platform_distr())
return commands
def delete_core_distr_files():
command = helper.new_docker_command('images/core/distr/')
command.append('alpine')
command.append('sh -c "rm -rf /out_files/*.rpm"')
return command
def add_all_after_commands():
commands = []
commands.append(delete_core_distr_files())
return commands
class New():
name = ''
commands_before = []
commands_after = []
def __init__(self):
self.name = 'core'
self.commands_before = add_all_before_commands()
self.commands_after = add_all_after_commands()

View File

@ -2,8 +2,9 @@
class New():
name = ''
commands = []
commands_before = []
commands_after = []
def __init__(self):
self.name = 'db'
self.commands = []
self.commands_before = []

View File

@ -36,20 +36,26 @@ def rename_forum_file():
return command
def add_all_commands():
def add_all_before_commands():
commands = []
commands.append(delete_forum_dir())
commands.append(unzip_forum_dir())
commands.append(rename_forum_file())
return commands
def add_all_after_commands():
commands = []
commands.append(delete_forum_dir())
return commands
class New():
name = ''
commands = []
commands_before = []
commands_after = []
def __init__(self):
self.name = 'forum'
self.commands = add_all_commands()
self.commands_before = add_all_before_commands()
self.commands_after = add_all_after_commands()

41
modules/gate.py Normal file
View File

@ -0,0 +1,41 @@
import modules.helper as helper
def copy_distrib_file():
command = helper.new_docker_command()
command.append('-v')
command.append(helper.this_path + helper.replace_sep('images/gate') + ':/main_dir')
command.append('alpine')
command.append('sh -c')
command.append('"cp /out_files/appgate*.deb /main_dir/distr/appgate.deb"')
return command
def delete_distrib_file():
command = helper.new_docker_command('images/gate/distr')
command.append('alpine')
command.append('sh -c "rm -rf /out_files/*.deb"')
return command
def add_all_before_commands():
commands = []
commands.append(copy_distrib_file())
return commands
def add_all_after_commands():
commands = []
return commands
class New():
name = ''
commands_before = []
commands_after = []
def __init__(self):
self.name = 'gate'
self.commands_before = add_all_before_commands()
self.commands_after = add_all_after_commands()

View File

@ -1,12 +1,5 @@
import subprocess
import pathlib
import os
import modules.helper as helper
def add_site_dir(command):
command.append('-v')
command.append(helper.this_path + helper.replace_sep('images/site') + ':/main_dir')
def delete_site_dir():
command = helper.new_docker_command('images/site/distr')
command.append('alpine')
@ -18,7 +11,8 @@ def delete_site_dir():
def unzip_site_dir():
command = helper.new_docker_command()
add_site_dir(command)
command.append('-v')
command.append(helper.this_path + helper.replace_sep('images/site') + ':/main_dir')
command.append('kubeless/unzip')
command.append('unzip')
command.append('/out_files/site_*.zip')
@ -36,20 +30,26 @@ def rename_site_file():
return command
def add_all_commands():
def add_all_before_commands():
commands = []
commands.append(delete_site_dir())
commands.append(unzip_site_dir())
commands.append(rename_site_file())
return commands
def add_all_after_commands():
commands = []
commands.append(delete_site_dir())
return commands
class New():
name = ''
commands = []
commands_before = []
commands_after = []
def __init__(self):
self.name = 'site'
self.commands = add_all_commands()
self.commands_before = add_all_before_commands()
self.commands_after = add_all_after_commands()