FROM ubuntu:focal


#RUN printf "deb http://cn.archive.ubuntu.com/ubuntu/ bionic universe" >> /etc/apt/sources.list
RUN printf "deb http://us.archive.ubuntu.com/ubuntu/ bionic universe" >> /etc/apt/sources.list

RUN apt update && \
    apt install -y libnss3 libgtk-3-0 libx11-xcb1 libxss1 libasound2 desktop-file-utils && \
    apt install -y fonts-droid-fallback && \
    apt install -y rclone && \
    apt clean && rm -rf /var/lib/apt/lists/*

#ARG BAIDUNETDISK_URL="http://wppkg.baidupcs.com/issue/netdisk/LinuxGuanjia/3.0.1/baidunetdisk_linux_3.0.1.2.deb"
#ARG BAIDUNETDISK_URL="https://issuepcdn.baidupcs.com/issue/netdisk/LinuxGuanjia/4.3.0/baidunetdisk_4.3.0_amd64.deb"
#RUN apt update && apt install -y  wget && \
#    cd /tmp && wget $BAIDUNETDISK_URL && dpkg -i baidunetdisk_linux_*.deb && rm baidunetdisk_linux_*.deb && \
#    apt remove -y wget && apt autoremove -y && apt clean && rm -rf /var/lib/apt/lists/*


RUN apt update \
    && apt install -y --no-install-recommends --allow-unauthenticated \
    	libnotify4 xdg-utils libsecret-1-0 

COPY fs/baidunetdisk_4.3.0_amd64.deb /tmp/
RUN cd /tmp && dpkg -i baidunetdisk_4.3.0_amd64.deb && rm baidunetdisk_4.3.0_amd64.deb



ARG NOVNC=/opt/noVNC
RUN apt update && apt install -y wget git && \
    export DEBIAN_FRONTEND=noninteractive && apt install -y vnc4server lxde  python3 firefox mousepad vim && \
    git clone --depth 1 https://github.com/novnc/noVNC.git $NOVNC && \
    git clone --depth 1 https://github.com/novnc/websockify.git $NOVNC/utils/websockify && \
    find ${NOVNC} -name ".git*" | xargs rm -rf && \
    ln -s /usr/bin/python3 /usr/bin/python && \
    ln -s $NOVNC/vnc.html $NOVNC/index.html && \
    touch /root/.Xauthority && \
    apt remove -y wget git && apt autoremove -y && apt clean && rm -rf /var/lib/apt/lists/*

# COPY vnc /root/.vnc
COPY fs/autostart /etc/xdg/lxsession/LXDE/autostart
COPY fs/*.desktop /root/Desktop/
COPY fs/baidunetdisk.desktop /root/Desktop/
COPY fs/readme.1st /root/Desktop/

ARG VNC_PASSWORD=12345678
COPY xstartup /root/.vnc/
RUN printf "${VNC_PASSWORD}\n${VNC_PASSWORD}\n\n" | vncpasswd

# RCLONE
RUN mkdir /root/onedrive
RUN mkdir /root/.config/ 
RUN mkdir /root/.config/rclone/ 
COPY fs/rclone.conf /root/.config/rclone/
COPY fs/mntone.sh /root/.


COPY baidunetdisk_entrypoint.sh /
ENTRYPOINT ["/baidunetdisk_entrypoint.sh"]

