FROM debian:latest

RUN apt update -y && \
    apt install -y libssl3t64 ca-certificates libicu76 rclone gnupg tini

ENTRYPOINT [ "/usr/bin/tini", "--", "/run-as-user.sh" ]

ENV XDG_CONFIG_HOME=/data
VOLUME /data

# Pass Duplicati version/channel as build arguments (not used by Duplicati itself)
ARG CHANNEL=
ARG VERSION=
ENV DUPLICATI_CHANNEL=${CHANNEL}
ENV DUPLICATI_VERSION=${VERSION}

# Copy in the Duplicati binaries for the target architecture
ARG TARGETARCH
COPY ./${TARGETARCH} /opt/duplicati
COPY run-as-user.sh /run-as-user.sh
RUN chmod +x /run-as-user.sh

# Set the PATH to include the Duplicati binaries
ENV PATH="/opt/duplicati:${PATH}"

CMD ["duplicati-agent"]
