Skip to content

Commit 7fd73a8

Browse files
committed
Add CONDA_PROXY_SERVER and CRAN_PROXY_SERVER private_env
This means installing conda and RStudio will not automatically configure a default server which is only useful for HIC-TRE images.
1 parent 40e1260 commit 7fd73a8

File tree

5 files changed

+43
-19
lines changed

5 files changed

+43
-19
lines changed

modules/conda-setup.sh

+6-3
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,12 @@ for env in "${SETUPDIR}"/conda-environment*.yml ; do
2929
~/conda/bin/mamba env update --file "$env"
3030
done
3131

32-
echo "Setting default conda channel"
33-
cat > "$HOME/.condarc" <<EOF
32+
# Internal Conda proxy or repository
33+
if [ -n "${CONDA_PROXY_SERVER:-}" ]; then
34+
echo "Configuring Conda proxy ${CONDA_PROXY_SERVER}"
35+
cat > "$HOME/.condarc" <<EOF
3436
channels:
3537
- conda-forge
36-
channel_alias: http://conda.hic-tre.dundee.ac.uk
38+
channel_alias: ${CONDA_PROXY_SERVER}
3739
EOF
40+
fi

modules/conda.ps1

+9-5
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,14 @@ if ( Test-Path -Path ${BASE_ENVIRONMENT_YML} -PathType Leaf ) {
4040
Write-Output "$BASE_ENVIRONMENT_YML not found, skipping"
4141
}
4242

43-
$condarc = "C:\Users\Administrator\.condarc"
44-
New-Item $condarc
45-
Set-Content $condarc "channels:"
46-
Add-Content $condarc " - conda-forge"
47-
Add-Content $condarc "channel_alias: http://conda.hic-tre.dundee.ac.uk"
43+
# Internal Conda proxy or repository
44+
if ( $Env:CONDA_PROXY_SERVER ) {
45+
Write-Output "Configuring conda proxy ${Env:CONDA_PROXY_SERVER}"
46+
$condarc = "C:\Users\Administrator\.condarc"
47+
New-Item $condarc
48+
Set-Content $condarc "channels:"
49+
Add-Content $condarc " - conda-forge"
50+
Add-Content $condarc "channel_alias: ${Env:CONDA_PROXY_SERVER}"
51+
}
4852

4953
conda deactivate

modules/rstudio.ps1

+12-5
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,21 @@ $RConfig = @"
2525
# Set the default help type
2626
options(help_type="html")
2727
28-
# HIC TRE R Repository
28+
# Set timezone
29+
Sys.setenv(TZ='Europe/London')
30+
31+
"@
32+
33+
# Internal CRAN proxy or repository
34+
if ( $Env:CRAN_PROXY_SERVER ) {
35+
Write-Output "Configuring CRAN proxy ${Env:CRAN_PROXY_SERVER}"
36+
$RConfig += @"
2937
local({r <- getOption("repos")
30-
r["CRAN"] <- "http://cran.hic-tre.dundee.ac.uk/"
38+
r["CRAN"] <- "${Env:CRAN_PROXY_SERVER}"
3139
options(repos=r)
3240
})
33-
34-
# Set timezone
35-
Sys.setenv(TZ='Europe/London')
3641
"@
42+
}
43+
3744
Set-Content "C:\Program Files\R\R-4.4.0\etc\Rprofile.site" $RConfig
3845
Set-Content "C:\Users\Administrator\Documents\.Renviron" "RSTUDIO_DISABLE_SECURE_DOWNLOAD_WARNING=1"

modules/rstudio.sh

+10-6
Original file line numberDiff line numberDiff line change
@@ -42,16 +42,20 @@ cat > "$HOME/.Rprofile" <<EOF
4242
# Set the default help type
4343
options(help_type="html")
4444
45-
# HIC TRE R Repository
46-
local({r <- getOption("repos")
47-
r["CRAN"] <- "http://cran.hic-tre.dundee.ac.uk/"
48-
options(repos=r)
49-
})
50-
5145
# Set timezone
5246
Sys.setenv(TZ='Europe/London')
5347
EOF
5448

49+
# Internal CRAN proxy or repository
50+
if [ -n "${CRAN_PROXY_SERVER:-}" ]; then
51+
echo "Configuring CRAN proxy ${CRAN_PROXY_SERVER}"
52+
cat >> "$HOME/.Rprofile" <<EOF
53+
local({r <- getOption("repos")
54+
r["CRAN"] <- "$CRAN_PROXY_SERVER"
55+
options(repos=r)
56+
})
57+
EOF
58+
5559
echo "RSTUDIO_DISABLE_SECURE_DOWNLOAD_WARNING=1" >> "$HOME/.Renviron"
5660

5761
sudo add-apt-repository -y ppa:c2d4u.team/c2d4u4.0+

templates/default.j2

+6
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@
66

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

1016
{% set modules = modules|default([],true) %}
1117
{% set security_modules = security_modules|default([],true) %}

0 commit comments

Comments
 (0)