FROM opensuse/leap:15.3

ENV KASMVNC_BUILD_OS opensuse
ENV KASMVNC_BUILD_OS_CODENAME 15
ENV XORG_VER 1.20.3

# Install depends
RUN zypper install -ny \
  bdftopcf \
  bigreqsproto-devel \
  cmake \
  ffmpeg-4-libavcodec-devel \
  fonttosfnt \
  font-util \
  gcc \
  gcc-c++ \
  giflib-devel \
  git \
  gzip \
  lbzip2 \
  libbz2-devel \
  libgbm-devel \
  libGLw-devel \
  libgnutls-devel \
  libopenssl-devel \
  libpng16-devel \
  libtiff-devel \
  libXfont2-devel \
  libxkbcommon-x11-devel \
  libxshmfence-devel \
  make \
  Mesa-dri \
  Mesa-libglapi-devel \
  mkfontdir \
  mkfontscale \
  patch \
  tigervnc \
  wget \
  xcmiscproto-devel \
  xorg-x11-devel \
  xorg-x11-server-sdk \
  xorg-x11-util-devel \
  zlib-devel

ENV SCRIPTS_DIR=/tmp/scripts
COPY builder/scripts $SCRIPTS_DIR
RUN $SCRIPTS_DIR/build-webp
RUN $SCRIPTS_DIR/build-libjpeg-turbo

RUN useradd -u 1000 docker && \
  groupadd -g 1000 docker && \
  usermod -a -G docker docker

COPY --chown=docker:docker . /src/


USER docker
ENTRYPOINT ["/src/builder/build.sh"]
