copy_tree

This commit is contained in:
Disassembler 2018-09-05 21:21:07 +02:00
parent 824af776d9
commit 8a65b6a0f4
No known key found for this signature in database
GPG Key ID: 524BD33A0EE29499
5 changed files with 19 additions and 9 deletions

View File

@ -20,7 +20,7 @@ SCRIPT
sed -i "s/-Xms64M -Xmx1G/-Xms32M -Xmx256M/" /srv/activemq/bin/env
RUN
COPY lxc/ /
COPY lxc
CMD /bin/s6-svscan /etc/services.d

View File

@ -17,4 +17,4 @@ SCRIPT
rm -f /tmp/apache-tomcat-8.tgz
RUN
COPY lxc-tomcat/ /
COPY lxc-tomcat

View File

@ -35,7 +35,7 @@ SCRIPT
rm -rf /root/.cache
RUN
COPY lxc/ /
COPY lxc
VOLUME /etc/ssl/services.pem etc/ssl/services.pem
VOLUME /srv/ckan-datapusher/conf etc/ckan-datapusher

View File

@ -47,7 +47,7 @@ SCRIPT
rm -rf /root/.cache
RUN
COPY lxc/ /
COPY lxc
MOUNT /srv/ckan/conf etc/ckan
MOUNT /srv/ckan/data srv/ckan/storage

View File

@ -74,7 +74,7 @@ def fix_world():
world_items.extend(last_world)
world_items = sorted(set(world_items))
if world_items != sorted(last_world):
os.makedirs(os.path.join(LXC_ROOT, layers[-1], 'etc/apk'))
os.makedirs(os.path.join(LXC_ROOT, layers[-1], 'etc/apk', 0o755, True))
with open(os.path.join(LXC_ROOT, layers[-1], 'etc/apk/world'), 'w') as fd:
fd.writelines(world_items)
@ -86,10 +86,21 @@ def run_script():
subprocess.run(['lxc-execute', '-n', image, '--', '/bin/sh', '-lc', '/run.sh'], check=True)
os.unlink(script_filename)
def copy_tree(src, dst):
if not os.path.isdir(src):
shutil.copy2(src, dst)
else:
os.makedirs(dst, exist_ok=True)
for name in os.listdir(src):
copy_tree(os.path.join(src, name), os.path.join(dst, name))
shutil.copystat(src, dst)
def copy_files(src, dst):
src = os.path.join(build_context, src)
dst = os.path.join(LXC_ROOT, layers[-1], dst)
shutil.copytree(src, dst)
print('SRC: {}'.format(src))
print('DST: {}'.format(dst))
copy_tree(src, dst)
with open(lxcfile, 'r') as fd:
recipe = fd.readlines()
@ -100,8 +111,7 @@ for line in recipe:
in_script = False
run_script()
elif in_script:
if line and not line.startswith('#'):
script.append(line)
script.append(line)
elif line == 'SCRIPT':
script = []
in_script = True
@ -115,7 +125,7 @@ for line in recipe:
fix_world()
elif line.startswith('COPY'):
srcdst = line.split()
copy_files(srcdst[1], srcdst[2])
copy_files(srcdst[1], srcdst[2] if len(srcdst) == 3 else '')
elif line.startswith('MOUNT'):
mounts.append(line.split()[1])
rebuild_config()