From 3e39f3ae1a6e6bd6e3ed580ac1460bf29f5d830f Mon Sep 17 00:00:00 2001 From: Peter Inglesby Date: Tue, 5 Dec 2023 16:13:43 +0000 Subject: [PATCH] Use service account to access BQ --- .gitignore | 5 ++++- Dockerfile | 7 +++++++ requirements.txt | 2 +- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 8c61629..fcca27d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,6 @@ +# Credentials for accessing BigQuery +bq-service-account.json + # Byte-compiled / optimized / DLL files __pycache__/ *.py[cod] @@ -17,4 +20,4 @@ __pycache__/ .DS_Store # Emacs -*~ \ No newline at end of file +*~ diff --git a/Dockerfile b/Dockerfile index 8785b17..dd9b2b6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,6 +3,9 @@ FROM ebmdatalab/datalab-jupyter:python3.8.1-2328e31e7391a127fe7184dcce38d581a17b # Set up jupyter environment ENV MAIN_PATH=/home/app/notebook +# Set path to BQ service account credentials +ENV EBMDATALAB_BQ_CREDENTIALS_PATH=/tmp/bq-service-account.json + # Install pip requirements COPY requirements.txt /tmp/ # Hack until this is fixed https://github.com/jazzband/pip-tools/issues/823 @@ -18,3 +21,7 @@ COPY config/kernel.json /tmp/kernel_with_custom_path/kernel.json RUN jupyter kernelspec install /tmp/kernel_with_custom_path/ --user --name="python3" CMD cd ${MAIN_PATH} && PYTHONPATH=${MAIN_PATH} jupyter lab --config=config/jupyter_notebook_config.py + +# Copy BQ service account credentials into container +# We work around the credentials not existing in CI with the glob +COPY bq-service-account.jso[n] /tmp/ diff --git a/requirements.txt b/requirements.txt index 3888404..78b4d6f 100644 --- a/requirements.txt +++ b/requirements.txt @@ -19,7 +19,7 @@ cycler==0.10.0 # via matplotlib decorator==4.4.1 # via ipython, traitlets defusedxml==0.6.0 # via nbconvert descartes==1.1.0 # via ebmdatalab -ebmdatalab==0.0.25 # via -r requirements.in +ebmdatalab==0.0.29 # via -r requirements.in entrypoints==0.3 # via nbconvert fiona==1.8.13 # via geopandas geopandas==0.6.3 # via ebmdatalab