# this sets up an environment similar to the one described in:
# https://jupyterlab.readthedocs.io/en/latest/extension/extension_tutorial.html
FROM continuumio/miniconda3

# Copy environment.yml to a temp location while we create the environment.
COPY environment.yml /tmp/conda-tmp/
RUN if [ -f "/tmp/conda-tmp/environment.yml" ]; \
        then conda env create -n jupyterlab-ext --file=/tmp/conda-tmp/environment.yml; \
    fi \
    && rm -rf /tmp/conda-tmp \
    && echo 'conda activate jupyterlab-ext' >> /root/.bashrc

# Install curl/gpg required for adding gcloud package source,
# add the gcloud CLI distribution URI as a package source,
# add Google Cloud public key,
# and install additional OS packages including the gcloud CLI.
RUN apt-get update -y \
    && apt-get install -y --no-install-recommends \
        curl \
        gnupg \
    && echo "deb [signed-by=/usr/share/keyrings/cloud.google.gpg] https://packages.cloud.google.com/apt cloud-sdk main" \
    | tee -a /etc/apt/sources.list.d/google-cloud-sdk.list \
    && curl https://packages.cloud.google.com/apt/doc/apt-key.gpg \
    | gpg --dearmor -o /usr/share/keyrings/cloud.google.gpg \
    && apt-get update -y \
    && apt-get install -y --no-install-recommends google-cloud-cli \
    && apt-get clean -yqq
