FROM docker.io/library/alpine:edge

# NOTE: there is no versioning inside the image, so frequently invoke the build to upgrade

RUN printf 'https://dl-cdn.alpinelinux.org/alpine/edge/main\n\
https://dl-cdn.alpinelinux.org/alpine/edge/community\n\
https://dl-cdn.alpinelinux.org/alpine/edge/testing\n' > /etc/apk/repositories \
    && apk add --update-cache alpine-sdk alpine-conf doas ccache \
    && apk upgrade -a \
    && /sbin/setup-apkcache /var/cache/apk

# Create a normal user and distfiles directory
RUN adduser -u 1069 -D -s /bin/sh -h /home/builder builder \
    && addgroup builder abuild \
    && echo 'permit nopass builder' >> /etc/doas.conf

USER builder
WORKDIR /home/builder
COPY entrypoint.sh /home/builder/
RUN mkdir -v packages
ENTRYPOINT ["/home/builder/entrypoint.sh"]
