ansible / awx

AWX provides a web-based user interface, REST API, and task engine built on top of Ansible. It is one of the upstream projects for Red Hat Ansible Automation Platform.
Other
14.09k stars 3.43k forks source link

make docker-compose-build behind proxy #10585

Closed Sispheor closed 3 years ago

Sispheor commented 3 years ago

Please confirm the following

Summary

Hello. I've set my Docker proxy into /etc/systemd/system/docker.service.d/http-proxy.conf and it helped on task that perform http get. But dnf does not rely on the environment and so fail to install packages into the image on build.

DOCKER_BUILDKIT=1 docker build -t quay.io/awx/awx_devel:HEAD \
>     --build-arg BUILDKIT_INLINE_CACHE=1 \
>     --cache-from=quay.io/awx/awx_devel:HEAD .
[+] Building 233.4s (7/44)                                                                                                                                                                                                           
[+] Building 233.6s (7/44)                                                                                                                                                                                                           
[+] Building 372.0s (8/44)                                                                                                                                                                                                           
 => [internal] load build definition from Dockerfile                                                                                                                                                                            0.0s
 => => transferring dockerfile: 97B                                                                                                                                                                                             0.0s
 => [internal] load .dockerignore                                                                                                                                                                                               0.0s
 => => transferring context: 93B                                                                                                                                                                                                0.0s
 => [internal] load metadata for quay.io/centos/centos:8                                                                                                                                                                        2.2s
 => ERROR importing cache manifest from quay.io/awx/awx_devel:HEAD                                                                                                                                                              0.7s
 => FROM quay.io/project-receptor/receptor:1.0.0a2                                                                                                                                                                             10.6s
 => => resolve quay.io/project-receptor/receptor:1.0.0a2                                                                                                                                                                        3.5s
 => => sha256:de2fa1c557bb5d6711ec39c29dbd4bc4f486ecabbd8117d1f5b61380745900e2 71.13MB / 71.13MB                                                                                                                                3.7s
 => => sha256:13b22e37f9ac593df4f123298fd3a7d05ac384cfd56d9f995bfa8e942c2eda17 4.42kB / 4.42kB                                                                                                                                  0.0s
 => => sha256:8a567f7090e51217faa2895b97a28c723ff5e7527468a23254adf259dbb2917f 19.68MB / 19.68MB                                                                                                                                2.1s
 => => sha256:4ec4162e908fe1c108c1f9eeeec8930ec1dae5659fb3a6362d611beb73dbde7b 1.99kB / 1.99kB                                                                                                                                  0.0s
 => => sha256:57214ae8030d4ffc3f77ebd51c4368f8b5dfc8ab0a99702662399be1aef1b15f 8.51kB / 8.51kB                                                                                                                                  2.2s
 => => sha256:75b1e83199024b87b5a32bfd27ed44be14339ebeaa695cd2b8485fc60f941425 36.41kB / 36.41kB                                                                                                                                3.3s
 => => sha256:80ace88f767c7d014d6742e0c9554a6b14c293b92fd1de54d5fe1fc9b674a618 1.59kB / 1.59kB                                                                                                                                  3.3s
 => => sha256:a03d20add3790a3050df32ec5d7b50204e4b8c82b475fa35d4c5df438fc11dc6 255B / 255B                                                                                                                                      4.2s
 => => sha256:85479aa9e6878287e9b79644ea44ea5ccb45d9954767b41d146112d4bc0c276c 188B / 188B                                                                                                                                      4.2s
 => => sha256:64f2ab4e59f4eccd9ef465ecb40d527c0c1a166d30837489870ed78db886532c 19.42MB / 19.42MB                                                                                                                                5.2s
 => => extracting sha256:de2fa1c557bb5d6711ec39c29dbd4bc4f486ecabbd8117d1f5b61380745900e2                                                                                                                                       4.0s
 => => extracting sha256:8a567f7090e51217faa2895b97a28c723ff5e7527468a23254adf259dbb2917f                                                                                                                                       1.3s
 => => extracting sha256:57214ae8030d4ffc3f77ebd51c4368f8b5dfc8ab0a99702662399be1aef1b15f                                                                                                                                       0.0s
 => => extracting sha256:80ace88f767c7d014d6742e0c9554a6b14c293b92fd1de54d5fe1fc9b674a618                                                                                                                                       0.0s
 => => extracting sha256:75b1e83199024b87b5a32bfd27ed44be14339ebeaa695cd2b8485fc60f941425                                                                                                                                       0.1s
 => => extracting sha256:85479aa9e6878287e9b79644ea44ea5ccb45d9954767b41d146112d4bc0c276c                                                                                                                                       0.0s
 => => extracting sha256:a03d20add3790a3050df32ec5d7b50204e4b8c82b475fa35d4c5df438fc11dc6                                                                                                                                       0.0s
 => => extracting sha256:64f2ab4e59f4eccd9ef465ecb40d527c0c1a166d30837489870ed78db886532c                                                                                                                                       0.7s
 => [internal] load build context                                                                                                                                                                                               0.0s
 => => transferring context: 41.41kB                                                                                                                                                                                            0.0s
 => [stage-1  1/30] FROM quay.io/centos/centos:8@sha256:8301d100020ffaedc93f57d8c8bb0e8e88006862bcb48ebc5dfbe1d1cb83060c                                                                                                        8.4s
 => => resolve quay.io/centos/centos:8@sha256:8301d100020ffaedc93f57d8c8bb0e8e88006862bcb48ebc5dfbe1d1cb83060c                                                                                                                  0.0s
 => => sha256:8301d100020ffaedc93f57d8c8bb0e8e88006862bcb48ebc5dfbe1d1cb83060c 743B / 743B                                                                                                                                      0.0s
 => => sha256:dbbacecc49b088458781c16f3775f2a2ec7521079034a7ba499c8b0bb7f86875 529B / 529B                                                                                                                                      0.0s
 => => sha256:300e315adb2f96afe5f0b2780b87f28ae95231fe3bdd1e16b9ba606307728f55 2.14kB / 2.14kB                                                                                                                                  0.0s
 => => sha256:7a0437f04f83f084b7ed68ad9c4a4947e12fc4e1b006b38129bac89114ec3621 75.18MB / 75.18MB                                                                                                                                3.9s
 => => extracting sha256:7a0437f04f83f084b7ed68ad9c4a4947e12fc4e1b006b38129bac89114ec3621                                                                                                                                       4.3s
 => ERROR [stage-1  2/30] RUN dnf -y module enable 'postgresql:12'                                                                                                                                                            360.7s
------                                                                                                                                                                                                                               
 > importing cache manifest from quay.io/awx/awx_devel:HEAD:
------
------
 > [stage-1  2/30] RUN dnf -y module enable 'postgresql:12':
#6 0.284 /bin/sh: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8)
#6 360.6 CentOS Linux 8 - AppStream                      0.0  B/s |   0  B     06:00    
#6 360.6 Failed to set locale, defaulting to C.UTF-8
#6 360.6 Errors during downloading metadata for repository 'appstream':
#6 360.6   - Curl error (28): Timeout was reached for http://mirrorlist.centos.org/?release=8&arch=x86_64&repo=AppStream&infra=container [Connection timed out after 30000 milliseconds]
#6 360.6 Error: Failed to download metadata for repo 'appstream': Cannot prepare internal mirrorlist: Curl error (28): Timeout was reached for http://mirrorlist.centos.org/?release=8&arch=x86_64&repo=AppStream&infra=container [Connection timed out after 30000 milliseconds]
------
executor failed running [/bin/sh -c dnf -y module enable 'postgresql:12']: exit code: 1

AWX version

19.2.2

Installation method

docker on linux

Modifications

no

Ansible version

2.9.23

Operating system

CentOS Linux release 8.4.2105

Web browser

No response

Steps to reproduce

Step 1 - Being behind a proxy

Step 2:

make docker-compose-build

Expected results

images are built

Actual results

Fail on image bulding

Additional information

At first I had another error related to the proxy

OCKER_BUILDKIT=1 docker build -t quay.io/awx/awx_devel:HEAD \
    --build-arg BUILDKIT_INLINE_CACHE=1 \
    --cache-from=quay.io/awx/awx_devel:HEAD .
[+] Building 68.8s (3/3) FINISHED                                                                                                                                                                                                    
 => [internal] load build definition from Dockerfile                                                                                                                                                                            0.0s
 => => transferring dockerfile: 6.80kB                                                                                                                                                                                          0.0s
 => [internal] load .dockerignore                                                                                                                                                                                               0.0s
 => => transferring context: 155B                                                                                                                                                                                               0.0s
 => ERROR [internal] load metadata for quay.io/centos/centos:8                                                                                                                                                                 68.7s
------
 > [internal] load metadata for quay.io/centos/centos:8:
------
failed to solve with frontend dockerfile.v0: failed to create LLB definition: failed to copy: httpReadSeeker: failed open: failed to do request: Get https://cdn02.quay.io/sha256/30/300e315adb2f96afe5f0b2780b87f28ae95231fe3bdd1e16b9ba606307728f55?Expires=1625490587&Signature=JLy24XiusuHLMtsEMU55IvaJOsDzuvSrwHS8E4~AscNRrVvd7ho4q~SWa7x-bo1K6DPN1-DFefek9QETZ~H8Yyf~Foi0X~uR4Og8kcdRIYhoLlgiVJ5F

I fixed this one by adding the proxy to the Docker config.

Sispheor commented 3 years ago

I just added the proxy to the build arguments. And it's ok. Maybe it could be wrapped by the make command.

DOCKER_BUILDKIT=1 docker build -t quay.io/awx/awx_devel:HEAD \
--build-arg BUILDKIT_INLINE_CACHE=1 \
--build-arg http_proxy=http://web-proxy.domain:8080 \
--build-arg https_proxy=http://web-proxy.domain:8080 \
--cache-from=quay.io/awx/awx_devel:HEAD .
Ali-Flt commented 9 months ago

You may need to run

export http_proxy=...
export https_proxy=...

before running the docker build command.