【问题标题】:Deploy Airflow to Docker from source code从源代码将 Airflow 部署到 Docker
【发布时间】:2023-03-24 10:23:01
【问题描述】:

我已将 Airflow repo https://github.com/apache/airflow 克隆到本地并尝试构建以便稍后在 docker 中运行到 Azure。

我不确定这个过程。我收到一个错误

错误 [airflow-build-image 11/12] 如果 [[ apache-airflow == "." 则运行]];然后 bash /scripts/docker/compile_www_assets.sh;菲;如果 [[ 2.5s**

---------------------- 修改问题------------------ 在 windows 上安装 ubuntu (WSL2) 并克隆气流 repo 并开始构建 docker 映像。我在 ma​​in 分支上。

docker build . -f Dockerfile --tag airflow-image-20210913:0.0.1

控制台错误:

    admin@Laptop-1:~/airflow$ docker build . -f Dockerfile --tag airflow-image-20210913:0.0.1
    [+] Building 41.4s (19/26)
    => [internal] load build definition from Dockerfile                                                               0.2s
    => => transferring dockerfile: 21.40kB                                                                            0.0s
    => [internal] load .dockerignore                                                                                  0.1s
    => => transferring context: 3.14kB                                                                                0.0s
    => [internal] load metadata for docker.io/library/python:3.6-slim-buster                                         24.4s
    => [internal] load build context                                                                                  0.1s
    => => transferring context: 40.64kB                                                                               0.0s
    => [airflow-build-image  1/12] FROM docker.io/library/python:3.6-slim-buster@sha256:760b66a8a90751b711bf20243c02  0.0s
    => CACHED [main  2/11] RUN apt-get update     && apt-get install -y --no-install-recommends            curl       0.0s
    => CACHED [main  3/11] RUN mkdir -pv /usr/share/man/man1     && mkdir -pv /usr/share/man/man7     && export       0.0s
    => CACHED [main  4/11] COPY scripts/docker/install_mysql.sh scripts/docker/install_pip_version.sh /scripts/docke  0.0s
    => CACHED [main  5/11] RUN chmod a+x /scripts/docker/install_mysql.sh &&     /scripts/docker/install_mysql.sh pr  0.0s
    => CACHED [airflow-build-image  2/12] RUN apt-get update     && apt-get install -y --no-install-recommends        0.0s
    => CACHED [airflow-build-image  3/12] RUN mkdir -pv /usr/share/man/man1     && mkdir -pv /usr/share/man/man7      0.0s
    => CACHED [airflow-build-image  4/12] COPY scripts/docker/*.sh /scripts/docker/                                   0.0s
    => CACHED [airflow-build-image  5/12] RUN bash ./scripts/docker/install_mysql.sh dev                              0.0s
    => [airflow-build-image  6/12] COPY docker-context-files /docker-context-files                                    0.1s
    => [airflow-build-image  7/12] RUN if [[ -f /docker-context-files/.pypirc ]]; then         cp /docker-context-fi  0.8s
    => [airflow-build-image  8/12] RUN bash /scripts/docker/install_pip_version.sh;     if [[ false == "true" &&     12.0s
    => [airflow-build-image  9/12] COPY empty /empty                                                                  0.1s
    => [airflow-build-image 10/12] WORKDIR /opt/airflow                                                               0.2s
    => ERROR [airflow-build-image 11/12] RUN if [[ apache-airflow == "." ]]; then         bash /scripts/docker/compi  3.2s
    ------
    > [airflow-build-image 11/12] RUN if [[ apache-airflow == "." ]]; then         bash /scripts/docker/compile_www_assets.sh;     fi;     if [[  == "true" ]]; then         bash /scripts/docker/install_from_docker_context_files.sh;     elif [[ true == "true" ]]; then         bash /scripts/docker/install_airflow.sh;     fi;     if [[ -n "" ]]; then         bash /scripts/docker/install_additional_dependencies.sh;     fi;     find /root/.local/ -name '*.pyc' -print0 | xargs -0 rm -r || true ;     find /root/.local/ -type d -name '__pycache__' -print0 | xargs -0 rm -r || true ;     find /root/.local -executable -print0 | xargs --null chmod g+x;     find /root/.local -print0 | xargs --null chmod g+rw:
    #19 0.669 + [[ apache-airflow == \. ]]
    #19 0.669 + [[ '' == \t\r\u\e ]]
    #19 0.669 + [[ true == \t\r\u\e ]]
    #19 0.669 + bash /scripts/docker/install_airflow.sh
    #19 0.675 + common::get_airflow_version_specification
    #19 0.675 + [[ -z '' ]]
    #19 0.675 + [[ -n 2.2.0.dev0 ]]
    #19 0.675 + [[ apache-airflow != \. ]]
    #19 0.676 + AIRFLOW_VERSION_SPECIFICATION===2.2.0.dev0
    #19 0.676 + common::override_pip_version_if_needed
    #19 0.676 + [[ -n 2.2.0.dev0 ]]
    #19 0.676 + [[ 2.2.0.dev0 =~ ^2\.0.* ]]
    #19 0.676 + [[ 2.2.0.dev0 =~ ^1\.* ]]
    #19 0.676 + common::get_constraints_location
    #19 0.676 + [[ -z '' ]]
    #19 0.676 + [[ 2.2.0.dev0 =~ v?2.* ]]
    #19 0.676 + AIRFLOW_CONSTRAINTS_REFERENCE=constraints-2.2.0.dev0
    #19 0.676 + [[ -z '' ]]
    #19 0.676 + local constraints_base=https://raw.githubusercontent.com/apache/airflow/constraints-2.2.0.dev0
    #19 0.676 + local python_version
    #19 0.678 ++ cut -d ' ' -f 2
    #19 0.678 ++ python --version
    #19 0.682 ++ cut -d . -f 1-2
    #19 0.686 + python_version=3.6
    #19 0.689
    #19 0.689 Installing all packages with constraints and upgrade if needed
    #19 0.689
    #19 0.690 + AIRFLOW_CONSTRAINTS_LOCATION=https://raw.githubusercontent.com/apache/airflow/constraints-2.2.0.dev0/constraints-3.6.txt
    #19 0.690 + install_airflow
    #19 0.690 + [[ apache-airflow != \. ]]
    #19 0.690 + [[ '' == \-\-\e\d\i\t\a\b\l\e ]]
    #19 0.690 + [[ true != \t\r\u\e ]]
    #19 0.690 + [[ false != \f\a\l\s\e ]]
    #19 0.690 + echo
    #19 0.690 + echo Installing all packages with constraints and upgrade if needed
    #19 0.690 + echo
    #19 0.690 + pip install --user 'apache-airflow[async,amazon,celery,cncf.kubernetes,docker,dask,elasticsearch,ftp,grpc,hashicorp,http,ldap,google,google_auth,microsoft.azure,mysql,pandas,postgres,redis,sendgrid,sftp,slack,ssh,statsd,virtualenv]==2.2.0.dev0' --constraint https://raw.githubusercontent.com/apache/airflow/constraints-2.2.0.dev0/constraints-3.6.txt
    #19 2.227 ERROR: 404 Client Error: Not Found for url: https://raw.githubusercontent.com/apache/airflow/constraints-2.2.0.dev0/constraints-3.6.txt
    ------
    executor failed running [/bin/bash -o pipefail -e -u -x -c if [[ ${AIRFLOW_INSTALLATION_METHOD} == "." ]]; then         bash /scripts/docker/compile_www_assets.sh;     fi;     if [[ ${INSTALL_FROM_DOCKER_CONTEXT_FILES} == "true" ]]; then         bash /scripts/docker/install_from_docker_context_files.sh;     elif [[ ${INSTALL_FROM_PYPI} == "true" ]]; then         bash /scripts/docker/install_airflow.sh;     fi;     if [[ -n "${ADDITIONAL_PYTHON_DEPS}" ]]; then         bash /scripts/docker/install_additional_dependencies.sh;     fi;     find /root/.local/ -name '*.pyc' -print0 | xargs -0 rm -r || true ;     find /root/.local/ -type d -name '__pycache__' -print0 | xargs -0 rm -r || true ;     find /root/.local -executable -print0 | xargs --null chmod g+x;     find /root/.local -print0 | xargs --null chmod g+rw]: exit code: 1

--------------------- 编辑 -3 ----------------

我在 python 3.8 上并成功构建和安装,但在调用 airflow

时出错

【问题讨论】:

  • 请发布您的Dockerfile
  • 我正在使用来自 repo github.com/apache/airflow/blob/main/Dockerfile的那个
  • 如果你使用的是官方的 Dockerfile 没有修改,你可以直接从 Dockerhub 克隆 hub.docker.com/r/apache/airflow 而不是构建相同的镜像。
  • 我很抱歉造成混乱。我想做一些代码更改。或更改徽标并在更改的基础上构建图像。我使用的是 Windows 机器,并且安装了 Docker Desktop。
  • 您最近的错误看起来像依赖问题。对于您的确切版本的python,可能不支持/无法在Windows系统上安装pandas。

标签: docker dockerfile airflow


【解决方案1】:

您尚未显示完整的错误消息。您也没有发布您使用的命令、您拥有的操作系​​统以及您的文件系统/Docker 引擎是什么。所有这些都很重要。

真正的错误可能在下面。我认为问题在于您正在 Windows 上构建它并且您的系统不支持可执行标志。在 WSL2 或 Linux VM 上构建它,它应该可以正常工作。

如果您收到消息的其余部分,我什至可以修复它,以便它也可以在 Windows 上运行。因此,请随时更新它并在 Airflow Slack 上联系我,或者如果您转储了您拥有的整个错误消息,请在此处联系我。

顺便说一句。这里有一整章关于使用气流 dockerfile 构建自定义图像:https://airflow.apache.org/docs/docker-stack/build.html#customizing-the-image

【讨论】:

  • 嗨 @Jarek Potiuk,我已经开始在 Ubuntu (WSL2) 上构建 docker 映像。我在本地气流 git 的主分支上,我尝试了这个命令。码头工人建造。 -f Dockerfile --tag 气流图像:0.0.1 我收到此错误:错误:404 客户端错误:找不到 url:raw.githubusercontent.com/apache/airflow/constraints-2.2.0.dev0/…
  • 主分支不适用于以这种方式构建映像 - 您应该使用特定版本的 Airflow 进行安装,因为 Airflow 2.2.0 尚未发布。使用标签发布,或通过气流版本--build-arg AIRFLOW_VERSION="2.1.3" 传递版本
  • 感谢@Jarek Potiuk 为您的 cmets。已将气流版本设置为 env 级别并出现熊猫依赖错误。我将在问题描述中添加屏幕截图。
猜你喜欢
  • 2021-11-07
  • 2012-08-22
  • 2014-10-17
  • 1970-01-01
  • 2018-02-24
  • 1970-01-01
  • 2010-12-19
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多