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:

RUN \
    # 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" >> /usr/local/anaconda/.condarc && \
    printf "\nallow_other_channels: False\n" >> /usr/local/anaconda/.condarc && \
    printf "\nssl_verify: False \n" >> /usr/local/anaconda/.condarc && \
    printf "\nshow_channel_urls: True\n" >> /usr/local/anaconda/.condarc && \
    printf "\nauto_update_conda: False\n" >> /usr/local/anaconda/.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
    RUN printf "[global]\nindex-url=$CUSTOMER_PYPI_MIRROR\ntrusted-host=$IP_OR_FQDN" > /etc/pip.conf && \
 
    chown -R ubuntu:ubuntu /home/ubuntu /usr/local/anaconda/.condarc \ 
Was this article helpful?
0 out of 0 found this helpful