Skip to content

Commit 2dec0a7

Browse files
committed
Rebuild IR image with puthon 3.9
1 parent 564ab22 commit 2dec0a7

File tree

4 files changed

+252
-36
lines changed

4 files changed

+252
-36
lines changed

.circleci/config.yml

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ orbs:
44
aws-cli: circleci/aws-cli@5.1.1
55
docker: circleci/docker@2.8
66

7-
87
commands:
98
split_python_version:
109
steps:
@@ -169,6 +168,37 @@ jobs:
169168
--output type=registry,push=true \
170169
.
171170
171+
build-and-push-ir:
172+
executor: docker/docker
173+
parameters:
174+
r-version:
175+
type: string
176+
environment:
177+
R_VERSION: << parameters.r-version >>
178+
steps:
179+
- checkout
180+
- docker_login
181+
- split_python_version # This provides PYTHON_VERSION
182+
- setup_buildkit_builder
183+
- run:
184+
name: Build and push python-conda image
185+
command: |
186+
REPOSITORY="deepnote/ir"
187+
TAG="${R_VERSION}${CIRCLE_PULL_REQUEST:+-ra-${CIRCLE_PULL_REQUEST##*/}}"
188+
docker buildx build \
189+
--file=./ir/Dockerfile.ir \
190+
--tag=978928340082.dkr.ecr.us-east-1.amazonaws.com/${REPOSITORY}:${TAG} \
191+
--tag=docker.io/${REPOSITORY}:${TAG} \
192+
--build-arg R_VERSION=${R_VERSION} \
193+
--cache-from type=registry,ref=docker.io/${REPOSITORY}:${TAG}-buildcache,mode=max \
194+
--cache-to type=registry,ref=docker.io/${REPOSITORY}:${TAG}-buildcache,mode=max,image-manifest=true,oci-mediatypes=true \
195+
--progress plain \
196+
--platform linux/amd64 \
197+
--provenance=false \
198+
--sbom=false \
199+
--output type=registry,push=true \
200+
./ir
201+
172202
build-and-push-gpu:
173203
machine:
174204
image: ubuntu-2404:current
@@ -216,6 +246,11 @@ python-versions: &python-versions
216246
- "3.10.15"
217247
- "3.11.10"
218248

249+
r-versions: &r-versions
250+
- "3.5.2"
251+
- "4.0.4"
252+
- "4.2.0"
253+
219254
workflows:
220255
build:
221256
jobs:
@@ -242,6 +277,11 @@ workflows:
242277
python-version: *python-versions
243278
requires:
244279
- Building the base image
280+
- build-and-push-ir:
281+
name: R << matrix.r-version >>
282+
matrix:
283+
parameters:
284+
r-version: *r-versions
245285

246286
- build-and-push-gpu:
247287
name: Tensorflow 2.9

ir/Dockerfile

Lines changed: 0 additions & 35 deletions
This file was deleted.

ir/Dockerfile.ir

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# Define build arguments for Python and R versions
2+
ARG PYTHON_VERSION=3.9
3+
ARG R_VERSION=4.4.0
4+
5+
# Use the specified Python version as the base image
6+
FROM deepnote/python:${PYTHON_VERSION}
7+
8+
# Set environment variables
9+
# Use the R version specified by the build argument
10+
ENV R_VERSION="${R_VERSION}" \
11+
R_HOME="/usr/local/lib/R" \
12+
TZ="Etc/UTC" \
13+
DEFAULT_KERNEL_NAME="ir" \
14+
DEEPNOTE_PYTHON_KERNEL_ONLY=""
15+
16+
# Copy the R installation script and run it
17+
COPY install_R_source.sh /rocker_scripts/install_R_source.sh
18+
RUN chmod +x /rocker_scripts/install_R_source.sh && \
19+
/rocker_scripts/install_R_source.sh
20+
21+
# Set the working directory
22+
WORKDIR /opt
23+
24+
# Create and activate a virtual environment in one RUN command
25+
RUN python -m venv jupyter-env && \
26+
. ./jupyter-env/bin/activate && \
27+
pip install --upgrade pip notebook
28+
29+
# Install IRkernel and configure it
30+
RUN . ./jupyter-env/bin/activate && \
31+
R -e "install.packages('IRkernel', repos='http://cran.rstudio.com/')" && \
32+
R -e "IRkernel::installspec()"
33+
34+
# Clean up unnecessary files to reduce the image size
35+
RUN apt-get clean && \
36+
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

ir/install_R_source.sh

Lines changed: 175 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,175 @@
1+
#!/bin/bash
2+
3+
## Source of the installation file https://github.com/rocker-org/rocker-versioned2/blob/master/scripts/install_R_source.sh
4+
## Install R from source.
5+
##
6+
## In order of preference, first argument of the script, the R_VERSION variable.
7+
## ex. latest, devel, patched, 4.0.0
8+
##
9+
## 'devel' means the prerelease development version (Latest daily snapshot of development version).
10+
## 'patched' means the prerelease patched version (Latest daily snapshot of patched version).
11+
12+
set -e
13+
14+
R_VERSION=${1:-${R_VERSION:-"latest"}}
15+
PURGE_BUILDDEPS=${PURGE_BUILDDEPS:-"true"}
16+
17+
# shellcheck source=/dev/null
18+
source /etc/os-release
19+
20+
apt-get update
21+
apt-get -y install locales
22+
23+
## Configure default locale
24+
LANG=${LANG:-"en_US.UTF-8"}
25+
/usr/sbin/locale-gen --lang "${LANG}"
26+
/usr/sbin/update-locale --reset LANG="${LANG}"
27+
28+
export DEBIAN_FRONTEND=noninteractive
29+
30+
R_HOME=${R_HOME:-"/usr/local/lib/R"}
31+
32+
READLINE_VERSION=8
33+
if [ "${UBUNTU_CODENAME}" == "bionic" ]; then
34+
READLINE_VERSION=7
35+
fi
36+
37+
apt-get install -y --no-install-recommends \
38+
bash-completion \
39+
ca-certificates \
40+
file \
41+
fonts-texgyre \
42+
g++ \
43+
gfortran \
44+
gsfonts \
45+
libblas-dev \
46+
libbz2-* \
47+
libcurl4 \
48+
"libicu[0-9][0-9]" \
49+
liblapack-dev \
50+
libpcre2* \
51+
libjpeg-turbo* \
52+
libpangocairo-* \
53+
libpng16* \
54+
"libreadline${READLINE_VERSION}" \
55+
libtiff* \
56+
liblzma* \
57+
libxt6 \
58+
make \
59+
tzdata \
60+
unzip \
61+
zip \
62+
zlib1g
63+
64+
BUILDDEPS="curl \
65+
default-jdk \
66+
devscripts \
67+
libbz2-dev \
68+
libcairo2-dev \
69+
libcurl4-openssl-dev \
70+
libpango1.0-dev \
71+
libjpeg-dev \
72+
libicu-dev \
73+
libpcre2-dev \
74+
libpng-dev \
75+
libreadline-dev \
76+
libtiff5-dev \
77+
liblzma-dev \
78+
libx11-dev \
79+
libxt-dev \
80+
perl \
81+
rsync \
82+
subversion \
83+
tcl-dev \
84+
tk-dev \
85+
texinfo \
86+
texlive-extra-utils \
87+
texlive-fonts-recommended \
88+
texlive-fonts-extra \
89+
texlive-latex-recommended \
90+
texlive-latex-extra \
91+
x11proto-core-dev \
92+
xauth \
93+
xfonts-base \
94+
xvfb \
95+
wget \
96+
zlib1g-dev"
97+
98+
# shellcheck disable=SC2086
99+
apt-get install -y --no-install-recommends ${BUILDDEPS}
100+
101+
## Download R from 0-Cloud CRAN mirror or CRAN
102+
function download_r_src() {
103+
wget "https://cloud.r-project.org/src/$1" -O "R.tar.gz" ||
104+
wget "https://cran.r-project.org/src/$1" -O "R.tar.gz"
105+
}
106+
107+
if [ "$R_VERSION" == "devel" ]; then
108+
download_r_src "base-prerelease/R-devel.tar.gz"
109+
elif [ "$R_VERSION" == "patched" ]; then
110+
download_r_src "base-prerelease/R-latest.tar.gz"
111+
elif [ "$R_VERSION" == "latest" ]; then
112+
download_r_src "base/R-latest.tar.gz"
113+
else
114+
download_r_src "base/R-${R_VERSION%%.*}/R-${R_VERSION}.tar.gz"
115+
fi
116+
117+
tar xzf "R.tar.gz"
118+
cd R-*/
119+
120+
R_PAPERSIZE=letter \
121+
R_BATCHSAVE="--no-save --no-restore" \
122+
R_BROWSER=xdg-open \
123+
PAGER=/usr/bin/pager \
124+
PERL=/usr/bin/perl \
125+
R_UNZIPCMD=/usr/bin/unzip \
126+
R_ZIPCMD=/usr/bin/zip \
127+
R_PRINTCMD=/usr/bin/lpr \
128+
LIBnn=lib \
129+
AWK=/usr/bin/awk \
130+
CFLAGS="-g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g" \
131+
CXXFLAGS="-g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g" \
132+
./configure --enable-R-shlib \
133+
--enable-memory-profiling \
134+
--with-readline \
135+
--with-blas \
136+
--with-lapack \
137+
--with-tcltk \
138+
--with-recommended-packages
139+
140+
make
141+
make install
142+
make clean
143+
144+
## Add a library directory (for user-installed packages)
145+
mkdir -p "${R_HOME}/site-library"
146+
chown root:staff "${R_HOME}/site-library"
147+
chmod g+ws "${R_HOME}/site-library"
148+
149+
## Fix library path
150+
echo "R_LIBS=\${R_LIBS-'${R_HOME}/site-library:${R_HOME}/library'}" >>"${R_HOME}/etc/Renviron.site"
151+
152+
## Clean up from R source install
153+
cd ..
154+
rm -rf /tmp/*
155+
rm -rf R-*/
156+
rm -rf "R.tar.gz"
157+
158+
## Copy the checkbashisms script to local before remove devscripts package.
159+
## https://github.com/rocker-org/rocker-versioned2/issues/510
160+
cp /usr/bin/checkbashisms /usr/local/bin/checkbashisms
161+
162+
# shellcheck disable=SC2086
163+
if [ "${PURGE_BUILDDEPS}" != "false" ]; then
164+
apt-get remove --purge -y ${BUILDDEPS}
165+
fi
166+
apt-get autoremove -y
167+
apt-get autoclean -y
168+
rm -rf /var/lib/apt/lists/*
169+
170+
# Check the R info
171+
echo -e "Check the R info...\n"
172+
173+
R -q -e "sessionInfo()"
174+
175+
echo -e "\nInstall R from source, done!"

0 commit comments

Comments
 (0)