Skip to content

Commit a07b5ee

Browse files
committed
fix docker build error when dockerfile contains unicode character.
if dockerfile contains unicode character,len(contents) will return character length,this length will less than len(contents_encoded) length,so contants data will be truncated. Signed-off-by: fengbaolong <[email protected]>
1 parent 9a24df5 commit a07b5ee

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

docker/utils/build.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,9 @@ def create_archive(root, files=None, fileobj=None, gzip=False,
105105

106106
for name, contents in extra_files:
107107
info = tarfile.TarInfo(name)
108-
info.size = len(contents)
109-
t.addfile(info, io.BytesIO(contents.encode('utf-8')))
108+
contents_encoded = contents.encode('utf-8')
109+
info.size = len(contents_encoded)
110+
t.addfile(info, io.BytesIO(contents_encoded))
110111

111112
t.close()
112113
fileobj.seek(0)

0 commit comments

Comments
 (0)