GoogleCloudPlatform / composer-local-dev

Apache License 2.0
75 stars 38 forks source link

Enable usage of artifact-repository in composer-dev template #21

Closed mokshasoul closed 7 months ago

mokshasoul commented 1 year ago

This enables composer-dev environments to use private pip repositories from GCP artifact-registry.

google-cla[bot] commented 1 year ago

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

mokshasoul commented 1 year ago

Thanks for the PR, please see my comments and please make the PR point to the development branch (we will resync this to main afterwards).

Hey @piotrwrotniak , just switched the branch as well, didn't see this comment thx for reviewing this

aflansburg commented 1 year ago

Noticed this is stale-ish :( The change proposed by this PR would be most welcome. We had a similar solution as we use several in-house developed packages located in GCP Artifact Registry:

# added to composer_local_dev/docker_files/entrypoint.sh
sudo chown airflow:airflow .config

if [ -n "${PRIVATE_INDEX_URLS}" ]; then
  echo "Adding private PyPI repository indexes: ${PRIVATE_INDEX_URLS}"
  pip3 install keyring keyrings.google-artifactregistry-auth

  # Split PRIVATE_INDEX_URLS by comma and create a space-separated string of URLs
  OLDIFS=$IFS
  IFS=','
  # shellcheck disable=SC2086
  set -- $PRIVATE_INDEX_URLS
  IFS=$OLDIFS
  EXTRA_INDEX_URLS=""
  for url; do
    EXTRA_INDEX_URLS="${EXTRA_INDEX_URLS} ${url}"
  done
  # Export the URLs as an environment variable
  export PIP_EXTRA_INDEX_URL="${EXTRA_INDEX_URLS}"
  printf 'PIP_EXTRA_INDEX_URL="%s"\n' "${PIP_EXTRA_INDEX_URL}"
fi

And adding our PRIVATE_INDEX_URLS in the generated composer/local-airflow-dev/variables.env unquoted and comma delimited seemed to work well when using multiple private packages in Artifact registry.

mokshasoul commented 7 months ago

x