Configure a Compute Environment to use private CRAN/Conda/PyPi mirrorsΒΆ

Many of our customers maintain internal mirrors of public package repos. This is typically done in concert with removing access to external, public repos via the use of a whitelist. This may be for security or for standardization.

By adding the following to your Dockerfile instructions of your global compute environments, you can set Conda, pip or Rstudio to reference your internal mirrors by default:

USER root

   # Add $CUSTOMER mirrors to condarc config files. Also disabled auto_update since mirrors are not always up to date.
   printf "\nchannels:\n  - $CUSTOMER_CHANNEL_1\n  - $CUSTOMER_CHANNEL_1\n\n" >> /opt/conda/.condarc && \
   printf "\nallow_other_channels: False\n" >> /opt/conda/.condarc && \
   printf "\nssl_verify: False \n" >> /opt/conda/.condarc && \
   printf "\nshow_channel_urls: True\n" >> /opt/conda/.condarc && \
   printf "\nauto_update_conda: False\n" >> /opt/conda/.condarc && \
   # Pointing R to $CUSTOMER CRAN mirror
   printf "\nlocal({ \n  r <- getOption('repos') \n  r['CRAN'] <- '$CRAN_MIRROR_URL' \n options(repos = r) \n})\n" >> /home/ubuntu/.Rprofile && \
   # Pointing pip to $CUSTOMER PyPi mirror
   printf "[global]\nindex-url=$CUSTOMER_PYPI_MIRROR\ntrusted-host=$IP_OR_FQDN" > /etc/pip.conf && \
   chown -R ubuntu:ubuntu /home/ubuntu /opt/conda/

USER ubuntu