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
33cae41d
Kaydet (Commit)
33cae41d
authored
Nis 12, 2018
tarafından
Joffrey F
Kaydeden (comit)
Joffrey F
Nis 26, 2018
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Support absolute paths for in-context Dockerfiles
Signed-off-by:
Joffrey F
<
joffrey@docker.com
>
üst
298b7e14
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
46 additions
and
9 deletions
+46
-9
build.py
docker/api/build.py
+4
-2
setup.py
setup.py
+10
-6
api_build_test.py
tests/integration/api_build_test.py
+32
-1
No files found.
docker/api/build.py
Dosyayı görüntüle @
33cae41d
...
...
@@ -332,10 +332,12 @@ def process_dockerfile(dockerfile, path):
if
(
os
.
path
.
splitdrive
(
path
)[
0
]
!=
os
.
path
.
splitdrive
(
abs_dockerfile
)[
0
]
or
os
.
path
.
relpath
(
abs_dockerfile
,
path
)
.
startswith
(
'..'
)):
# Dockerfile not in context - read data to insert into tar later
with
open
(
abs_dockerfile
,
'r'
)
as
df
:
return
(
'.dockerfile.{0:x}'
.
format
(
random
.
getrandbits
(
160
)),
df
.
read
()
)
else
:
return
(
dockerfile
,
None
)
# Dockerfile is inside the context - return path relative to context root
return
(
os
.
path
.
relpath
(
abs_dockerfile
,
path
),
None
)
setup.py
Dosyayı görüntüle @
33cae41d
...
...
@@ -9,12 +9,16 @@ import pip
from
setuptools
import
setup
,
find_packages
if
'docker-py'
in
[
x
.
project_name
for
x
in
pip
.
get_installed_distributions
()]:
print
(
'ERROR: "docker-py" needs to be uninstalled before installing this'
' package:
\n
pip uninstall docker-py'
,
file
=
sys
.
stderr
)
sys
.
exit
(
1
)
try
:
if
'docker-py'
in
[
x
.
project_name
for
x
in
pip
.
get_installed_distributions
()]:
print
(
'ERROR: "docker-py" needs to be uninstalled before installing this'
' package:
\n
pip uninstall docker-py'
,
file
=
sys
.
stderr
)
sys
.
exit
(
1
)
except
AttributeError
:
pass
ROOT_DIR
=
os
.
path
.
dirname
(
__file__
)
SOURCE_DIR
=
os
.
path
.
join
(
ROOT_DIR
)
...
...
tests/integration/api_build_test.py
Dosyayı görüntüle @
33cae41d
...
...
@@ -452,7 +452,6 @@ class BuildTest(BaseAPIIntegrationTest):
'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
(
...
...
@@ -472,3 +471,35 @@ class BuildTest(BaseAPIIntegrationTest):
assert
sorted
(
[
b
'.'
,
b
'..'
,
b
'file.txt'
,
b
'custom.dockerfile'
]
)
==
sorted
(
lsdata
)
def
test_build_in_context_abs_dockerfile
(
self
):
base_dir
=
tempfile
.
mkdtemp
()
self
.
addCleanup
(
shutil
.
rmtree
,
base_dir
)
abs_dockerfile_path
=
os
.
path
.
join
(
base_dir
,
'custom.dockerfile'
)
with
open
(
os
.
path
.
join
(
base_dir
,
'file.txt'
),
'w'
)
as
f
:
f
.
write
(
'hello world'
)
with
open
(
abs_dockerfile_path
,
'w'
)
as
df
:
df
.
write
(
'
\n
'
.
join
([
'FROM busybox'
,
'COPY . /src'
,
'WORKDIR /src'
,
]))
img_name
=
random_name
()
self
.
tmp_imgs
.
append
(
img_name
)
stream
=
self
.
client
.
build
(
path
=
base_dir
,
dockerfile
=
abs_dockerfile_path
,
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