Skip to content

Commit 44f4e99

Browse files
authored
Merge pull request #41 from deepnote/ach/build-ir-on-python-3.9
Rebuild IR image with puthon 3.9
2 parents 564ab22 + 1f18ab2 commit 44f4e99

File tree

8 files changed

+321
-60
lines changed

8 files changed

+321
-60
lines changed

.circleci/config.yml

Lines changed: 87 additions & 5 deletions
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:
@@ -61,7 +60,7 @@ jobs:
6160
--provenance=false \
6261
--sbom=false \
6362
--output type=registry,push=true \
64-
.
63+
./python/base
6564
6665
build-and-push-python:
6766
machine:
@@ -97,7 +96,7 @@ jobs:
9796
--provenance=false \
9897
--sbom=false \
9998
--output type=registry,push=true \
100-
.
99+
./python/python
101100
102101
build-and-push-python-datascience:
103102
machine:
@@ -167,7 +166,72 @@ jobs:
167166
--provenance=false \
168167
--sbom=false \
169168
--output type=registry,push=true \
170-
.
169+
./python/conda
170+
171+
build-and-push-ir:
172+
machine:
173+
image: ubuntu-2404:current
174+
parameters:
175+
r-version:
176+
type: string
177+
environment:
178+
R_VERSION: << parameters.r-version >>
179+
PYTHON_VERSION: "3.9"
180+
steps:
181+
- checkout
182+
- docker_login
183+
- setup_buildkit_builder
184+
- run:
185+
name: Build and push ir image
186+
command: |
187+
REPOSITORY="deepnote/ir"
188+
TAG="${R_VERSION}${CIRCLE_PULL_REQUEST:+-ra-${CIRCLE_PULL_REQUEST##*/}}"
189+
docker buildx build \
190+
--file=./ir/ir-base/Dockerfile.ir \
191+
--tag=978928340082.dkr.ecr.us-east-1.amazonaws.com/${REPOSITORY}:${TAG} \
192+
--tag=docker.io/${REPOSITORY}:${TAG} \
193+
--build-arg R_VERSION=${R_VERSION} \
194+
--build-arg PYTHON_VERSION=${PYTHON_VERSION} \
195+
--cache-from type=registry,ref=docker.io/${REPOSITORY}:${TAG}-buildcache,mode=max \
196+
--cache-to type=registry,ref=docker.io/${REPOSITORY}:${TAG}-buildcache,mode=max,image-manifest=true,oci-mediatypes=true \
197+
--progress plain \
198+
--platform linux/amd64 \
199+
--provenance=false \
200+
--sbom=false \
201+
--output type=registry,push=true \
202+
./ir/ir-base
203+
build-and-push-ir-with-libs:
204+
machine:
205+
image: ubuntu-2404:current
206+
parameters:
207+
r-version:
208+
type: string
209+
environment:
210+
R_VERSION: << parameters.r-version >>
211+
PYTHON_VERSION: "3.9"
212+
steps:
213+
- checkout
214+
- docker_login
215+
- setup_buildkit_builder
216+
- run:
217+
name: Build and push ir with datascience libraries
218+
command: |
219+
REPOSITORY="deepnote/ir-with-libs"
220+
TAG="${R_VERSION}${CIRCLE_PULL_REQUEST:+-ra-${CIRCLE_PULL_REQUEST##*/}}"
221+
docker buildx build \
222+
--file=./ir/ir-with-libs/Dockerfile.ir \
223+
--tag=978928340082.dkr.ecr.us-east-1.amazonaws.com/${REPOSITORY}:${TAG} \
224+
--tag=docker.io/${REPOSITORY}:${TAG} \
225+
--build-arg R_VERSION=${R_VERSION} \
226+
--build-arg CIRCLE_PULL_REQUEST=${CIRCLE_PULL_REQUEST} \
227+
--cache-from type=registry,ref=docker.io/${REPOSITORY}:${TAG}-buildcache,mode=max \
228+
--cache-to type=registry,ref=docker.io/${REPOSITORY}:${TAG}-buildcache,mode=max,image-manifest=true,oci-mediatypes=true \
229+
--progress plain \
230+
--platform linux/amd64 \
231+
--provenance=false \
232+
--sbom=false \
233+
--output type=registry,push=true \
234+
./ir/ir-with-libs
171235
172236
build-and-push-gpu:
173237
machine:
@@ -208,14 +272,18 @@ jobs:
208272
--provenance=false \
209273
--sbom=false \
210274
--output type=registry,push=true \
211-
.
275+
./gpu
212276
213277
python-versions: &python-versions
214278
- "3.8.19"
215279
- "3.9.19"
216280
- "3.10.15"
217281
- "3.11.10"
218282

283+
r-versions: &r-versions
284+
- "4.0.4"
285+
- "4.2.0"
286+
219287
workflows:
220288
build:
221289
jobs:
@@ -242,6 +310,20 @@ workflows:
242310
python-version: *python-versions
243311
requires:
244312
- Building the base image
313+
- build-and-push-ir:
314+
name: R << matrix.r-version >>
315+
matrix:
316+
parameters:
317+
r-version: *r-versions
318+
requires:
319+
- Python 3.9.19
320+
- build-and-push-ir-with-libs:
321+
name: R with libs << matrix.r-version >>
322+
matrix:
323+
parameters:
324+
r-version: *r-versions
325+
requires:
326+
- R << matrix.r-version >>
245327

246328
- build-and-push-gpu:
247329
name: Tensorflow 2.9

gpu/Dockerfile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,17 @@ RUN apt-get update && apt-get -y dist-upgrade \
2323
gnupg2 \
2424
&& rm -rf /var/lib/apt/lists/*
2525

26-
# replace python version (optional) and
26+
# replace python version (optional) and
2727
# create the virtual environment in the home directory in the Dockerfile
2828
# for performance improvement.
2929
ARG PYTHON_VER
3030
ARG TF_VERSION
31-
ADD ./gpu/setup.python.sh /tmp/setup.python.sh
31+
ADD ./setup.python.sh /tmp/setup.python.sh
3232
RUN bash /tmp/setup.python.sh ${PYTHON_VER} ${TF_VERSION}; rm -v /tmp/setup.python.sh
3333

3434
# setup cuda for tensorflow
3535
ARG CUDA_IMAGE_TAG
36-
ADD ./gpu/setup.cuda.sh /tmp/setup.cuda.sh
36+
ADD ./setup.cuda.sh /tmp/setup.cuda.sh
3737
RUN bash /tmp/setup.cuda.sh ${CUDA_IMAGE_TAG}; rm -v /tmp/setup.cuda.sh
3838

3939
ENV DEEPNOTE_PYTHON_KERNEL_ONLY=true

ir-with-libs/Dockerfile

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

ir/Dockerfile

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

ir/ir-base/Dockerfile.ir

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

0 commit comments

Comments
 (0)