copy_tree
This commit is contained in:
parent
824af776d9
commit
8a65b6a0f4
@ -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
|
||||
|
||||
|
@ -17,4 +17,4 @@ SCRIPT
|
||||
rm -f /tmp/apache-tomcat-8.tgz
|
||||
RUN
|
||||
|
||||
COPY lxc-tomcat/ /
|
||||
COPY lxc-tomcat
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
20
lxc-build
20
lxc-build
@ -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()
|
||||
|
Loading…
Reference in New Issue
Block a user