From 435eb16a4cc4eab0ba1da0fbccbd90ae04d68563 Mon Sep 17 00:00:00 2001 From: lilianabs Date: Sat, 1 Apr 2023 20:21:03 -0600 Subject: [PATCH 1/5] Add docker image --- docker-image/Dockerfile | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 docker-image/Dockerfile diff --git a/docker-image/Dockerfile b/docker-image/Dockerfile new file mode 100644 index 0000000..32db175 --- /dev/null +++ b/docker-image/Dockerfile @@ -0,0 +1,15 @@ +FROM python:3.7 + +RUN apt-get update && apt-get install -y git + +RUN git clone https://github.com/neomatrix369/nlp_profiler.git + +WORKDIR nlp_profiler + +ADD app.py . + +RUN pip install -r requirements-dev.txt + +RUN pip install -r requirements.txt + +RUN pip install -r requirements-nix-dev.txt \ No newline at end of file From 5f766b97a2e1ffc1382f07d0e5de53f501017cab Mon Sep 17 00:00:00 2001 From: lilianabs Date: Mon, 19 Jun 2023 22:30:54 -0600 Subject: [PATCH 2/5] Add script for creating and running docker container --- docker-image/Dockerfile | 8 +++++--- docker-image/run-nlp-profiler-in-docker.sh | 20 ++++++++++++++++++++ 2 files changed, 25 insertions(+), 3 deletions(-) create mode 100755 docker-image/run-nlp-profiler-in-docker.sh diff --git a/docker-image/Dockerfile b/docker-image/Dockerfile index 32db175..6a9f7bf 100644 --- a/docker-image/Dockerfile +++ b/docker-image/Dockerfile @@ -1,13 +1,15 @@ FROM python:3.7 -RUN apt-get update && apt-get install -y git +RUN apt-get update + +RUN apt-get install -y cmake + +RUN apt-get install -y git RUN git clone https://github.com/neomatrix369/nlp_profiler.git WORKDIR nlp_profiler -ADD app.py . - RUN pip install -r requirements-dev.txt RUN pip install -r requirements.txt diff --git a/docker-image/run-nlp-profiler-in-docker.sh b/docker-image/run-nlp-profiler-in-docker.sh new file mode 100755 index 0000000..04c4ed3 --- /dev/null +++ b/docker-image/run-nlp-profiler-in-docker.sh @@ -0,0 +1,20 @@ +#!/bin/bash + +set -e +set -u +set -o pipefail + +MOUNT_VOLUME="${PWD}/../" +TARGET_FOLDER="/nlp_profiler" +DOCKER_IMAGE_NAME="nlp_profiler" + +echo "~~~ Running nlp_profiler in a docker container" +echo "Mounted volume: ${MOUNT_VOLUME}" + +docker build -t ${DOCKER_IMAGE_NAME} . + +docker run -it \ + --volume ${MOUNT_VOLUME}:${TARGET_FOLDER} \ + --workdir ${TARGET_FOLDER} \ + ${DOCKER_IMAGE_NAME} \ + /bin/bash \ No newline at end of file From a163d75e30219c93129c23e56a9e0c836c4cc81a Mon Sep 17 00:00:00 2001 From: lilianabs Date: Tue, 27 Jun 2023 21:16:47 -0600 Subject: [PATCH 3/5] Make Python version configurable --- docker-image/Dockerfile | 4 +++- docker-image/run-nlp-profiler-in-docker.sh | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/docker-image/Dockerfile b/docker-image/Dockerfile index 6a9f7bf..3e50c8a 100644 --- a/docker-image/Dockerfile +++ b/docker-image/Dockerfile @@ -1,4 +1,6 @@ -FROM python:3.7 +ARG python_version + +FROM python:$python_version RUN apt-get update diff --git a/docker-image/run-nlp-profiler-in-docker.sh b/docker-image/run-nlp-profiler-in-docker.sh index 04c4ed3..2ce1102 100755 --- a/docker-image/run-nlp-profiler-in-docker.sh +++ b/docker-image/run-nlp-profiler-in-docker.sh @@ -7,11 +7,13 @@ set -o pipefail MOUNT_VOLUME="${PWD}/../" TARGET_FOLDER="/nlp_profiler" DOCKER_IMAGE_NAME="nlp_profiler" +PYTHON_VERSION="3.8" echo "~~~ Running nlp_profiler in a docker container" echo "Mounted volume: ${MOUNT_VOLUME}" +echo "Python version: ${PYTHON_VERSION}" -docker build -t ${DOCKER_IMAGE_NAME} . +docker build -t ${DOCKER_IMAGE_NAME} --build-arg python_version=${PYTHON_VERSION} . docker run -it \ --volume ${MOUNT_VOLUME}:${TARGET_FOLDER} \ From b32a8fbee6129490e4f53038112cf504fcd12c75 Mon Sep 17 00:00:00 2001 From: lilianabs Date: Wed, 28 Jun 2023 22:30:52 -0600 Subject: [PATCH 4/5] Use local folder --- docker-image/Dockerfile | 6 +++--- docker-image/run-nlp-profiler-in-docker.sh | 4 +++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/docker-image/Dockerfile b/docker-image/Dockerfile index 3e50c8a..8db7d06 100644 --- a/docker-image/Dockerfile +++ b/docker-image/Dockerfile @@ -6,11 +6,11 @@ RUN apt-get update RUN apt-get install -y cmake -RUN apt-get install -y git +RUN pip install --upgrade pip -RUN git clone https://github.com/neomatrix369/nlp_profiler.git +WORKDIR /nlp_profiler -WORKDIR nlp_profiler +COPY . . RUN pip install -r requirements-dev.txt diff --git a/docker-image/run-nlp-profiler-in-docker.sh b/docker-image/run-nlp-profiler-in-docker.sh index 2ce1102..db0c888 100755 --- a/docker-image/run-nlp-profiler-in-docker.sh +++ b/docker-image/run-nlp-profiler-in-docker.sh @@ -10,10 +10,12 @@ DOCKER_IMAGE_NAME="nlp_profiler" PYTHON_VERSION="3.8" echo "~~~ Running nlp_profiler in a docker container" +echo "Docker image name: " ${DOCKER_IMAGE_NAME}} echo "Mounted volume: ${MOUNT_VOLUME}" +echo "Target folder: " ${TARGET_FOLDER} echo "Python version: ${PYTHON_VERSION}" -docker build -t ${DOCKER_IMAGE_NAME} --build-arg python_version=${PYTHON_VERSION} . +docker build -t ${DOCKER_IMAGE_NAME} --build-arg python_version=${PYTHON_VERSION} ../ docker run -it \ --volume ${MOUNT_VOLUME}:${TARGET_FOLDER} \ From 00b6247f557c50e3bad20d1afe2d9c5b603c0445 Mon Sep 17 00:00:00 2001 From: lilianabs Date: Fri, 7 Jul 2023 18:49:24 -0600 Subject: [PATCH 5/5] Format Dockerfile and shell script --- docker-image/Dockerfile | 21 +++++++++------------ docker-image/run-nlp-profiler-in-docker.sh | 18 +++++++++++------- 2 files changed, 20 insertions(+), 19 deletions(-) diff --git a/docker-image/Dockerfile b/docker-image/Dockerfile index 8db7d06..d062d3a 100644 --- a/docker-image/Dockerfile +++ b/docker-image/Dockerfile @@ -1,19 +1,16 @@ -ARG python_version +ARG BASE_IMAGE=python:${PYTHON_VERSION} -FROM python:$python_version +FROM ${BASE_IMAGE} as base -RUN apt-get update - -RUN apt-get install -y cmake - -RUN pip install --upgrade pip +RUN apt-get update \ + && apt-get install --no-install-recommends -y cmake \ + && apt-get clean \ + && rm -rf /var/lib/apt/lists/* WORKDIR /nlp_profiler COPY . . -RUN pip install -r requirements-dev.txt - -RUN pip install -r requirements.txt - -RUN pip install -r requirements-nix-dev.txt \ No newline at end of file +RUN pip install --no-cache-dir -r requirements-dev.txt \ + && pip install --no-cache-dir -r requirements.txt \ + && pip install --no-cache-dir -r requirements-nix-dev.txt \ No newline at end of file diff --git a/docker-image/run-nlp-profiler-in-docker.sh b/docker-image/run-nlp-profiler-in-docker.sh index db0c888..5180f16 100755 --- a/docker-image/run-nlp-profiler-in-docker.sh +++ b/docker-image/run-nlp-profiler-in-docker.sh @@ -4,21 +4,25 @@ set -e set -u set -o pipefail +PYTHON_VERSION=${1:-"3.8"} + MOUNT_VOLUME="${PWD}/../" TARGET_FOLDER="/nlp_profiler" DOCKER_IMAGE_NAME="nlp_profiler" -PYTHON_VERSION="3.8" echo "~~~ Running nlp_profiler in a docker container" -echo "Docker image name: " ${DOCKER_IMAGE_NAME}} +echo "Docker image name: ${DOCKER_IMAGE_NAME}" echo "Mounted volume: ${MOUNT_VOLUME}" -echo "Target folder: " ${TARGET_FOLDER} -echo "Python version: ${PYTHON_VERSION}" +echo "Target folder: ${TARGET_FOLDER}" -docker build -t ${DOCKER_IMAGE_NAME} --build-arg python_version=${PYTHON_VERSION} ../ +echo "~~~ Building docker image ${DOCKER_IMAGE_NAME} with Python version ${PYTHON_VERSION}." +docker build -t ${DOCKER_IMAGE_NAME} --build-arg python_version="${PYTHON_VERSION}" ../ +echo "~~~ Running docker container ${DOCKER_IMAGE_NAME}." docker run -it \ - --volume ${MOUNT_VOLUME}:${TARGET_FOLDER} \ + --volume "${MOUNT_VOLUME}":${TARGET_FOLDER} \ --workdir ${TARGET_FOLDER} \ ${DOCKER_IMAGE_NAME} \ - /bin/bash \ No newline at end of file + /bin/bash + +echo "~~~ Exited docker container." \ No newline at end of file