################################################################
# Begin section generated from template/Dockerfile.full.header
# This common file will be used by both Docker and the linux
# install script.
################################################################
ARG BUILDPACK_DEPS_BASE="bullseye"
FROM debian:${BUILDPACK_DEPS_BASE} as header

RUN apt-get update && apt-get -y install curl wget

# switch to nvm?
ARG NODE_VERSION=18
RUN curl -fsSL https://deb.nodesource.com/setup_${NODE_VERSION}.x | bash -
RUN apt-get update
RUN apt-get install -y nodejs

# Coral Edge TPU
# https://coral.ai/docs/accelerator/get-started/#runtime-on-linux
RUN echo "deb https://packages.cloud.google.com/apt coral-edgetpu-stable main" | tee /etc/apt/sources.list.d/coral-edgetpu.list
RUN curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add -
RUN apt-get -y update
RUN apt-get -y install libedgetpu1-std

RUN apt-get -y install software-properties-common apt-utils
RUN apt-get -y update
RUN apt-get -y upgrade

# base development stuff
RUN apt-get -y install \
    build-essential \
    cmake \
    gcc \
    libcairo2-dev \
    libgirepository1.0-dev \
    libvips \
    pkg-config

# these are necessary for pillow-simd, additional on disk size is small
# but could consider removing this.
RUN apt-get -y install \
    libjpeg-dev zlib1g-dev

# gstreamer native https://gstreamer.freedesktop.org/documentation/installing/on-linux.html?gi-language=c#install-gstreamer-on-ubuntu-or-debian
RUN apt-get -y install \
    gstreamer1.0-tools gstreamer1.0-plugins-base gstreamer1.0-plugins-good gstreamer1.0-plugins-bad gstreamer1.0-libav gstreamer1.0-alsa \
    gstreamer1.0-vaapi

# python native
RUN apt-get -y install \
    python3 \
    python3-dev \
    python3-gst-1.0 \
    python3-pip \
    python3-setuptools \
    python3-wheel

# armv7l does not have wheels for any of these
# and compile times would forever, if it works at all.
RUN if [ "$(uname -m)" = "armv7l" ]; \
    then \
        apt-get -y install \
        python3-matplotlib \
        python3-numpy \
        python3-opencv \
        python3-pil \
        python3-skimage; \
    fi

# python pip
RUN python3 -m pip install --upgrade pip
# pyvips is broken on x86 due to mismatch ffi
# https://stackoverflow.com/questions/62658237/it-seems-that-the-version-of-the-libffi-library-seen-at-runtime-is-different-fro
RUN pip install --force-reinstall --no-binary :all: cffi
RUN python3 -m pip install aiofiles debugpy typing_extensions psutil

################################################################
# End section generated from template/Dockerfile.full.header
################################################################
