Secrets

Secrets on Banana let you pass private data to your model at build time or runtime

Getting Started with Secrets

Navigate to your models setting page and add secrets in the Build Arguments section

Next, you must modify the Dockerfile to access them

In the example below we fetch a stable diffusion 1.5 model checkpoint URL and hugginface auth token using ARG commands and passing the names of the build argument keys we provided in the model settings above

FROM pytorch/pytorch:1.11.0-cuda11.3-cudnn8-runtime

ARG MODEL_URL
ARG HF_TOKEN

RUN apt update && DEBIAN_FRONTEND=noninteractive TZ=Etc/UTC apt-get -y install git wget \
    python3.10 python3-pip \
    build-essential libgl-dev libglib2.0-0 vim # real txt editor
RUN ln -s /usr/bin/python3.10 /usr/bin/python

ADD requirements.txt requirements.txt

RUN pip install -r requirements.txt

WORKDIR /app
RUN git clone https://github.com/AUTOMATIC1111/stable-diffusion-webui.git webui && cd webui && git checkout 3e0f9a75438fa815429b5530261bcf7d80f3f101
WORKDIR /app/webui

ENV MODEL_URL=${MODEL_URL}
ENV HF_TOKEN=${HF_TOKEN}

ARG commands only make the variable accessible from within the docker build context, so in addition we add the lines

  • ENV MODEL_URL=${MODEL_URL} and

  • ENV HF_TOKEN=${HF_TOKEN}

These lines pass the build arguments to our potassium runtime as environment variables.

Once your potassium app is running you can access these env vars using any standard library call such as os.getenv('MODEL_URL') in the case of python

Last updated