Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
D
docker-py
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
docker-py
Commits
06f5a47d
Kaydet (Commit)
06f5a47d
authored
Mar 30, 2018
tarafından
Joffrey F
Kaydeden (comit)
Joffrey F
Mar 30, 2018
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Properly handle relative Dockerfile paths and Dockerfile on different drives
Signed-off-by:
Joffrey F
<
joffrey@docker.com
>
üst
2ecc3adc
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
52 additions
and
9 deletions
+52
-9
build.py
docker/api/build.py
+20
-9
api_build_test.py
tests/integration/api_build_test.py
+32
-0
No files found.
docker/api/build.py
Dosyayı görüntüle @
06f5a47d
...
...
@@ -149,15 +149,7 @@ class BuildApiMixin(object):
lambda
x
:
x
!=
''
and
x
[
0
]
!=
'#'
,
[
l
.
strip
()
for
l
in
f
.
read
()
.
splitlines
()]
))
if
dockerfile
and
os
.
path
.
relpath
(
dockerfile
,
path
)
.
startswith
(
'..'
):
with
open
(
dockerfile
,
'r'
)
as
df
:
dockerfile
=
(
'.dockerfile.{0:x}'
.
format
(
random
.
getrandbits
(
160
)),
df
.
read
()
)
else
:
dockerfile
=
(
dockerfile
,
None
)
dockerfile
=
process_dockerfile
(
dockerfile
,
path
)
context
=
utils
.
tar
(
path
,
exclude
=
exclude
,
dockerfile
=
dockerfile
,
gzip
=
gzip
)
...
...
@@ -312,3 +304,22 @@ class BuildApiMixin(object):
)
else
:
log
.
debug
(
'No auth config found'
)
def
process_dockerfile
(
dockerfile
,
path
):
if
not
dockerfile
:
return
(
None
,
None
)
abs_dockerfile
=
dockerfile
if
not
os
.
path
.
isabs
(
dockerfile
):
abs_dockerfile
=
os
.
path
.
join
(
path
,
dockerfile
)
if
(
os
.
path
.
splitdrive
(
path
)[
0
]
!=
os
.
path
.
splitdrive
(
abs_dockerfile
)[
0
]
or
os
.
path
.
relpath
(
abs_dockerfile
,
path
)
.
startswith
(
'..'
)):
with
open
(
abs_dockerfile
,
'r'
)
as
df
:
return
(
'.dockerfile.{0:x}'
.
format
(
random
.
getrandbits
(
160
)),
df
.
read
()
)
else
:
return
(
dockerfile
,
None
)
tests/integration/api_build_test.py
Dosyayı görüntüle @
06f5a47d
...
...
@@ -440,3 +440,35 @@ class BuildTest(BaseAPIIntegrationTest):
lsdata
=
self
.
client
.
logs
(
ctnr
)
.
strip
()
.
split
(
b
'
\n
'
)
assert
len
(
lsdata
)
==
3
assert
sorted
([
b
'.'
,
b
'..'
,
b
'file.txt'
])
==
sorted
(
lsdata
)
def
test_build_in_context_dockerfile
(
self
):
base_dir
=
tempfile
.
mkdtemp
()
self
.
addCleanup
(
shutil
.
rmtree
,
base_dir
)
with
open
(
os
.
path
.
join
(
base_dir
,
'file.txt'
),
'w'
)
as
f
:
f
.
write
(
'hello world'
)
with
open
(
os
.
path
.
join
(
base_dir
,
'custom.dockerfile'
),
'w'
)
as
df
:
df
.
write
(
'
\n
'
.
join
([
'FROM busybox'
,
'COPY . /src'
,
'WORKDIR /src'
,
]))
print
(
os
.
path
.
join
(
base_dir
,
'custom.dockerfile'
))
img_name
=
random_name
()
self
.
tmp_imgs
.
append
(
img_name
)
stream
=
self
.
client
.
build
(
path
=
base_dir
,
dockerfile
=
'custom.dockerfile'
,
tag
=
img_name
,
decode
=
True
)
lines
=
[]
for
chunk
in
stream
:
lines
.
append
(
chunk
)
assert
'Successfully tagged'
in
lines
[
-
1
][
'stream'
]
ctnr
=
self
.
client
.
create_container
(
img_name
,
'ls -a'
)
self
.
tmp_containers
.
append
(
ctnr
)
self
.
client
.
start
(
ctnr
)
lsdata
=
self
.
client
.
logs
(
ctnr
)
.
strip
()
.
split
(
b
'
\n
'
)
assert
len
(
lsdata
)
==
4
assert
sorted
(
[
b
'.'
,
b
'..'
,
b
'file.txt'
,
b
'custom.dockerfile'
]
)
==
sorted
(
lsdata
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment