FROM alpine:3.12

# > All command-line options (except for '-datadir' and '-conf') may be specified in a configuration file
ENV DATA_DIR_PATH=/var/lib/bitcoin
ARG BITCOIN_CORE_PACKAGE_VERSION=0.19.1-r0
# > Executing bitcoin-0.19.1-r0.post-install
# > Generated random user / password / port in: /etc/bitcoin.conf
RUN apk add --no-cache bitcoin=$BITCOIN_CORE_PACKAGE_VERSION \
    && rm /etc/bitcoin.conf \
    && mkdir "$DATA_DIR_PATH" \
    && chown -c bitcoin "$DATA_DIR_PATH"
VOLUME $DATA_DIR_PATH

USER bitcoin
CMD ["sh", "-c", "exec bitcoind -datadir=\"$DATA_DIR_PATH\""]