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
7af7e1b7
Kaydet (Commit)
7af7e1b7
authored
May 17, 2017
tarafından
Joffrey F
Kaydeden (comit)
GitHub
May 17, 2017
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Sade Fark
Merge pull request #1612 from lawliet89/build-stage
Add `target` argument to image building
üst
7880c5af
e4093ab2
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
35 additions
and
1 deletion
+35
-1
build.py
docker/api/build.py
+11
-1
images.py
docker/models/images.py
+2
-0
api_build_test.py
tests/integration/api_build_test.py
+22
-0
No files found.
docker/api/build.py
Dosyayı görüntüle @
7af7e1b7
...
@@ -18,7 +18,7 @@ class BuildApiMixin(object):
...
@@ -18,7 +18,7 @@ class BuildApiMixin(object):
custom_context
=
False
,
encoding
=
None
,
pull
=
False
,
custom_context
=
False
,
encoding
=
None
,
pull
=
False
,
forcerm
=
False
,
dockerfile
=
None
,
container_limits
=
None
,
forcerm
=
False
,
dockerfile
=
None
,
container_limits
=
None
,
decode
=
False
,
buildargs
=
None
,
gzip
=
False
,
shmsize
=
None
,
decode
=
False
,
buildargs
=
None
,
gzip
=
False
,
shmsize
=
None
,
labels
=
None
,
cache_from
=
None
):
labels
=
None
,
cache_from
=
None
,
target
=
None
):
"""
"""
Similar to the ``docker build`` command. Either ``path`` or ``fileobj``
Similar to the ``docker build`` command. Either ``path`` or ``fileobj``
needs to be set. ``path`` can be a local path (to a directory
needs to be set. ``path`` can be a local path (to a directory
...
@@ -94,6 +94,8 @@ class BuildApiMixin(object):
...
@@ -94,6 +94,8 @@ class BuildApiMixin(object):
labels (dict): A dictionary of labels to set on the image.
labels (dict): A dictionary of labels to set on the image.
cache_from (list): A list of images used for build cache
cache_from (list): A list of images used for build cache
resolution.
resolution.
target (str): Name of the build-stage to build in a multi-stage
Dockerfile.
Returns:
Returns:
A generator for the build output.
A generator for the build output.
...
@@ -198,6 +200,14 @@ class BuildApiMixin(object):
...
@@ -198,6 +200,14 @@ class BuildApiMixin(object):
'cache_from was only introduced in API version 1.25'
'cache_from was only introduced in API version 1.25'
)
)
if
target
:
if
utils
.
version_gte
(
self
.
_version
,
'1.29'
):
params
.
update
({
'target'
:
target
})
else
:
raise
errors
.
InvalidVersion
(
'target was only introduced in API version 1.29'
)
if
context
is
not
None
:
if
context
is
not
None
:
headers
=
{
'Content-Type'
:
'application/tar'
}
headers
=
{
'Content-Type'
:
'application/tar'
}
if
encoding
:
if
encoding
:
...
...
docker/models/images.py
Dosyayı görüntüle @
7af7e1b7
...
@@ -151,6 +151,8 @@ class ImageCollection(Collection):
...
@@ -151,6 +151,8 @@ class ImageCollection(Collection):
decoded into dicts on the fly. Default ``False``.
decoded into dicts on the fly. Default ``False``.
cache_from (list): A list of images used for build cache
cache_from (list): A list of images used for build cache
resolution.
resolution.
target (str): Name of the build-stage to build in a multi-stage
Dockerfile.
Returns:
Returns:
(:py:class:`Image`): The built image.
(:py:class:`Image`): The built image.
...
...
tests/integration/api_build_test.py
Dosyayı görüntüle @
7af7e1b7
...
@@ -189,6 +189,28 @@ class BuildTest(BaseAPIIntegrationTest):
...
@@ -189,6 +189,28 @@ class BuildTest(BaseAPIIntegrationTest):
counter
+=
1
counter
+=
1
assert
counter
==
0
assert
counter
==
0
@requires_api_version
(
'1.29'
)
def
test_build_container_with_target
(
self
):
script
=
io
.
BytesIO
(
'
\n
'
.
join
([
'FROM busybox as first'
,
'RUN mkdir -p /tmp/test'
,
'RUN touch /tmp/silence.tar.gz'
,
'FROM alpine:latest'
,
'WORKDIR /root/'
'COPY --from=first /tmp/silence.tar.gz .'
,
'ONBUILD RUN echo "This should not be in the final image"'
])
.
encode
(
'ascii'
))
stream
=
self
.
client
.
build
(
fileobj
=
script
,
target
=
'first'
,
tag
=
'build1'
)
self
.
tmp_imgs
.
append
(
'build1'
)
for
chunk
in
stream
:
pass
info
=
self
.
client
.
inspect_image
(
'build1'
)
self
.
assertEqual
(
info
[
'Config'
][
'OnBuild'
],
[])
def
test_build_stderr_data
(
self
):
def
test_build_stderr_data
(
self
):
control_chars
=
[
'
\x1b
[91m'
,
'
\x1b
[0m'
]
control_chars
=
[
'
\x1b
[91m'
,
'
\x1b
[0m'
]
snippet
=
'Ancient Temple (Mystic Oriental Dream ~ Ancient Temple)'
snippet
=
'Ancient Temple (Mystic Oriental Dream ~ Ancient Temple)'
...
...
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