FROM ubuntu:18.04

ARG THREADS=1

RUN apt clean && apt update
ARG DEBIAN_FRONTEND=noninteractive
ENV TZ=Europe/Amsterdam

RUN apt install -y \
    autoconf \
    automake \
    autopoint \
    aptitude \
    bash \
    build-essential \
    bison \
    bzip2 \
    ccache \
    flex \
    g++ \
    g++-multilib \
    gettext \
    git \
    gperf \
    intltool \
    libc6-dev-i386 \
    libgdk-pixbuf2.0-dev \
    libltdl-dev \
    libssl-dev \
    libtool-bin \
    libxml-parser-perl \
    lzip \
    nano \
    make \
    openssl \
    p7zip-full \
    patch \
    perl \
    python \
    python-mako \
    ruby \
    sed \
    scons \
    software-properties-common \
    unzip \
    tzdata \
    vim \
    wget \
    xz-utils

RUN git clone -b feather-patch --depth 1 https://git.wownero.com/feather/mxe.git && \
    cd mxe && \
    make -j$THREADS MXE_TARGETS='x86_64-w64-mingw32.static' gcc libqrencode pkgconf libgpg_error libgcrypt cmake libsodium lzma readline libzmq boost qtbase qtsvg qtwebsockets qtimageformats qtmultimedia

# plugins
RUN cd mxe && make -j$THREADS MXE_PLUGIN_DIRS='/mxe/plugins/apps/' MXE_TARGETS='x86_64-w64-mingw32.static' tor

# fix env.
RUN echo "export PATH=\"/mxe/usr/bin/:\$PATH\"" >> "/root/.bashrc"
RUN ln -s /mxe/usr/bin/x86_64-w64-mingw32.static-cmake /usr/local/bin/cmake
RUN ln -s /mxe/usr/bin/x86_64-w64-mingw32.static-windres /usr/local/bin/windres
RUN ln -s /mxe/usr/x86_64-w64-mingw32.static/lib/libsicudt.a /mxe/usr/x86_64-w64-mingw32.static/lib/libicudt.a
RUN ln -s /mxe/usr/x86_64-w64-mingw32.static/lib/libsicuio.a /mxe/usr/x86_64-w64-mingw32.static/lib/libicuio.a
RUN ln -s /mxe/usr/x86_64-w64-mingw32.static/lib/libsicutu.a /mxe/usr/x86_64-w64-mingw32.static/lib/libicutu.a
RUN ln -s /mxe/usr/x86_64-w64-mingw32.static/lib/libsicuuc.a /mxe/usr/x86_64-w64-mingw32.static/lib/libicuuc.a
RUN ln -s /mxe/usr/x86_64-w64-mingw32.static/lib/libsicuin.a /mxe/usr/x86_64-w64-mingw32.static/lib/libicuin.a

ENV PATH="/mxe/usr/bin/:$PATH"

RUN git clone https://git.wownero.com/feather/monero-seed.git && \
    cd monero-seed && \
    cmake -DCMAKE_BUILD_TYPE=Release -Bbuild && \
    make -Cbuild -j$THREADS && \
    make -Cbuild install