github.com/apache/beam/sdks/v2@v2.48.2/python/expansion-service-container/Dockerfile (about) 1 ############################################################################### 2 # Licensed to the Apache Software Foundation (ASF) under one 3 # or more contributor license agreements. See the NOTICE file 4 # distributed with this work for additional information 5 # regarding copyright ownership. The ASF licenses this file 6 # to you under the Apache License, Version 2.0 (the 7 # "License"); you may not use this file except in compliance 8 # with the License. You may obtain a copy of the License at 9 # 10 # http://www.apache.org/licenses/LICENSE-2.0 11 # 12 # Unless required by applicable law or agreed to in writing, software 13 # distributed under the License is distributed on an "AS IS" BASIS, 14 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 # See the License for the specific language governing permissions and 16 # limitations under the License. 17 ############################################################################### 18 19 # We just need to support one Python version supported by Beam. 20 # Picking the current default Beam Python version which is Python 3.8. 21 FROM python:3.8-bullseye as expansion-service 22 LABEL Author "Apache Beam <dev@beam.apache.org>" 23 ARG TARGETOS 24 ARG TARGETARCH 25 26 WORKDIR /opt/apache/beam 27 28 # Copy the Python source tarball. 29 COPY target/apache-beam-sdk.tar.gz /opt/apache/beam/ 30 31 # Copy the requirements file 32 COPY target/requirements.txt /opt/apache/beam/ 33 34 # Copy the boot program 35 COPY target/launcher/${TARGETOS}_${TARGETARCH}/boot /opt/apache/beam/ 36 37 # Creating a virtual environment and installing Beam. 38 # We do these steps in the Dockefile instead of the boot.go to minimize the 39 # startup time for the Python expansion service container. 40 RUN mkdir /opt/apache/beam/beam_venv &&\ 41 python3 -m venv /opt/apache/beam/beam_venv &&\ 42 . /opt/apache/beam/beam_venv/bin/activate &&\ 43 pip install --upgrade pip &&\ 44 pip install --upgrade setuptools &&\ 45 pip install -r requirements.txt &&\ 46 pip install apache-beam-sdk.tar.gz[gcp,dataframe] 47 48 ENTRYPOINT ["/opt/apache/beam/boot"] 49 50 #### 51 # Pull and add third party licenses to the image if pull_licenses is true. 52 # Use multistage build to eliminate unwanted changes to beam image due to 53 # extra dependencies needed to pull licenses. 54 #### 55 56 FROM expansion-service as third_party_licenses 57 ARG pull_licenses 58 COPY target/license_scripts /tmp/license_scripts/ 59 60 # Add golang licenses. 61 COPY target/go-licenses/* /opt/apache/beam/third_party_licenses/golang/ 62 63 COPY target/license_scripts /tmp/license_scripts/ 64 RUN if [ "$pull_licenses" = "true" ] ; then \ 65 pip install 'pip-licenses<5' pyyaml tenacity && \ 66 python /tmp/license_scripts/pull_licenses_py.py ; \ 67 fi 68 69 FROM expansion-service 70 ARG pull_licenses 71 COPY --from=third_party_licenses /opt/apache/beam/third_party_licenses /opt/apache/beam/third_party_licenses 72 RUN if [ "$pull_licenses" != "true" ] ; then \ 73 rm -rf /opt/apache/beam/third_party_licenses ; \ 74 fi