FROM hypriot/rpi-alpine-scratch

RUN apk update \
    && apk upgrade

RUN apk add bash python git gcc musl-dev libffi-dev python-dev openssl-dev curl jq

ENV DOCKER_GEN_VERSION=0.7.3 \
    DOCKER_HOST=unix:///var/run/docker.sock

RUN wget https://github.com/jwilder/docker-gen/releases/download/$DOCKER_GEN_VERSION/docker-gen-linux-armhf-$DOCKER_GEN_VERSION.tar.gz \
 && tar -C /usr/local/bin -xvzf docker-gen-linux-armhf-$DOCKER_GEN_VERSION.tar.gz \
 && rm /docker-gen-linux-armhf-$DOCKER_GEN_VERSION.tar.gz


WORKDIR /app
#RUN apk add py-pip
#RUN pip install --upgrade pip setuptools
ADD https://bootstrap.pypa.io/get-pip.py /tmp/get-pip.py
RUN python /tmp/get-pip.py
RUN pip install requests

# Install simp_le program
RUN mkdir -p /src && git -C /src clone --depth=1 --branch "0.2.0" https://github.com/zenhack/simp_le.git

# Install simp_le in /usr/bin
RUN cd /src/simp_le && python ./setup.py install

# Make house cleaning
RUN rm -rf /src && \
    apk del git gcc py-pip musl-dev libffi-dev python-dev openssl-dev && \
    rm -rf /var/cache/apk/*

ENTRYPOINT ["/bin/bash", "/app/entrypoint.sh" ]
CMD ["/bin/bash", "/app/start.sh" ]

COPY /app/ /app/
# [dr] made executable
RUN chmod +rx /app/*.sh && chmod +rx /app/letsencrypt_service && chmod +rx /app/update_certs
