Building your custom image
Create a Dockerfile and a custom-requirements.txt
file in your project directory. Adapt the following steps for your registry and
requirements.
-
Create a requirements file.
List only the additional Python packages you require. Pin versions where possible to maintain stability.
# custom-requirements.txt apache-airflow-providers-databricks some-internal-library==1.2.3 -
Write a Docker file.
Extend the official Cloudera Workflow Orchestrator base image. The virtual environment resides at /opt/airflow_venv. Install packages using the uv pip install command.
ARG UV_VERSION=0.13.7 ARG AIRFLOW_VENV_DIR=/opt/airflow_venv ARG CWO_BASE_IMAGE=[***CWO-BASE-IMAGE-NAME***] FROM ${CWO_BASE_IMAGE} ARG UV_VERSION ARG AIRFLOW_VENV_DIR USER root COPY [***REQUIREMENTS-FILE-PATH-IN-DOCKER***] [***REQUIREMENTS-FILE-PATH-IN-TMP-DIRECTORY***] RUN pip install --disable-pip-version-check --no-cache-dir "uv==${UV_VERSION}" && \ uv pip install --python "${AIRFLOW_VENV_DIR}/bin/python" \ --no-cache-dir \ -r [***REQUIREMENTS-FILE-PATH-IN-TMP-DIRECTORY***] \ --constraint /usr/local/airflow/constraints.txt && \ rm [***REQUIREMENTS-FILE-PATH-IN-TMP-DIRECTORY***] USER 50000Example,
ARG UV_VERSION=0.13.7 ARG AIRFLOW_VENV_DIR=/opt/airflow_venv ARG CWO_BASE_IMAGE=cloudera-airflow-base:local FROM ${CWO_BASE_IMAGE} ARG UV_VERSION ARG AIRFLOW_VENV_DIR USER root COPY docker/custom-image/custom-requirements.txt /tmp/custom-requirements.txt RUN pip install --disable-pip-version-check --no-cache-dir "uv==${UV_VERSION}" && \ uv pip install --python "${AIRFLOW_VENV_DIR}/bin/python" \ --no-cache-dir \ -r /tmp/custom-requirements.txt \ --constraint /usr/local/airflow/constraints.txt && \ rm /tmp/custom-requirements.txt USER 50000 -
Build and push the custom image on top of the Cloudera Workflow Orchestrator base image for your Airflow and Python version.
export CWO_BASE_IMAGE="[***CWO-BASE-IMAGE-NAME***]" export CUSTOM_IMAGE="[***CUSTOM-IMAGE-NAME***]" export BUILDX_FLAGS = [***PLATFORM-BUILD-FLAGS***] docker build ${BUILDX_FLAGS} \ --build-arg CWO_BASE_IMAGE="${CWO_BASE_IMAGE}" \ -t "${CUSTOM_IMAGE}" \ -f Dockerfile \ . docker push "${CUSTOM_IMAGE}"Example,
export CWO_BASE_IMAGE="${REGISTRY}/${REGISTRY_NAMESPACE}/cloudera-airflow-3.4.0-py3.12:2.0.0-dev" export CUSTOM_IMAGE="${REGISTRY}/${REGISTRY_NAMESPACE}/cwo-airflow-custom:test" export BUILDX_FLAGS = --load --platform=linux/amd64,linux/arm64 docker build ${BUILDX_FLAGS} \ --build-arg CWO_BASE_IMAGE="${CWO_BASE_IMAGE}" \ -t "${CUSTOM_IMAGE}" \ -f Dockerfile \ . docker push "${CUSTOM_IMAGE}" -
Before registering the image in Anywhere Cloud, verify the
image manually.
# Confirm Airflow version and Python version docker run --rm [***CUSTOM-IMAGE-NAME***] \ airflow version docker run --rm [***CUSTOM-IMAGE-NAME***] \ python --versionExample,
# Confirm Airflow version and Python version docker run --rm your-registry.example.com/your-org/cwo-airflow-custom:1.0.0 \ airflow version docker run --rm your-registry.example.com/your-org/cwo-airflow-custom:1.0.0 \ python --version -
Configure the image in Anywhere Cloud.
Update the following fields during Cloudera Workflow Orchestrator deployment using the built custom image.
- Enable Custom Image: Select the checkbox to enable the custom image feature.
- Image Name: Enter the image name with a tag
excluding registry. For example,
cloudera/cwo-airflow-custom:1.0.0. - Docker Registry: The registry hostname where the images are available.
- Docker Registry Username: The username for registry authentication.
- Docker Registry Password: The password for registry authentication.
- (Optional) Docker Registry Email: The email address associated with the account.
For information about deployment, see Deploying Cloudera Workflow Orchestrator.
