# create a new version of this docker image
# > docker build -t iterativ/vbv-lernwelt-bitbucket .
# push new version to Docker Hub
# > docker push iterativ/vbv-lernwelt-bitbucket
# run locally with directory mounted
# > docker run -v $(dirname "$(pwd)"):/src -it iterativ/vbv-lernwelt-bitbucket /bin/bash

FROM python:3.10-bullseye
MAINTAINER Daniel Egger <daniel.egger@iterativ.ch>

ARG DEBIAN_FRONTEND=noninteractive

# Install node prereqs, nodejs and yarn
# Ref: https://deb.nodesource.com/setup_16.x
# Ref: https://yarnpkg.com/en/docs/install
# https://github.com/nikolaik/docker-python-nodejs
RUN \
  echo "deb https://deb.nodesource.com/node_16.x bullseye main" > /etc/apt/sources.list.d/nodesource.list && \
  wget -qO- https://deb.nodesource.com/gpgkey/nodesource.gpg.key | apt-key add - && \
  echo "deb https://dl.yarnpkg.com/debian/ stable main" > /etc/apt/sources.list.d/yarn.list && \
  wget -qO- https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - && \
  apt-get update && \
  apt-get install -yqq nodejs yarn && \
  pip install -U pip && pip install pipenv && \
  npm i -g npm@^6

# Install Cypress deps
# https://github.com/cypress-io/cypress-docker-images/blob/master/base/16.5.0/Dockerfile
RUN apt-get update && \
  apt-get install --no-install-recommends -y \
  libgtk2.0-0 \
  libgtk-3-0 \
  libnotify-dev \
  libgconf-2-4 \
  libgbm-dev \
  libnss3 \
  libxss1 \
  libasound2 \
  libxtst6 \
  xauth \
  xvfb \
  # install text editors
  vim-tiny \
  nano \
  # install emoji font
  fonts-noto-color-emoji \
  # install Chinese fonts
  # this list was copied from https://github.com/jim3ma/docker-leanote
  fonts-arphic-bkai00mp \
  fonts-arphic-bsmi00lp \
  fonts-arphic-gbsn00lp \
  fonts-arphic-gkai00mp \
  fonts-arphic-ukai \
  fonts-arphic-uming \
  ttf-wqy-zenhei \
  ttf-wqy-microhei \
  xfonts-wqy

RUN npm --version

RUN npm install -g yarn@latest --force
RUN yarn --version

# a few environment variables to make NPM installs easier
# good colors for most applications
ENV TERM xterm
# avoid million NPM install messages
ENV npm_config_loglevel warn
# allow installing when the main user is root
ENV npm_config_unsafe_perm true

# Node libraries
RUN node -p process.versions

# Show where Node loads required modules from
RUN node -p 'module.paths'

# install postgresql
 RUN apt-get install -y postgresql postgresql-contrib libpq-dev

# Required by python3-saml
 RUN apt-get -y install libxmlsec1-dev pkg-config gettext

# install git-crypt
RUN apt-get -y install git-crypt

ENV LANG C.UTF-8
ENV LC_ALL C.UTF-8

# Install Google Chrome
RUN wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add -
RUN sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list'
RUN apt-get update && apt-get install -y google-chrome-stable

# versions of local tools
RUN echo  " node version:    $(node -v) \n" \
"npm version:     $(npm -v) \n" \
"yarn version:    $(yarn -v) \n" \
"python version:  $(python --version) \n" \
"debian version:  $(cat /etc/debian_version) \n" \
"user:            $(whoami) \n"
