ARG BASE_IMAGE
FROM $BASE_IMAGE

RUN apk add --no-cache bash

RUN ln -s /usr/local/lib /usr/local/lib64

ADD docker/scripts/direwolf-1.5.patch /
ADD docker/scripts/install-dependencies.sh /
RUN /install-dependencies.sh

ADD . /opt/openwebrx

WORKDIR /opt/openwebrx

RUN mkdir -p /tmp/openwebrx && \
    mv "/opt/openwebrx/config_webrx.py" "/opt/openwebrx/config_webrx.py.orig" && \
    sed 's/temporary_directory = "\/tmp"/temporary_directory = "\/tmp\/openwebrx"/' < "/opt/openwebrx/config_webrx.py.orig" > "/opt/openwebrx/config_webrx.py" && \
    rm "/opt/openwebrx/config_webrx.py.orig"

VOLUME /config

ENTRYPOINT [ "/opt/openwebrx/docker/scripts/run.sh" ]
EXPOSE 8073