Skip to content

Commit

Permalink
Add CONDA_PROXY_SERVER and CRAN_PROXY_SERVER private_env
Browse files Browse the repository at this point in the history
This means installing conda and RStudio will not automatically configure a default server which is only useful for HIC-TRE images.
  • Loading branch information
manics committed Jun 19, 2024
1 parent 40e1260 commit e20e4b8
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 19 deletions.
9 changes: 6 additions & 3 deletions modules/conda-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,12 @@ for env in "${SETUPDIR}"/conda-environment*.yml ; do
~/conda/bin/mamba env update --file "$env"
done

echo "Setting default conda channel"
cat > "$HOME/.condarc" <<EOF
# Internal Conda proxy or repository
if [ -n "${CONDA_PROXY_SERVER:-}" ]; then
echo "Configuring Conda proxy ${CONDA_PROXY_SERVER}"
cat > "$HOME/.condarc" <<EOF
channels:
- conda-forge
channel_alias: http://conda.hic-tre.dundee.ac.uk
channel_alias: ${CONDA_PROXY_SERVER}
EOF
fi
14 changes: 9 additions & 5 deletions modules/conda.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,14 @@ if ( Test-Path -Path ${BASE_ENVIRONMENT_YML} -PathType Leaf ) {
Write-Output "$BASE_ENVIRONMENT_YML not found, skipping"
}

$condarc = "C:\Users\Administrator\.condarc"
New-Item $condarc
Set-Content $condarc "channels:"
Add-Content $condarc " - conda-forge"
Add-Content $condarc "channel_alias: http://conda.hic-tre.dundee.ac.uk"
# Internal Conda proxy or repository
if ( $Env:CONDA_PROXY_SERVER ) {
Write-Output "Configuring conda proxy ${Env:CONDA_PROXY_SERVER}"
$condarc = "C:\Users\Administrator\.condarc"
New-Item $condarc
Set-Content $condarc "channels:"
Add-Content $condarc " - conda-forge"
Add-Content $condarc "channel_alias: ${Env:CONDA_PROXY_SERVER}"
}

conda deactivate
17 changes: 12 additions & 5 deletions modules/rstudio.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,21 @@ $RConfig = @"
# Set the default help type
options(help_type="html")
# HIC TRE R Repository
# Set timezone
Sys.setenv(TZ='Europe/London')
"@

# Internal CRAN proxy or repository
if ( $Env:CRAN_PROXY_SERVER ) {
Write-Output "Configuring CRAN proxy ${Env:CRAN_PROXY_SERVER}"
$RConfig += @"
local({r <- getOption("repos")
r["CRAN"] <- "http://cran.hic-tre.dundee.ac.uk/"
r["CRAN"] <- "${Env:CRAN_PROXY_SERVER}"
options(repos=r)
})
# Set timezone
Sys.setenv(TZ='Europe/London')
"@
}

Set-Content "C:\Program Files\R\R-4.4.0\etc\Rprofile.site" $RConfig
Set-Content "C:\Users\Administrator\Documents\.Renviron" "RSTUDIO_DISABLE_SECURE_DOWNLOAD_WARNING=1"
17 changes: 11 additions & 6 deletions modules/rstudio.sh
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +42,21 @@ cat > "$HOME/.Rprofile" <<EOF
# Set the default help type
options(help_type="html")
# HIC TRE R Repository
local({r <- getOption("repos")
r["CRAN"] <- "http://cran.hic-tre.dundee.ac.uk/"
options(repos=r)
})
# Set timezone
Sys.setenv(TZ='Europe/London')
EOF

# Internal CRAN proxy or repository
if [ -n "${CRAN_PROXY_SERVER:-}" ]; then
echo "Configuring CRAN proxy ${CRAN_PROXY_SERVER}"
cat >> "$HOME/.Rprofile" <<EOF
local({r <- getOption("repos")
r["CRAN"] <- "$CRAN_PROXY_SERVER"
options(repos=r)
})
EOF
fi

echo "RSTUDIO_DISABLE_SECURE_DOWNLOAD_WARNING=1" >> "$HOME/.Renviron"

sudo add-apt-repository -y ppa:c2d4u.team/c2d4u4.0+
Expand Down
6 changes: 6 additions & 0 deletions templates/default.j2
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@

{% set env = env|default([],true) %}
{% set private_env = private_env|default([],true) %}
{# For example, to configure an internal CRAN and conda proxy/repository:
{% set private_env = [
"CONDA_PROXY_SERVER=http://conda.hic-tre.dundee.ac.uk",
"CRAN_PROXY_SERVER=http://cran.hic-tre.dundee.ac.uk/",
] %}
#}

{% set modules = modules|default([],true) %}
{% set security_modules = security_modules|default([],true) %}
Expand Down

0 comments on commit e20e4b8

Please sign in to comment.