Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 21 additions & 15 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,29 +1,35 @@
# Use the official Python image from the Docker Hub
FROM python:3.10

# Add Tini
ENV TINI_VERSION v0.19.0
# Add Tini, a minimal init system for containers
ENV TINI_VERSION=v0.19.0
ADD https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini /tini
RUN chmod +x /tini

# The WORKDIR instruction sets the working directory for any RUN, CMD, ENTRYPOINT,
# COPY and ADD instructions that follow it in the Dockerfile.
# If the WORKDIR doesn’t exist, it will be created even if it’s not used
# in any subsequent Dockerfile instruction.
# Set the working directory inside the container
WORKDIR /root/env

# Prevent running interactive config
ENV DEBIAN_FRONTEND noninteractive
# Prevent running interactive config during package installation
ENV DEBIAN_FRONTEND=noninteractive

# Install system dependencies and remove the package list
RUN apt-get update && \
apt-get install -y \
libgeos-dev \
&& rm -rf /var/lib/apt/lists/*

# Copy the requirements file into the container
COPY requirements.txt ./

# Install Python dependencies
RUN pip install --no-cache-dir --upgrade pip && \
pip install --no-cache-dir -r requirements.txt

RUN pip install jupyter
RUN pip install networkx
RUN pip install pandas
RUN pip install seaborn
RUN pip install basemap-data-hires
RUN pip install basemap
# Create a mount point for external volumes
VOLUME /root/env

# Set the entrypoint to Tini
ENTRYPOINT ["/tini", "-g", "--"]

ENTRYPOINT ["/tini", "-g", "--"]
# Default command to run when the container starts
CMD ["/bin/bash"]
25 changes: 0 additions & 25 deletions dev/Dockerfile

This file was deleted.

86 changes: 0 additions & 86 deletions dev/buildenv.sh

This file was deleted.

13 changes: 0 additions & 13 deletions dev/requirements.txt

This file was deleted.

14 changes: 13 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,16 @@ geopy
networkx
numpy
pandas
matplotlib
matplotlib
build
twine
pytest
pytest-cov
pytest-benchmark
pytest-mock
pylint
black
jupyter
seaborn
basemap-data-hires
basemap
48 changes: 36 additions & 12 deletions run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,21 @@

set -e

IMAGE_TAG=ngraph
DEFAULT_IMAGE_TAG=ngraph
IMAGE_TAG=${2:-$DEFAULT_IMAGE_TAG}
DEFAULT_CONTAINER_NAME=ngraph_jupyter
CONTAINER_NAME=${3:-$DEFAULT_CONTAINER_NAME}
IMAGE_ID=$(docker images --format "{{.ID}}" $IMAGE_TAG)

USAGE="Usage: $0 COMMAND IMAGE_TAG\n"
USAGE+=" COMMAND is what you expect script to do:\n"
USAGE="Usage: $0 COMMAND [IMAGE_TAG] [CONTAINER_NAME]\n"
USAGE+=" COMMAND is what you expect the script to do:\n"
USAGE+=" build - Builds an image from a Dockerfile.\n"
USAGE+=" run - Runs a container.\n"
USAGE+=" killall - Stops and removes all running containers.\n"
USAGE+=" forcecleanall - Clean-up Docker.\n"
USAGE+=" run - Runs a container and starts Jupyter.\n"
USAGE+=" shell - Attaches to the shell of a running container.\n"
USAGE+=" killall - Stops and removes all running containers based on the image tag.\n"
USAGE+=" forcecleanall - WARNING: Stops and removes all containers and images. This action cannot be undone.\n"
USAGE+=" IMAGE_TAG is the optional Docker image tag (default: $DEFAULT_IMAGE_TAG).\n"
USAGE+=" CONTAINER_NAME is the optional Docker container name (default: $DEFAULT_CONTAINER_NAME).\n"

if [[ $# -lt 1 ]]; then
echo>&2 "ERROR: Must specify the command"
Expand All @@ -21,7 +27,7 @@ fi
[[ $(uname) -eq "Darwin" ]] && MODHACK="-v /lib/modules:/lib/modules:ro" || MODHACK=""

function build {
echo "Building docker container"
echo "Building docker container with tag $IMAGE_TAG"
docker build . -t $IMAGE_TAG

IMAGE_ID=$(docker images --format "{{.ID}}" $IMAGE_TAG)
Expand All @@ -30,18 +36,24 @@ function build {
}

function run {
name=ngraph_jupyter
echo "Starting a container with the name $name using $IMAGE_TAG image..."
CONTAINER_ID=$(docker create --rm -it --name $name -v "$PWD":/root/env -p 8787:8787 --entrypoint=/bin/bash --privileged $MODHACK --cap-add ALL $IMAGE_TAG)
echo "Starting a container with the name $CONTAINER_NAME using $IMAGE_TAG image..."
CONTAINER_ID=$(docker create --rm -it --name $CONTAINER_NAME -v "$PWD":/root/env -p 8787:8787 --entrypoint=/bin/bash --privileged $MODHACK --cap-add ALL $IMAGE_TAG)
docker start $CONTAINER_ID
echo "Started $CONTAINER_ID with the name $name"
echo "Started $CONTAINER_ID with the name $CONTAINER_NAME"
docker exec -it $CONTAINER_ID pip install -e .
echo "Starting Jupyter in a container. Open http://127.0.0.1:8787/ in your browser."
docker exec -it $CONTAINER_ID jupyter notebook --port=8787 --no-browser --ip=0.0.0.0 --allow-root --NotebookApp.token='' /root/env
return 0
}

function shell {
echo "Attaching to the shell of the running container $CONTAINER_NAME..."
docker exec -it $CONTAINER_NAME /bin/bash
return 0
}

function killall {
echo "Stopping and removing all running containers based on the image tag $IMAGE_TAG..."
for container_id in $(docker ps -q --filter "ancestor=$IMAGE_TAG"); do
echo "$(docker kill $container_id) - stopped and removed"
done
Expand All @@ -50,6 +62,13 @@ function killall {
}

function forcecleanall {
echo "WARNING: This will stop and remove all containers and images. This action cannot be undone."
read -p "Are you sure you want to proceed? (Y/N): " confirm
if [[ $confirm != [Yy] ]]; then
echo "Aborting forcecleanall."
return 1
fi

for container in $(docker container ls --format "{{.ID}}"); do docker container kill $container; done
for container in $(docker container ls -a --format "{{.ID}}"); do docker container rm $container; done
for image in $(docker images --format "{{.ID}}"); do docker image rm --force $image; done
Expand All @@ -68,6 +87,11 @@ case $1 in
run "$@"
;;

shell)
echo "Executing SHELL command..."
shell "$@"
;;

killall)
echo "Executing KILLALL command..."
killall "$@"
Expand All @@ -83,4 +107,4 @@ case $1 in
printf "$USAGE" >&2
exit 2
;;
esac
esac
Loading