我正在开发一个 GCP 数据流项目,该项目创建 flex 模板并且它正在使用云构建运行。 我试图通过云运行而不是使用云构建来运行,但我遇到了一些狡猾的错误。我怀疑我构建 Dockerfile 的方式使其无法同时用于 cloudbuild 和 cloudrun。 下面是我的 dockerfile
FROM gcr.io/dataflow-templates-base/python3-template-launcher-base
ARG WORKDIR=/dataflow/template
RUN mkdir -p ${WORKDIR}
RUN mkdir -p ${WORKDIR}/modules
WORKDIR ${WORKDIR}
COPY spec/python_command_spec.json ${WORKDIR}/python_command_spec.json
COPY modules ${WORKDIR}/modules
ENV DATAFLOW_PYTHON_COMMAND_SPEC ${WORKDIR}/python_command_spec.json
RUN pip install avro-python3 pyarrow==0.15.1 apache-beam[gcp]==2.27.0 pandas-datareader==0.9.0
RUN apt-get update && apt-get install -y iputils-ping dnsutils
COPY __init__.py ${WORKDIR}/__init__.py
COPY setup.py ${WORKDIR}/setup.py
COPY main.py ${WORKDIR}/main.py
# Super important to add these lines.
ENV FLEX_TEMPLATE_PYTHON_SETUP_FILE="${WORKDIR}/setup.py"
ENV FLEX_TEMPLATE_PYTHON_PY_FILE="${WORKDIR}/main.py"
#RUN python ${WORKDIR}/setup.py install
RUN echo '----- listing workdir'
RUN ls -la ${WORKDIR}
RUN echo '-- pinging google--'
RUN echo '-- pinging sec.gov'
RUN echo '--- bulding image---'
ENTRYPOINT [ "/opt/apache/beam/boot" ]
最后一行允许我使用以下 yaml 运行我的模板
substitutions:
_IMAGE: my_logic:latest2
_JOB_NAME: 'pipelinerunner'
_TEMP_LOCATION: ''
_REGION: us-central1
_FMPKEY: ''
steps:
- name: gcr.io/$PROJECT_ID/$_IMAGE
entrypoint: python
args:
- /dataflow/template/main.py
- --runner=DataflowRunner
- --project=$PROJECT_ID
- --region=$_REGION
- --job_name=$_JOB_NAME
- --temp_location=$_TEMP_LOCATION
- --sdk_container_image=gcr.io/$PROJECT_ID/$_IMAGE
- --disk_size_gb=50
- --year=2018
- --quarter=QTR1
- --fmpkey=$_FMPKEY
- --setup_file=/dataflow/template/setup.py
options:
logging: CLOUD_LOGGING_ONLY
但是,使用上面的 docker,每当我启动 cloudrun 时,我都会收到此异常
terminated: Application failed to start: Failed to create init process: failed to load /opt/apache/beam/boot: no such file or directory
我错过了什么? 问候 马可