Ë
    9ài¿>  ã                   óz   — d dl Z d dlZd dlZd dlZddlmZmZmZmZ  ej                  e
«      Z G d„ d«      Zd„ Zy)é    Né   )ÚauthÚ	constantsÚerrorsÚutilsc                   ó\   — e Zd Z	 	 	 	 	 	 	 	 dd„Z ej
                  d«      dd„«       Zd„ Zy)ÚBuildApiMixinNc                 óv  — dx}}i }|xs i }|xs i }|€|€t        d«      ‚|r|	�t        j                  d«      ‚|�.t        j                  |«      st        j                  d|› d�«      ‚|j                  «       D ]-  }|t        j                  vsŒt        j                  d|› d�«      ‚ |r|st        d«      ‚|}�n%|�t        j                  |«      }�n|j                  d«      r|}nøt        j                  j                  |«      st        d«      ‚t        j                  j                  |d	«      }d} t        j                  j                  |«      rbt        |«      5 }!t!        t#        d
„ |!j%                  «       j'                  «       D �"cg c]  }"|"j)                  «       ‘Œ c}"«      «      } ddd«       t+        ||«      }t        j,                  || ||¬«      }|rdn|	}	| j/                  d«      }#|||||||
|dœ}$|$j1                  |«       |rD| j2                  j5                  «       }%|%j7                  «       D ]  \  }&}'|j9                  |&|'«       Œ |r&|$j1                  dt;        j<                  |«      i«       |rIt        j>                  | j@                  d«      r|$j1                  d|i«       nt        jB                  d«      ‚|r\t        j>                  | j@                  d«      r'|$j1                  dt;        j<                  |«      i«       nt        jB                  d«      ‚|r\t        j>                  | j@                  d«      r'|$j1                  dt;        j<                  |«      i«       nt        jB                  d«      ‚|rIt        j>                  | j@                  d«      r|$j1                  d|i«       nt        jB                  d«      ‚|rIt        j>                  | j@                  d«      r|$j1                  d|i«       nt        jB                  d«      ‚|rIt        j>                  | j@                  d«      r|$j1                  d|i«       nt        jB                  d«      ‚|�mt        jD                  | j@                  d «      rt        jB                  d!«      ‚tG        |tH        «      rt        jJ                  |«      }|$j1                  d"|i«       |�:t        jD                  | j@                  d#«      rt        jB                  d$«      ‚||$d%<   |�:t        jD                  | j@                  d&«      rt        jB                  d'«      ‚||$d(<   |�d)d*i}|	r|	|d+<   | jM                  |«       | jO                  |#||$|d,|¬-«      }(|�|s|jQ                  «        | jS                  |(|¬.«      S c c}"w # 1 sw Y   �Œ xY w)/aþ  
        Similar to the ``docker build`` command. Either ``path`` or ``fileobj``
        needs to be set. ``path`` can be a local path (to a directory
        containing a Dockerfile) or a remote URL. ``fileobj`` must be a
        readable file-like object to a Dockerfile.

        If you have a tar file for the Docker build context (including a
        Dockerfile) already, pass a readable file-like object to ``fileobj``
        and also pass ``custom_context=True``. If the stream is compressed
        also, set ``encoding`` to the correct value (e.g ``gzip``).

        Example:
            >>> from io import BytesIO
            >>> from docker import APIClient
            >>> dockerfile = '''
            ... # Shared Volume
            ... FROM busybox:buildroot-2014.02
            ... VOLUME /data
            ... CMD ["/bin/sh"]
            ... '''
            >>> f = BytesIO(dockerfile.encode('utf-8'))
            >>> cli = APIClient(base_url='tcp://127.0.0.1:2375')
            >>> response = [line for line in cli.build(
            ...     fileobj=f, rm=True, tag='yourname/volume'
            ... )]
            >>> response
            ['{"stream":" ---\u003e a9eb17255234\n"}',
             '{"stream":"Step 1 : VOLUME /data\n"}',
             '{"stream":" ---\u003e Running in abdc1e6896c6\n"}',
             '{"stream":" ---\u003e 713bca62012e\n"}',
             '{"stream":"Removing intermediate container abdc1e6896c6\n"}',
             '{"stream":"Step 2 : CMD [\"/bin/sh\"]\n"}',
             '{"stream":" ---\u003e Running in dba30f2a1a7e\n"}',
             '{"stream":" ---\u003e 032b8b2855fc\n"}',
             '{"stream":"Removing intermediate container dba30f2a1a7e\n"}',
             '{"stream":"Successfully built 032b8b2855fc\n"}']

        Args:
            path (str): Path to the directory containing the Dockerfile
            fileobj: A file object to use as the Dockerfile. (Or a file-like
                object)
            tag (str): A tag to add to the final image
            quiet (bool): Whether to return the status
            nocache (bool): Don't use the cache when set to ``True``
            rm (bool): Remove intermediate containers. The ``docker build``
                command now defaults to ``--rm=true``, but we have kept the old
                default of `False` to preserve backward compatibility
            timeout (int): HTTP timeout
            custom_context (bool): Optional if using ``fileobj``
            encoding (str): The encoding for a stream. Set to ``gzip`` for
                compressing
            pull (bool): Downloads any updates to the FROM image in Dockerfiles
            forcerm (bool): Always remove intermediate containers, even after
                unsuccessful builds
            dockerfile (str): path within the build context to the Dockerfile
            gzip (bool): If set to ``True``, gzip compression/encoding is used
            buildargs (dict): A dictionary of build arguments
            container_limits (dict): A dictionary of limits applied to each
                container created by the build process. Valid keys:

                - memory (int): set memory limit for build
                - memswap (int): Total memory (memory + swap), -1 to disable
                    swap
                - cpushares (int): CPU shares (relative weight)
                - cpusetcpus (str): CPUs in which to allow execution, e.g.,
                    ``"0-3"``, ``"0,1"``
            decode (bool): If set to ``True``, the returned stream will be
                decoded into dicts on the fly. Default ``False``
            shmsize (int): Size of `/dev/shm` in bytes. The size must be
                greater than 0. If omitted the system uses 64MB
            labels (dict): A dictionary of labels to set on the image
            cache_from (:py:class:`list`): A list of images used for build
                cache resolution
            target (str): Name of the build-stage to build in a multi-stage
                Dockerfile
            network_mode (str): networking mode for the run commands during
                build
            squash (bool): Squash the resulting images layers into a
                single layer.
            extra_hosts (dict): Extra hosts to add to /etc/hosts in building
                containers, as a mapping of hostname to IP address.
            platform (str): Platform in the format ``os[/arch[/variant]]``
            isolation (str): Isolation technology used during build.
                Default: `None`.
            use_config_proxy (bool): If ``True``, and if the docker client
                configuration file (``~/.docker/config.json`` by default)
                contains a proxy configuration, the corresponding environment
                variables will be set in the container being built.

        Returns:
            A generator for the build output.

        Raises:
            :py:class:`docker.errors.APIError`
                If the server returns an error.
            ``TypeError``
                If neither ``path`` nor ``fileobj`` is specified.
        Nz,Either path or fileobj needs to be provided.z.Can not use custom encoding if gzip is enabledzinvalid tag 'z': invalid reference formatz,You must specify fileobj with custom_context)zhttp://zhttps://zgit://zgithub.com/zgit@z-You must specify a directory to build in pathz.dockerignorec                 ó    — | dk7  xr | d   dk7  S )NÚ r   ú#© )Úxs    úQ/home/factor_ks/STREAMA2026/venv/lib/python3.12/site-packages/docker/api/build.pyú<lambda>z%BuildApiMixin.build.<locals>.<lambda>›   s   €  ! r¡'Ò"9¨a°©d°c©k€ ó    )ÚexcludeÚ
dockerfileÚgzipr   z/build)ÚtÚremoteÚqÚnocacheÚrmÚforcermÚpullr   Ú	buildargsz1.22Úshmsizez/shmsize was only introduced in API version 1.22z1.23Úlabelsz.labels was only introduced in API version 1.23z1.25Ú	cachefromz2cache_from was only introduced in API version 1.25z1.29Útargetz.target was only introduced in API version 1.29Únetworkmodez4network_mode was only introduced in API version 1.25Úsquashz.squash was only introduced in API version 1.25z1.27z3extra_hosts was only introduced in API version 1.27Ú
extrahostsz1.32z0platform was only introduced in API version 1.32Úplatformz1.24z1isolation was only introduced in API version 1.24Ú	isolationzContent-Typezapplication/tarzContent-EncodingT)ÚdataÚparamsÚheadersÚstreamÚtimeout)Údecode)*Ú	TypeErrorr   ÚDockerExceptionr   Ú	match_tagÚkeysr   ÚCONTAINER_LIMITS_KEYSÚmkbuildcontextÚ
startswithÚosÚpathÚisdirÚjoinÚexistsÚopenÚlistÚfilterÚreadÚ
splitlinesÚstripÚprocess_dockerfileÚtarÚ_urlÚupdateÚ_proxy_configsÚget_environmentÚitemsÚ
setdefaultÚjsonÚdumpsÚversion_gteÚ_versionÚInvalidVersionÚ
version_ltÚ
isinstanceÚdictÚformat_extra_hostsÚ_set_auth_headersÚ_postÚcloseÚ_stream_helper))Úselfr5   ÚtagÚquietÚfileobjr   r   r+   Úcustom_contextÚencodingr   r   r   Úcontainer_limitsr,   r   r   r   r   Ú
cache_fromr!   Únetwork_moder#   Úextra_hostsr%   r&   Úuse_config_proxyr   Úcontextr)   ÚkeyÚdockerignorer   ÚfÚlineÚur(   Ú
proxy_argsÚkÚvÚresponses)                                            r   ÚbuildzBuildApiMixin.build   sl  € ðT  Ðˆ�ØˆØ+Ò1¨rÐØ’O ˆ	Øˆ<˜G˜OÜÐJÓKÐKÙ�HÐ(Ü×(Ñ(Ø@óð ð ˆ?Ü—?‘? 3Ô'Ü×,Ñ,Ø# C 5Ð(CÐDóð ð $×(Ñ(Ó*ò 	ˆCØœ)×9Ñ9Ò9Ü×,Ñ,Ø# C 5Ð(CÐDóð ð	ñ
 ÙÜÐ NÓOÐOØŠGØÐ Ü×*Ñ*¨7Ó3ŠGØ�_‰_ð ?ô @à‰FÜ—‘—‘˜tÔ$ÜÐKÓLÐLäŸ7™7Ÿ<™<¨¨oÓ>ˆLØˆGÜ�w‰w�~‰~˜lÔ+Ü˜,Ó'ð ¨1Ü"¤6Ù9Ø23·&±&³(×2EÑ2EÓ2GÖH¨$˜Ÿ™�ÒHó$ó �G÷ô
 ,¨J¸Ó=ˆJÜ—i‘iØ˜g°*À4ôˆGñ "&‘v¨8ˆHà�I‰I�hÓˆàØØØØØØØ$ñ	
ˆð 	�‰Ð&Ô'áØ×,Ñ,×<Ñ<Ó>ˆJØ"×(Ñ(Ó*ò +‘��1Ø×$Ñ$ Q¨Õ*ð+áØ�M‰M˜;¬¯
©
°9Ó(=Ð>Ô?áÜ× Ñ  §¡°Ô7Ø—‘˜y¨'Ð2Õ3ä×+Ñ+ØEóð ñ Ü× Ñ  §¡°Ô7Ø—‘˜x¬¯©°FÓ);Ð<Õ=ä×+Ñ+ØDóð ñ Ü× Ñ  §¡°Ô7Ø—‘˜{¬D¯J©J°zÓ,BÐCÕDä×+Ñ+ØHóð ñ Ü× Ñ  §¡°Ô7Ø—‘˜x¨Ð0Õ1ä×+Ñ+ØDóð ñ Ü× Ñ  §¡°Ô7Ø—‘˜}¨lÐ;Õ<ä×+Ñ+ØJóð ñ Ü× Ñ  §¡°Ô7Ø—‘˜x¨Ð0Õ1ä×+Ñ+ØDóð ð Ð"Ü×Ñ §¡¨vÔ6Ü×+Ñ+ØIóð ô ˜+¤tÔ,Ü#×6Ñ6°{ÓC�Ø�M‰M˜<¨Ð5Ô6àÐÜ×Ñ §¡¨vÔ6Ü×+Ñ+ØFóð ð "*ˆF�:ÑàÐ Ü×Ñ §¡¨vÔ6Ü×+Ñ+ØGóð ð #,ˆF�;ÑàÐØ%Ð'8Ð9ˆGÙØ.6�Ð*Ñ+à×Ñ˜wÔ'à—:‘:ØØØØØØð ó 
ˆð Ð¡~Ø�M‰MŒOà×"Ñ" 8°FÐ"Ó;Ð;ùòo I÷ñ ús   Å!-V.ÆV)Æ%V.Ö)V.Ö.V8z1.31c                 ó8  — | j                  d«      }|||fdk7  r5t        j                  | j                  d«      rt	        j
                  d«      ‚i }|�t        j                  |«      |d<   |�||d<   |�||d<   | j                  | j                  ||¬«      d	«      S )
a/  
        Delete the builder cache

        Args:
            filters (dict): Filters to process on the prune list.
                Needs Docker API v1.39+
                Available filters:
                - dangling (bool):  When set to true (or 1), prune only
                unused and untagged images.
                - until (str): Can be Unix timestamps, date formatted
                timestamps, or Go duration strings (e.g. 10m, 1h30m) computed
                relative to the daemon's local time.
            keep_storage (int): Amount of disk space in bytes to keep for cache.
                Needs Docker API v1.39+
            all (bool): Remove all types of build cache.
                Needs Docker API v1.39+

        Returns:
            (dict): A dictionary containing information about the operation's
                    result. The ``SpaceReclaimed`` key indicates the amount of
                    bytes of disk space reclaimed.

        Raises:
            :py:class:`docker.errors.APIError`
                If the server returns an error.
        z/build/prune©NNNz1.39zS`filters`, `keep_storage`, and `all` args are only available for API version > 1.38Úfilterszkeep-storageÚall)r(   T)	rA   r   rL   rJ   r   rK   Úconvert_filtersÚ_resultrQ   )rT   rl   Úkeep_storagerm   Úurlr(   s         r   Úprune_buildszBuildApiMixin.prune_builds  s¬   € ð8 �i‰i˜Ó'ˆØ�\ 3Ð'Ð+=Ò=Ü×$Ñ$ T§]¡]°FÔ;Ü×'Ñ'ð)óð ð ˆØÐÜ %× 5Ñ 5°gÓ >ˆF�9ÑØÐ#Ø%1ˆF�>Ñ"Øˆ?ØˆF�5‰MØ�|‰|˜DŸJ™J s°6˜JÓ:¸DÓAÐAr   c                 ó–  — t         j                  d«       | j                  r| j                  j                  r:t         j                  d«       t	        j
                  | j                  ¬«      | _        | j                  r·| j                  j                  «       }t        j                  |vrCt        j                  |v r1|j                  t        j                  i «      |t        j                  <   t         j                  ddj                  d„ |D «       «      «       |rt	        j                  |«      |d<   y y t         j                  d«       y )	NzLooking for auth configz2No auth config in memory - loading from filesystem)Úcredstore_envzSending auth config (%s)z, c              3   ó2   K  — | ]  }t        |«      –— Œ y ­w)N)Úrepr)Ú.0rf   s     r   ú	<genexpr>z2BuildApiMixin._set_auth_headers.<locals>.<genexpr>X  s   è ø€ Ò5 aœ$˜qŸ'Ñ5ùs   ‚zX-Registry-ConfigzNo auth config found)ÚlogÚdebugÚ_auth_configsÚis_emptyr   Úload_configrt   Úget_all_credentialsÚ	INDEX_URLÚ
INDEX_NAMEÚgetr7   Úencode_header)rT   r)   Ú	auth_datas      r   rP   zBuildApiMixin._set_auth_headersA  sú   € Ü�	‰	Ð+Ô,ð ×!Ò! T×%7Ñ%7×%@Ò%@Ü�I‰IÐJÔKÜ!%×!1Ñ!1Ø"×0Ñ0ô"ˆDÔð ×ÒØ×*Ñ*×>Ñ>Ó@ˆIô —‘ iÑ/Ü—O‘O yÑ0Ø,5¯M©M¼$¿/¹/È2Ó,N�	œ$Ÿ.™.Ñ)ä�I‰IØ*Ø—	‘	Ñ5¨9Ô5Ó5ôñ
 Ü/3×/AÑ/AØó0�Ð+Ò,ð ô
 �I‰IÐ,Õ-r   )NNFNFFNFNFFNNFNFNNNNNNNNNTrk   )Ú__name__Ú
__module__Ú__qualname__ri   r   Úminimum_versionrr   rP   r   r   r   r	   r	      sJ   „ Ø>BØ/3Ø8=Ø?CØ@DØFJØFJØ#óG<ðR €U×Ñ˜6Ó"ò)Bó #ð)BóV.r   r	   c                 óP  — | sy| }t         j                  j                  | «      sœt         j                  j                  || «      }t        j
                  rl|j                  t        j                  «      rMt         j                  j                  |t        t        j                  «      d  «      }t        j                  › |› �}t         j                  j                  |«      d   t         j                  j                  |«      d   k7  s/t         j                  j                  ||«      j                  d«      r>t        |«      5 }dt        j                  d«      d›�|j                  «       fcd d d «       S | |k(  r t         j                  j                  ||«      } | d fS # 1 sw Y   Œ2xY w)N)NNr   z..z.dockerfile.é    r   )r4   r5   Úisabsr7   r   ÚIS_WINDOWS_PLATFORMr3   ÚWINDOWS_LONGPATH_PREFIXÚnormpathÚlenÚ
splitdriveÚrelpathr9   ÚrandomÚgetrandbitsr<   )r   r5   Úabs_dockerfiler�   Údfs        r   r?   r?   c  sP  € ÙØà€NÜ�7‰7�=‰=˜Ô$ÜŸ™Ÿ™ d¨JÓ7ˆÜ×(Ò(¨T¯_©_Ü×1Ñ1ô.3ä—w‘w×'Ñ'Øœs¤9×#DÑ#DÓEÐFÐGóIˆHä )× AÑ AÐBÀ8À*ÐMˆNÜ
�‰×Ñ˜4Ó  Ñ#¤r§w¡w×'9Ñ'9¸.Ó'IÈ!Ñ'LÒLÜ�G‰G�O‰O˜N¨DÓ1×<Ñ<¸TÔBä�.Ó!ð 	 Ràœv×1Ñ1°#Ó6°qÐ9Ð:Ø—‘“	ð÷	ñ 	ð �^Ò#ô —W‘W—_‘_ ^°TÓ:ˆ
Ø˜ÐÐ÷	ð 	ús   Å )FÆF%)rG   Úloggingr4   r‘   r   r   r   r   r   Ú	getLoggerr„   ry   r	   r?   r   r   r   ú<module>r—      s;   ðÛ Û Û 	Û ç -Ó -à€g×Ñ˜Ó!€÷U.ñ U.óp
r   