Moving bitcoin to build role
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
Role Name
|
||||
=========
|
||||
|
||||
A brief description of the role goes here.
|
||||
|
||||
Requirements
|
||||
------------
|
||||
|
||||
Any pre-requisites that may not be covered by Ansible itself or the role should be mentioned here. For instance, if the role uses the EC2 module, it may be a good idea to mention in this section that the boto package is required.
|
||||
|
||||
Role Variables
|
||||
--------------
|
||||
|
||||
A description of the settable variables for this role should go here, including any variables that are in defaults/main.yml, vars/main.yml, and any variables that can/should be set via parameters to the role. Any variables that are read from other roles and/or the global scope (ie. hostvars, group vars, etc.) should be mentioned here as well.
|
||||
|
||||
Dependencies
|
||||
------------
|
||||
|
||||
A list of other roles hosted on Galaxy should go here, plus any details in regards to parameters that may need to be set for other roles, or variables that are used from other roles.
|
||||
|
||||
Example Playbook
|
||||
----------------
|
||||
|
||||
Including an example of how to use your role (for instance, with variables passed in as parameters) is always nice for users too:
|
||||
|
||||
- hosts: servers
|
||||
roles:
|
||||
- { role: username.rolename, x: 42 }
|
||||
|
||||
License
|
||||
-------
|
||||
|
||||
BSD
|
||||
|
||||
Author Information
|
||||
------------------
|
||||
|
||||
An optional section for the role authors to include contact information, or a website (HTML is not allowed).
|
||||
@@ -0,0 +1,2 @@
|
||||
---
|
||||
# defaults file for build
|
||||
@@ -0,0 +1,16 @@
|
||||
#!/bin/sh
|
||||
|
||||
set -ex
|
||||
|
||||
# Generate bitcoin.conf
|
||||
btc_init
|
||||
|
||||
# Default / no argument invocation listens for RPC commands and has to accept non-localhost because of
|
||||
# Docker port proxying or Docker private networking.
|
||||
if [ $# -eq 0 ]; then
|
||||
# If IPv6 is in the container do both:
|
||||
#set -- '-rpcbind=[::]:8332' '-rpcallowip=::/0' '-rpcallowip=0.0.0.0/0'
|
||||
set -- '-rpcbind=:8332' '-rpcallowip=0.0.0.0/0'
|
||||
fi
|
||||
|
||||
exec bitcoind "$@"
|
||||
@@ -0,0 +1,18 @@
|
||||
#!/bin/sh
|
||||
set -e
|
||||
|
||||
# first arg is `-f` or `--some-option`
|
||||
# or first arg is `something.conf`
|
||||
if [ "${1#-}" != "$1" ] || [ "${1%.conf}" != "$1" ]; then
|
||||
set -- btc_oneshot "$@"
|
||||
fi
|
||||
|
||||
# Allow the container to be started with `--user`, if running as root drop privileges
|
||||
if [ "$1" = 'btc_oneshot' -a "$(id -u)" = '0' ]; then
|
||||
chown -R bitcoin .
|
||||
exec gosu bitcoin "$0" "$@"
|
||||
fi
|
||||
|
||||
# If not root (i.e. docker run --user $USER ...), then run as invoked
|
||||
exec "$@"
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
---
|
||||
# handlers file for build
|
||||
@@ -0,0 +1,52 @@
|
||||
galaxy_info:
|
||||
author: your name
|
||||
description: your role description
|
||||
company: your company (optional)
|
||||
|
||||
# If the issue tracker for your role is not on github, uncomment the
|
||||
# next line and provide a value
|
||||
# issue_tracker_url: http://example.com/issue/tracker
|
||||
|
||||
# Choose a valid license ID from https://spdx.org - some suggested licenses:
|
||||
# - BSD-3-Clause (default)
|
||||
# - MIT
|
||||
# - GPL-2.0-or-later
|
||||
# - GPL-3.0-only
|
||||
# - Apache-2.0
|
||||
# - CC-BY-4.0
|
||||
license: license (GPL-2.0-or-later, MIT, etc)
|
||||
|
||||
min_ansible_version: 2.1
|
||||
|
||||
# If this a Container Enabled role, provide the minimum Ansible Container version.
|
||||
# min_ansible_container_version:
|
||||
|
||||
#
|
||||
# Provide a list of supported platforms, and for each platform a list of versions.
|
||||
# If you don't wish to enumerate all versions for a particular platform, use 'all'.
|
||||
# To view available platforms and versions (or releases), visit:
|
||||
# https://galaxy.ansible.com/api/v1/platforms/
|
||||
#
|
||||
# platforms:
|
||||
# - name: Fedora
|
||||
# versions:
|
||||
# - all
|
||||
# - 25
|
||||
# - name: SomePlatform
|
||||
# versions:
|
||||
# - all
|
||||
# - 1.0
|
||||
# - 7
|
||||
# - 99.99
|
||||
|
||||
galaxy_tags: []
|
||||
# List tags for your role here, one per line. A tag is a keyword that describes
|
||||
# and categorizes the role. Users find roles by searching for tags. Be sure to
|
||||
# remove the '[]' above, if you add tags to this list.
|
||||
#
|
||||
# NOTE: A tag is limited to a single word comprised of alphanumeric characters.
|
||||
# Maximum 20 tags per role.
|
||||
|
||||
dependencies: []
|
||||
# List your role dependencies here, one per line. Be sure to remove the '[]' above,
|
||||
# if you add dependencies to this list.
|
||||
@@ -0,0 +1,7 @@
|
||||
---
|
||||
# tasks file for build
|
||||
#
|
||||
- name: Copy Containerfiles
|
||||
ansible.posix.synchronize:
|
||||
src: ContainerFiles
|
||||
dest: ContainerFiles
|
||||
@@ -0,0 +1,68 @@
|
||||
#Based on Dockerflie from Kyle Manna - https://github.com/kylemanna/docker-bitcoind
|
||||
|
||||
FROM almalinux/9-minimal AS build
|
||||
|
||||
RUN microdnf update -y \
|
||||
&& microdnf install -y \
|
||||
ca-certificates \
|
||||
gnupg2 \
|
||||
libatomic \
|
||||
wget \
|
||||
tar \
|
||||
gzip \
|
||||
&& microdnf clean all && rm -fr /tmp/* /var/tmp/*
|
||||
|
||||
ARG VERSION=26.0
|
||||
ARG BITCOIN_CORE_SIGNATURE=71A3B16735405025D447E8F274810B012346C9A6
|
||||
ENV GOSU_VERSION 1.17
|
||||
|
||||
RUN cd /tmp \
|
||||
&& gpg --keyserver hkp://keyserver.ubuntu.com --recv-keys ${BITCOIN_CORE_SIGNATURE} \
|
||||
&& wget https://bitcoincore.org/bin/bitcoin-core-${VERSION}/SHA256SUMS.asc \
|
||||
https://bitcoincore.org/bin/bitcoin-core-${VERSION}/SHA256SUMS \
|
||||
https://bitcoincore.org/bin/bitcoin-core-${VERSION}/bitcoin-${VERSION}-x86_64-linux-gnu.tar.gz \
|
||||
&& gpg --verify --status-fd 1 --verify SHA256SUMS.asc SHA256SUMS 2>/dev/null | grep "^\[GNUPG:\] VALIDSIG.*${BITCOIN_CORE_SIGNATURE}\$" \
|
||||
&& sha256sum --ignore-missing --check SHA256SUMS \
|
||||
&& tar -xzvf bitcoin-${VERSION}-x86_64-linux-gnu.tar.gz -C /opt \
|
||||
&& ln -sv bitcoin-${VERSION} /opt/bitcoin \
|
||||
&& /opt/bitcoin/bin/test_bitcoin --show_progress \
|
||||
&& rm -v /opt/bitcoin/bin/test_bitcoin /opt/bitcoin/bin/bitcoin-qt
|
||||
|
||||
RUN wget -O /usr/local/bin/gosu "https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-amd64"; \
|
||||
wget -O /usr/local/bin/gosu.asc "https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-amd64.asc"; \
|
||||
\
|
||||
# verify the signature
|
||||
export GNUPGHOME="$(mktemp -d)"; \
|
||||
gpg --batch --keyserver hkps://keys.openpgp.org --recv-keys B42F6819007F00F88E364FD4036A9C25BF357DD4; \
|
||||
gpg --batch --verify /usr/local/bin/gosu.asc /usr/local/bin/gosu; \
|
||||
gpgconf --kill all; \
|
||||
rm -rf "$GNUPGHOME" /usr/local/bin/gosu.asc;
|
||||
|
||||
FROM almalinux/9-minimal
|
||||
LABEL maintainer="b0xxer@b0xxy.net"
|
||||
|
||||
ENTRYPOINT ["entrypoint.sh"]
|
||||
ENV HOME /bitcoin
|
||||
EXPOSE 8332 8333
|
||||
VOLUME ["/bitcoin/.bitcoin"]
|
||||
WORKDIR /bitcoin
|
||||
|
||||
COPY --from=build /opt/ /opt/
|
||||
COPY --from=build /usr/local/bin/gosu /usr/local/bin/
|
||||
|
||||
RUN microdnf update -y \
|
||||
&& microdnf install -y libatomic shadow-utils \
|
||||
&& microdnf clean all && rm -rf /tmp/* /var/tmp/* \
|
||||
&& ln -sv /opt/bitcoin/bin/* /usr/local/bin
|
||||
|
||||
ARG GROUP_ID=1000
|
||||
ARG USER_ID=1000
|
||||
RUN groupadd -g ${GROUP_ID} bitcoin \
|
||||
&& useradd -u ${USER_ID} -g bitcoin -d /bitcoin bitcoin
|
||||
|
||||
|
||||
COPY ./bin ./entrypoint.sh /usr/local/bin/
|
||||
RUN chmod +x /usr/local/bin/entrypoint.sh && chmod +x /usr/local/bin/gosu \
|
||||
&& chmod +x /usr/local/bin/btc_oneshot && chmod +x /usr/local/bin/btc_init
|
||||
|
||||
CMD ["btc_oneshot"]
|
||||
@@ -0,0 +1,25 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -ex
|
||||
|
||||
# This shouldn't be in the Dockerfile or containers built from the same image
|
||||
# will have the same credentials.
|
||||
if [ ! -e "$HOME/.bitcoin/bitcoin.conf" ]; then
|
||||
mkdir -p $HOME/.bitcoin
|
||||
|
||||
echo "Creating bitcoin.conf"
|
||||
|
||||
# Seed a random password for JSON RPC server
|
||||
cat <<EOF > $HOME/.bitcoin/bitcoin.conf
|
||||
regtest=${REGTEST:-0}
|
||||
disablewallet=${DISABLEWALLET:-1}
|
||||
printtoconsole=${PRINTTOCONSOLE:-1}
|
||||
rpcuser=${RPCUSER:-bitcoinrpc}
|
||||
rpcpassword=${RPCPASSWORD:-`dd if=/dev/urandom bs=33 count=1 2>/dev/null | base64`}
|
||||
EOF
|
||||
|
||||
fi
|
||||
|
||||
cat $HOME/.bitcoin/bitcoin.conf
|
||||
|
||||
echo "Initialization completed successfully"
|
||||
@@ -0,0 +1,2 @@
|
||||
localhost
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
---
|
||||
- hosts: localhost
|
||||
remote_user: root
|
||||
roles:
|
||||
- build
|
||||
@@ -0,0 +1,2 @@
|
||||
---
|
||||
# vars file for build
|
||||
Reference in New Issue
Block a user