From 232d6fc465d05b6d5762b4517a294ffe4980b1a4 Mon Sep 17 00:00:00 2001 From: Peter Parente Date: Tue, 2 Feb 2016 10:47:57 -0500 Subject: [PATCH] Use jq instead of sed (c) Copyright IBM Corp. 2016 --- all-spark-notebook/Dockerfile | 9 +++++++-- pyspark-notebook/Dockerfile | 9 +++++++-- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/all-spark-notebook/Dockerfile b/all-spark-notebook/Dockerfile index d07b2e72..74343920 100644 --- a/all-spark-notebook/Dockerfile +++ b/all-spark-notebook/Dockerfile @@ -6,6 +6,9 @@ MAINTAINER Jupyter Project USER root +# Util to help with kernel spec later +RUN apt-get -y update && apt-get -y install jq + # Spark dependencies ENV APACHE_SPARK_VERSION 1.5.1 RUN apt-get -y update && \ @@ -96,5 +99,7 @@ RUN bash -c '. activate python2 && \ python -m ipykernel.kernelspec --prefix=$CONDA_DIR && \ . deactivate' # Set PYSPARK_HOME in the python2 spec -RUN sed -i '$ d' $CONDA_DIR/share/jupyter/kernels/python2/kernel.json && \ - echo ', "env": {"PYSPARK_PYTHON": "/opt/conda/envs/python2/bin/python"} }' >> $CONDA_DIR/share/jupyter/kernels/python2/kernel.json +RUN jq --arg v "$CONDA_DIR/envs/python2/bin/python" \ + '.["env"]["PYSPARK_PYTHON"]=$v' \ + $CONDA_DIR/share/jupyter/kernels/python2/kernel.json > /tmp/kernel.json && \ + mv /tmp/kernel.json $CONDA_DIR/share/jupyter/kernels/python2/kernel.json diff --git a/pyspark-notebook/Dockerfile b/pyspark-notebook/Dockerfile index 4dc8979f..1370477d 100644 --- a/pyspark-notebook/Dockerfile +++ b/pyspark-notebook/Dockerfile @@ -6,6 +6,9 @@ MAINTAINER Jupyter Project USER root +# Util to help with kernel spec later +RUN apt-get -y update && apt-get -y install jq + # Spark dependencies ENV APACHE_SPARK_VERSION 1.5.1 RUN apt-get -y update && \ @@ -58,5 +61,7 @@ RUN bash -c '. activate python2 && \ python -m ipykernel.kernelspec --prefix=$CONDA_DIR && \ . deactivate' # Set PYSPARK_HOME in the python2 spec -RUN sed -i '$ d' $CONDA_DIR/share/jupyter/kernels/python2/kernel.json && \ - echo ', "env": {"PYSPARK_PYTHON": "/opt/conda/envs/python2/bin/python"} }' >> $CONDA_DIR/share/jupyter/kernels/python2/kernel.json +RUN jq --arg v "$CONDA_DIR/envs/python2/bin/python" \ + '.["env"]["PYSPARK_PYTHON"]=$v' \ + $CONDA_DIR/share/jupyter/kernels/python2/kernel.json > /tmp/kernel.json && \ + mv /tmp/kernel.json $CONDA_DIR/share/jupyter/kernels/python2/kernel.json