# Use an official Python runtime as a parent image
FROM ubuntu:bionic

ENV DEBIAN_FRONTEND "noninteractive"
RUN apt-get update -qq && \
    apt-get upgrade -y -qq --no-install-recommends && \
	apt-get install -y -qq --no-install-recommends \
	gnupg-agent \
	software-properties-common \
	wget \ 
	apt-utils

# Qt 5.15.2
RUN add-apt-repository --yes ppa:beineri/opt-qt-5.15.2-bionic

# Clang 12
RUN echo "deb http://apt.llvm.org/bionic/ llvm-toolchain-bionic-12 main" > /etc/apt/sources.list.d/clang.list
RUN wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key| apt-key add -

RUN	apt-get update -qq && \
	apt-get install -y --no-install-recommends \
	make \
	coreutils \
	curl \
	clang-12 \
	git \
	gstreamer1.0-alsa \
	gstreamer1.0-libav \
	gstreamer1.0-plugins-bad \
	gstreamer1.0-plugins-base \
	gstreamer1.0-plugins-base-apps \
	gstreamer1.0-plugins-good \
	gstreamer1.0-plugins-ugly \
	gstreamer1.0-pulseaudio \
	libclang-cpp12 \
	libgst7 \
	libgstreamer-plugins-bad1.0 \
	libgstreamer-plugins-good1.0 \
    libgstreamer-plugins-base1.0 \
	libgstreamer-plugins-bad1.0-dev \
	libgstreamer-plugins-base1.0-dev \
	libgstreamer-plugins-good1.0-dev \
	libgstreamer1.0-dev \
	libtag1-dev \
	pkg-config \
	qttools5-dev-tools \
	qt515base \
	qt515svg \
	qt515tools \
	qt515translations \
	qt515x11extras \
	qt515xmlpatterns \
	qttools5-dev \
	zlib1g-dev \
    libgl1-mesa-dev

RUN ln -sf /opt/qt515 /opt/qt

# Needed for linuxdeploy images
RUN apt-get install -y -qq --no-install-recommends \
	ca-certificates \
	file \
	libfuse2 \
	openssl \
	wget

# cmake
ENV CMAKE_VERSION_NR "3.20.1"
ENV CMAKE_VERSION "${CMAKE_VERSION_NR}-linux-x86_64"
RUN wget "https://github.com/Kitware/CMake/releases/download/v${CMAKE_VERSION_NR}/cmake-${CMAKE_VERSION}.tar.gz"
RUN tar xzf "cmake-${CMAKE_VERSION}.tar.gz"
RUN cp -r "cmake-${CMAKE_VERSION}/bin" /usr/local
RUN cp -r "cmake-${CMAKE_VERSION}/doc" /usr/local
RUN cp -r "cmake-${CMAKE_VERSION}/share" /usr/local
RUN rm -f "cmake-${CMAKE_VERSION}.tar.gz"
RUN rm -rf "cmake-${CMAKE_VERSION}"

# App Image
RUN wget "https://github.com/linuxdeploy/linuxdeploy/releases/download/continuous/linuxdeploy-x86_64.AppImage"
RUN wget "https://github.com/linuxdeploy/linuxdeploy-plugin-qt/releases/download/continuous/linuxdeploy-plugin-qt-x86_64.AppImage"
RUN wget "https://github.com/AppImage/AppImageKit/releases/download/continuous/appimagetool-x86_64.AppImage"

RUN mv "linuxdeploy-x86_64.AppImage" "linuxdeploy-plugin-qt-x86_64.AppImage" "appimagetool-x86_64.AppImage" /usr/local/bin/
RUN chmod a+x /usr/local/bin/*.AppImage

RUN mkdir -p /tmp/tx && curl -o /tmp/tx/install.sh https://raw.githubusercontent.com/transifex/cli/master/install.sh
RUN cd /tmp/tx && /bin/bash ./install.sh

# make clang the default compiler
ENV CC clang-12
ENV CXX clang++-12

CMD ["bash"]
