#FROM alpine:3.9
FROM ubuntu:latest as build

ARG DEBIAN_FRONTEND=noninteractive

ENV INST_RCLONE_VERSION=current
ENV ARCH=amd64
ENV SYNC_SRC=
ENV SYNC_DEST=
ENV SYNC_OPTS=-v
ENV RCLONE_OPTS="--config /config/rclone.conf"
ENV CRON=
ENV CRON_ABORT=
ENV FORCE_SYNC=
ENV CHECK_URL=
ENV TZ=


# install rclone
#RUN apk -U add ca-certificates fuse wget dcron tzdata \
#    && rm -rf /var/cache/apk/* \
RUN apt update
RUN apt install -y ca-certificates fuse wget cron tzdata zip unzip \
    && cd /tmp \
    && wget -q http://downloads.rclone.org/rclone-${INST_RCLONE_VERSION}-linux-${ARCH}.zip \
    && unzip /tmp/rclone-${INST_RCLONE_VERSION}-linux-${ARCH}.zip \
    && mv /tmp/rclone-*-linux-${ARCH}/rclone /usr/bin \
    && rm -r /tmp/rclone* \
    && apt autoremove -y \
    && rm -rf /var/lib/apt/lists/* \
    && apt clean


# install entrypoint
ADD docker-entrypoint.sh /docker-entrypoint.sh
RUN chmod +x /docker-entrypoint.sh

#ADD config/rclone.conf /root/.config/rclone/rclone.conf

VOLUME ["/config"]

# defaults env vars
ENV CRON_SCHEDULE="0 0 * * *"
ENV COMMAND="rclone version"

ENTRYPOINT ["/docker-entrypoint.sh"]

RUN touch /var/log/cron.log

CMD ["cron", "-f"]
#CMD cron -f -l 2 

