# The standard name for this image is ovndb-vip-u. It captures all the
# packages and scripts required to support OVN NB/SB DB HA using
# corosync/pacemaker framework.

FROM ubuntu:18.04

USER root
# We need this since some of the packages below expects access to terminal
ARG DEBIAN_FRONTEND=noninteractive

RUN apt-get update && apt-get install -y iptables iproute2 curl software-properties-common setpriv \
    pcs pacemaker fence-agents crmsh

# We do not have much control over the exact version of OVS/OVN that can be
# obtained from upstream Ubuntu. guru@ovn.org maintains more latest versions of
# OVS/OVN packages at 3.19.28.122. Please comment out the next 3 lines if
# you prefer to use upstream Ubuntu packages instead.
RUN echo "deb http://3.19.28.122/openvswitch/stable /" |  tee /etc/apt/sources.list.d/openvswitch.list
RUN curl http://3.19.28.122/openvswitch/keyFile |  apt-key add -

RUN echo "deb https://apt.kubernetes.io/ kubernetes-xenial main" | tee -a /etc/apt/sources.list.d/kubernetes.list
RUN curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add -

# Install OVS and OVN packages.
RUN apt-get update && apt-get install -y openvswitch-switch openvswitch-common ovn-central ovn-common kubectl

RUN mkdir -p /var/run/openvswitch

# ovnkube-ha.sh is the entry point. This script examines environment
# variables to direct operation and configure ovn DBs
COPY ovndb-vip.sh /root/

# copy git commit number into image
COPY git_info /root


LABEL io.k8s.display-name="ovn kubernetes" \
      io.k8s.description="ovnkube NB/SB DB VIP HA ubuntu image"

WORKDIR /root
ENTRYPOINT /root/ovndb-vip.sh
