From 3fe8a81c780da7a54e316862980d5f00cf4be242 Mon Sep 17 00:00:00 2001 From: Grzegorz Wierzowiecki Date: Tue, 11 Jul 2023 16:28:02 +0200 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20Improve=20dev=20workflow=20by=20cac?= =?UTF-8?q?hing=20`pip=20install`=20with=20Docker?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This commit introduces Docker usage to build an image that caches the installation of Python dependencies, preventing the need for repeated downloads and installations in subsequent runs. This enhances the development workflow by saving time and bandwidth. --- README.md | 17 +++++++++++++++++ notebooks/Dockerfile | 8 ++++++++ notebooks/Makefile | 8 ++++++++ 3 files changed, 33 insertions(+) create mode 100644 notebooks/Dockerfile create mode 100644 notebooks/Makefile diff --git a/README.md b/README.md index 14d1b59..2e96e4e 100644 --- a/README.md +++ b/README.md @@ -25,3 +25,20 @@ docker run --rm -p 8888:8888 -e JUPYTER_ENABLE_LAB=yes -v "$PWD":/home/jovyan/wo ``` In your web browser, go to the URL shown in the output. + +Or if you want to cache installation of python depenencies, +you can build docker image once with dependencies installed: + +``` +cd notebooks +make build # will use Makefile "build" target +``` + +and keep using it: + +``` +cd notebooks +make run # will use Makefile's "run" target +``` + +In your web browser, go to the URL shown in the output. diff --git a/notebooks/Dockerfile b/notebooks/Dockerfile new file mode 100644 index 0000000..62f4405 --- /dev/null +++ b/notebooks/Dockerfile @@ -0,0 +1,8 @@ +FROM jupyter/datascience-notebook:python-3.9 + +# Install langchain[llms] and python-dotenv +RUN pip install langchain[llms] \ + && pip install python-dotenv + +# Set the working directory +WORKDIR /home/jovyan/work diff --git a/notebooks/Makefile b/notebooks/Makefile new file mode 100644 index 0000000..a70d402 --- /dev/null +++ b/notebooks/Makefile @@ -0,0 +1,8 @@ +.PHONY: build run + +build: + docker build -t cristobalcl_img . + +run: + docker run --rm -p 8888:8888 -e JUPYTER_ENABLE_LAB=yes -v "$$PWD":/home/jovyan/work cristobalcl_img +