From 039d2cef384353bf229f424b274328bfa69c97ca Mon Sep 17 00:00:00 2001 From: randymcmillan Date: Sun, 15 May 2022 19:08:04 -0400 Subject: [PATCH 01/39] init: docker config --- GNUmakefile | 408 ++++++++++++++++++++++++++++++++++++++++++++ docker-compose.yml | 96 +++++++++++ statoshi.dockerfile | 142 +++++++++++++++ 3 files changed, 646 insertions(+) create mode 100644 GNUmakefile create mode 100755 docker-compose.yml create mode 100644 statoshi.dockerfile diff --git a/GNUmakefile b/GNUmakefile new file mode 100644 index 000000000000..099c5c0296a5 --- /dev/null +++ b/GNUmakefile @@ -0,0 +1,408 @@ +SHELL := /bin/bash +PWD ?= pwd_unknown +THIS_FILE := $(lastword $(MAKEFILE_LIST)) +export THIS_FILE +TIME := $(shell date +%s) +export TIME +ARCH := $(shell uname -m) +export ARCH +ifeq ($(user),) +#DEFAULT to root +HOST_USER := root +HOST_UID := $(strip $(if $(uid),$(uid),0)) +else +HOST_USER := $(strip $(if $(user),$(user),nodummy)) +HOST_UID := $(strip $(if $(shell id -u),$(shell id -u),4000)) +endif +export HOST_USER +export HOST_UID +ifeq ($(target),) +SERVICE_TARGET ?= statoshi +else +SERVICE_TARGET := $(target) +endif +export SERVICE_TARGET +ifeq ($(docker),) +DOCKER := $(shell which docker) +else +DOCKER := $(docker) +endif +export DOCKER +ifeq ($(compose),) +DOCKER_COMPOSE := $(shell which docker-compose) +else +DOCKER_COMPOSE := $(compose) +endif +export DOCKER_COMPOSE +ifeq ($(alpine),) +ALPINE_VERSION := 3.11.6 +else +ALPINE_VERSION := $(alpine) +endif +export ALPINE_VERSION +ifeq ($(project),) +PROJECT_NAME := $(notdir $(PWD)) +else +PROJECT_NAME := $(project) +endif +export PROJECT_NAME +GIT_USER_NAME := $(shell git config user.name) +export GIT_USER_NAME +GIT_USER_EMAIL := $(shell git config user.email) +export GIT_USER_EMAIL +GIT_SERVER := https://github.com +export GIT_SERVER +GIT_REPO_NAME := $(PROJECT_NAME) +export GIT_REPO_NAME +ifeq ($(profile),) +#USAGE EXAMPLE: make init profile=jlopp +GIT_PROFILE := bitcoincore-dev +else +GIT_PROFILE := $(profile) +endif +export GIT_PROFILE +#GIT_BRANCH := $(shell git rev-parse --abbrev-ref HEAD) +GIT_BRANCH := $(shell git rev-parse --short HEAD~0) +export GIT_BRANCH +GIT_HASH := $(shell git rev-parse --short HEAD~0) +export GIT_HASH +GIT_PREVIOUS_HASH := $(shell git rev-parse --short master@{1}) +export GIT_PREVIOUS_HASH +GIT_REPO_ORIGIN := $(shell git remote get-url origin) +export GIT_REPO_ORIGIN +GIT_REPO_PATH := $(HOME)/$(GIT_REPO_NAME) +export GIT_REPO_PATH +DOCKERFILE := $(PROJECT_NAME).dockerfile +export DOCKERFILE +DOCKERFILE_PATH := $(HOME)/$(PROJECT_NAME)/$(DOCKERFILE) +export DOCKERFILE_PATH +BITCOIN_CONF := $(HOME)/$(PROJECT_NAME)/conf/bitcoin.conf +export BITCOIN_CONF +ifeq ($(network),) +NETWORK := signet +else +NETWORK := $(network) +endif +export NETWORK +ifeq ($(datadir),) +DATADIR := $(HOME)/.statoshi +else +DATADIR := $(datadir) +endif +export DATADIR +ifeq ($(nocache),true) +NOCACHE := --no-cache +else +NOCACHE := +endif +export NOCACHE +ifeq ($(verbose),true) +VERBOSE := --verbose +else +VERBOSE := +endif +export VERBOSE +ifeq ($(port),) +PUBLIC_PORT := 80 +else +PUBLIC_PORT := $(port) +endif +export PUBLIC_PORT +ifeq ($(nodeport),) +NODE_PORT := 8333 +else +NODE_PORT := $(nodeport) +endif +export NODE_PORT +ifneq ($(passwd),) +PASSWORD := $(passwd) +else +PASSWORD := changeme +endif +export PASSWORD +ifeq ($(cmd),) +CMD_ARGUMENTS := +else +CMD_ARGUMENTS := $(cmd) +endif +export CMD_ARGUMENTS +PACKAGE_PREFIX := ghcr.io +export PACKAGE_PREFIX + +.PHONY: help +help: + @echo '' + @echo ' [USAGE]: make [BUILD] run [EXTRA_ARGUMENTS] ' + @echo '' + @echo ' make init' + @echo '' + @echo ' bitcoin commands:' + @echo '' + @echo ' make local-autogen' + @echo ' make local-configure' + @echo '' + @echo ' docker commands:' + @echo '' + @echo ' make build-docker' + @echo '' + @echo ' make init user=root uid=0 nocache=false verbose=true' + @echo '' + @echo ' [DEV ENVIRONMENT]: ' + @echo '' + @echo ' make build user=root' + @echo ' make run user=root' + @echo ' make shell user=$(HOST_USER)' + @echo '' + @echo ' [EXTRA_ARGUMENTS]: set build variables ' + @echo '' + @echo ' nocache=true' + @echo ' add --no-cache to docker command and apk add $(NOCACHE)' + @echo '' + @echo ' nodeport=integer' + @echo ' set NODE_PORT default 8333' + @echo '' + @echo ' TODO' + @echo '' + @echo ' [DOCKER COMMANDS]: push a command to the container ' + @echo '' + @echo ' cmd=command ' + @echo ' cmd="command" ' + @echo ' send CMD_ARGUMENTS to the [TARGET]' + @echo '' + @echo ' [EXAMPLE]:' + @echo '' + @echo ' make all run user=root uid=0 no-cache=true verbose=true' + @echo ' make report build run user=root uid=0 no-cache=true verbose=true cmd="top"' + @echo '' +.PHONY: report +report: + @echo '' + @echo ' [ARGUMENTS] ' + @echo ' args:' + @echo ' - HOME=${HOME}' + @echo ' - PWD=${PWD}' + @echo ' - UMBREL=${UMBREL}' + @echo ' - THIS_FILE=${THIS_FILE}' + @echo ' - TIME=${TIME}' + @echo ' - PACKAGE_PREFIX=${PACKAGE_PREFIX}' + @echo ' - ARCH=${ARCH}' + @echo ' - HOST_USER=${HOST_USER}' + @echo ' - HOST_UID=${HOST_UID}' + @echo ' - PUBLIC_PORT=${PUBLIC_PORT}' + @echo ' - NODE_PORT=${NODE_PORT}' + @echo ' - SERVICE_TARGET=${SERVICE_TARGET}' + @echo ' - ALPINE_VERSION=${ALPINE_VERSION}' + @echo ' - PROJECT_NAME=${PROJECT_NAME}' + @echo ' - DOCKER_BUILD_TYPE=${DOCKER_BUILD_TYPE}' + @echo ' - DOCKER_COMPOSE=${DOCKER_COMPOSE}' + @echo ' - DOCKERFILE=${DOCKERFILE}' + @echo ' - DOCKERFILE_BODY=${DOCKERFILE_BODY}' + @echo ' - GIT_USER_NAME=${GIT_USER_NAME}' + @echo ' - GIT_USER_EMAIL=${GIT_USER_EMAIL}' + @echo ' - GIT_SERVER=${GIT_SERVER}' + @echo ' - GIT_PROFILE=${GIT_PROFILE}' + @echo ' - GIT_BRANCH=${GIT_BRANCH}' + @echo ' - GIT_HASH=${GIT_HASH}' + @echo ' - GIT_PREVIOUS_HASH=${GIT_PREVIOUS_HASH}' + @echo ' - GIT_REPO_ORIGIN=${GIT_REPO_ORIGIN}' + @echo ' - GIT_REPO_NAME=${GIT_REPO_NAME}' + @echo ' - GIT_REPO_PATH=${GIT_REPO_PATH}' + @echo ' - DOCKERFILE=${DOCKERFILE}' + @echo ' - DOCKERFILE_PATH=${DOCKERFILE_PATH}' + @echo ' - BITCOIN_CONF=${BITCOIN_CONF}' + @echo ' - NETWORK=${NETWORK}' + @echo ' - DATADIR=${DATADIR}' + @echo ' - NOCACHE=${NOCACHE}' + @echo ' - VERBOSE=${VERBOSE}' + @echo ' - NODE_PORT=${NODE_PORT}' + @echo ' - PASSWORD=${PASSWORD}' + @echo ' - CMD_ARGUMENTS=${CMD_ARGUMENTS}' + +####################### + +ORIGIN_DIR:=$(PWD) +MACOS_TARGET_DIR:=/var/root/$(PROJECT_NAME) +LINUX_TARGET_DIR:=/root/$(PROJECT_NAME) +export ORIGIN_DIR +export TARGET_DIR + +.PHONY: super +super: +ifneq ($(shell id -u),0) + @echo switch to superuser + @echo cd $(TARGET_DIR) + #sudo ln -s $(PWD) $(TARGET_DIR) +#.ONESHELL: + sudo -s +endif +####################### +####################### +# Backup $HOME/.bitcoin +######################## +#backup: +# @echo '' +# bash -c 'mkdir -p $(HOME)/.bitcoin' +## bash -c 'conf/get_size.sh' +# bash -c 'tar czv --exclude=*.log --exclude=banlist.dat \ +# --exclude=fee_exstimates.dat --exclude=mempool.dat \ +# --exclude=peers.dat --exclude=.cookie --exclude=database \ +# --exclude=.lock --exclude=.walletlock --exclude=.DS_Store\ +# -f $(HOME)/.bitcoin-$(TIME).tar.gz $(HOME)/.bitcoin' +# bash -c 'openssl md5 $(HOME)/.bitcoin-$(TIME).tar.gz > $(HOME)/bitcoin-$(TIME).tar.gz.md5' +# bash -c 'openssl md5 -c $(HOME)/bitcoin-$(TIME).tar.gz.md5' +# +# +# @echo '' +####################### +# Some initial setup +######################## +####################### + +.PHONY: host +host: + @echo 'host' + bash -c './host' + +####################### +.PHONY: init +.SILENT: +init: + git config --global core.editor vim + docker pull docker.io/graphiteapp/graphite-statsd:latest + docker pull ghcr.io/bitcoincore-dev/statoshi/$(ARCH)/root:latest +ifneq ($(shell id -u),0) + sudo bash -c 'mkdir -p /usr/local/include/' + sudo bash -c 'install -v $(PWD)/src/statsd_client.h /usr/local/include/statsd_client.h' + sudo bash -c 'install -v $(PWD)/src/statsd_client.cpp /usr/local/include/statsd_client.cpp' +endif + rm -f Makefile +####################### +.PHONY: local-autogen +local-autogen: + ./autogen.sh +.PHONY: local-configure +local-configure: + ./configure --disable-wallet --disable-tests --disable-hardening --disable-man --enable-util-cli --enable-util-tx --with-gui=no --disable-bench +.PHONY: signin +signin: + bash -c 'cat ~/GH_TOKEN.txt | docker login ghcr.io -u RandyMcMillan --password-stdin' + docker tag $(PROJECT_NAME):$(HOST_USER) $(PACKAGE_PREFIX)/$(GIT_PROFILE)/$(PROJECT_NAME)/$(ARCH)/$(HOST_USER) + +.PHONY: build build-docker +build: build-docker +build-docker: + @echo 'build' + #$(DOCKER_COMPOSE) $(VERBOSE) build --pull $(NOCACHE) statoshi + $(DOCKER_COMPOSE) $(VERBOSE) build $(NOCACHE) statoshi + @echo '' +####################### +.PHONY: run +run: init + @echo 'run' +ifeq ($(CMD_ARGUMENTS),) + @echo '' + $(DOCKER_COMPOSE) $(VERBOSE) -p $(PROJECT_NAME)_$(HOST_UID) run -d statoshi sh + #$(DOCKER_COMPOSE) $(VERBOSE) -p $(PROJECT_NAME)_$(HOST_UID) run -d --publish 8125:8125 --publish 8126:8126 --publish 8333:8333 --publish 8332:8332 statoshi sh + @echo '' +else + @echo '' + $(DOCKER_COMPOSE) $(VERBOSE) -p $(PROJECT_NAME)_$(HOST_UID) run -d statoshi sh -c "$(CMD_ARGUMENTS)" + #$(DOCKER_COMPOSE) $(VERBOSE) -p $(PROJECT_NAME)_$(HOST_UID) run -d --publish 8125:8125 --publish 8126:8126 --publish 8333:8333 --publish 8332:8332 statoshi sh -c "$(CMD_ARGUMENTS)" + @echo '' +endif +####################### +.PHONY: torproxy +torproxy: + @echo '' + #REF: https://hub.docker.com/r/dperson/torproxy + bash -c 'docker run -it -p 8118:8118 -p 9050:9050 -p 9051:9051 -d dperson/torproxy' + @echo '' +ifneq ($(shell id -u),0) + bash -c 'sudo make torproxy user=root &' +endif +ifeq ($(CMD_ARGUMENTS),) + $(DOCKER_COMPOSE) $(VERBOSE) -f docker-compose.yml -p $(PROJECT_NAME)_$(HOST_UID) run --publish 8118:8118 --publish 9050:9050 --publish 9051:9051 --rm torproxy +else + $(DOCKER_COMPOSE) $(VERBOSE) -f docker-compose.yml -p $(PROJECT_NAME)_$(HOST_UID) run --publish 8118:8118 --publish 9050:9050 --publish 9051:9051 --rm torproxy sh -c "$(CMD_ARGUMENTS)" +endif + @echo '' +####################### +.PHONY: clean +clean: + # remove created images + @$(DOCKER_COMPOSE) -p $(PROJECT_NAME)_$(HOST_UID) down --remove-orphans --rmi all 2>/dev/null \ + && echo 'Image(s) for "$(PROJECT_NAME):$(HOST_USER)" removed.' \ + || echo 'Image(s) for "$(PROJECT_NAME):$(HOST_USER)" already removed.' + @rm -f Makefile +####################### +.PHONY: prune +prune: + @echo 'prune' + $(DOCKER_COMPOSE) -p $(PROJECT_NAME)_$(HOST_UID) down + docker system prune -f +####################### +.PHONY: prune-network +prune-network: + @echo 'prune-network' + $(DOCKER_COMPOSE) -p $(PROJECT_NAME)_$(HOST_UID) down + docker network prune -f +####################### +.PHONY: docs +statoshi-docs: +#$ make report no-cache=true verbose=true cmd='make doc' user=root doc +#SHELL := /bin/bash + @echo 'docs' + #bash -c "if pgrep MacDown; then pkill MacDown; fi" + bash -c "touch $(PWD)/docker/README.md" + curl -o $(PWD)/docker/README.md https://raw.githubusercontent.com/jlopp/statoshi/master/README.md + bash -c "cat $(PWD)/docker/README.md" + bash -c "cat $(PWD)/docker/README.md > README.md" + bash -c "echo ' ' >> README.md" + #bash -c "echo '' >> README.md" + bash -c "echo '----' >> README.md" + bash -c "cat $(PWD)/docker/DOCKER.md >> README.md" + #bash -c "echo '## [$(PROJECT_NAME)]($(GIT_SERVER)/$(GIT_PROFILE)/$(PROJECT_NAME)) ' >> README.md" + bash -c "echo '##### $ make' >> README.md" + bash -c "make help >> README.md" + #bash -c "if hash open 2>/dev/null; then open README.md; fi || echo failed to open README.md" +.PHONY: push +push: + @echo 'push' + #bash -c "git reset --soft HEAD~1 || echo failed to add docs..." + #bash -c "git add README.md docker/README.md docker/DOCKER.md *.md docker/*.md || echo failed to add docs..." + #bash -c "git commit --amend --no-edit --allow-empty -m '$(GIT_HASH)' || echo failed to commit --amend --no-edit" + #bash -c "git commit --no-edit --allow-empty -m '$(GIT_PREVIOUS_HASH)' || echo failed to commit --amend --no-edit" + bash -c "git push -f --all git@github.com:$(GIT_PROFILE)/$(PROJECT_NAME).git || echo failed to push docs" +.PHONY: push-docs +push-docs: docs push + @echo 'push-docs' +####################### +package-statoshi: init signin + #@echo "legit . -m "$(HOST_USER):$(TIME)" -p 0000000 && make user=root package && GPF" + bash -c 'cat ~/GH_TOKEN.txt | docker login ghcr.io -u RandyMcMillan --password-stdin' + bash -c 'docker tag $(PROJECT_NAME):$(HOST_USER) ghcr.io/$(GIT_PROFILE)/$(PROJECT_NAME)/$(ARCH)/$(HOST_USER):$(TIME)' + bash -c 'docker push ghcr.io/$(GIT_PROFILE)/$(PROJECT_NAME)/$(ARCH)/$(HOST_USER):$(TIME)' + bash -c 'docker tag $(PROJECT_NAME):$(HOST_USER) ghcr.io/$(GIT_PROFILE)/$(PROJECT_NAME)/$(ARCH)/$(HOST_USER)' + bash -c 'docker push ghcr.io/$(GIT_PROFILE)/$(PROJECT_NAME)/$(ARCH)/$(HOST_USER)' +# +# touch TIME && echo $(TIME) > TIME && git add -f TIME +# #legit . -m "make package-header at $(TIME)" -p 00000 +# git commit --amend --no-edit --allow-empty +# bash -c 'docker tag $(PROJECT_NAME):$(HOST_USER) $(PACKAGE_PREFIX)/$(GIT_PROFILE)/$(PROJECT_NAME)/$(ARCH)/$(HOST_USER):$(TIME)' +# bash -c 'docker push $(PACKAGE_PREFIX)/$(GIT_PROFILE)/$(PROJECT_NAME)/$(ARCH)/$(HOST_USER):$(TIME)' +# bash -c 'docker tag $(PROJECT_NAME):$(HOST_USER) $(PACKAGE_PREFIX)/$(GIT_PROFILE)/$(PROJECT_NAME)/$(ARCH)/$(HOST_USER)' #defaults to latest +# bash -c 'docker push $(PACKAGE_PREFIX)/$(GIT_PROFILE)/$(PROJECT_NAME)/$(ARCH)/$(HOST_USER)' + +######################## +.PHONY: package-build-all +package-build-all: init signin package-statoshi + + make build-docker package-statoshi + +######################## +.PHONY: automate +automate: + ./.github/workflows/automate.sh +#-include funcs.mk +-include Makefile + diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100755 index 000000000000..aa3c8c03d96f --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,96 @@ +version: '3.4' +services: + + statoshi: + # Makefile fills PROJECT_NAME to current directory name. + # add UID to allow multiple users run this in parallel + container_name: ${PROJECT_NAME}_${HOST_UID:-4000} + hostname: ${PROJECT_NAME} + ## These variables are passed into the container. + #environment: + # - TIME=${TIME} + # - PACKAGE_PREFIX=${PACKAGE_PREFIX} + # - ARCH=${ARCH} + # - HOST_USER=${HOST_USER} + # - HOST_UID=${HOST_UID} + # - ALPINE_VERSION=${ALPINE_VERSION} + # - PROJECT_NAME=${PROJECT_NAME} + # - GIT_SERVER=${GIT_SERVER} + # - GIT_PROFILE=${GIT_PROFILE} + # - GIT_REPO_NAME=${GIT_REPO_NAME} + # - BITCOIN_CONF=${BITCOIN_CONF} + # - NETWORK=${NETWORK} + # - DATADIR=${DATADIR} + # - NOCACHE=${NOCACHE} + # - VERBOSE=${VERBOSE} + # - PUBLIC_PORT=${PUBLIC_PORT} + # - NODE_PORT=${NODE_PORT} + # - PASSWORD=${PASSWORD} + # - CMD_ARGUMENTS=${CMD_ARGUMENTS} + ## Run with user priviliges by default. + user: ${HOST_USER:-nodummy} + image: ghcr.io/bitcoincore-dev/statoshi/${ARCH}/root:latest + restart: unless-stopped + build: + context: . + # This is the name of the last layer in stats.bitcoincore.dev + dockerfile: ${PROJECT_NAME}.dockerfile + # These variables are passed to Dockerfile. + args: + - TIME=${TIME} + - PACKAGE_PREFIX=${PACKAGE_PREFIX} + - ARCH=${ARCH} + - HOST_USER=${HOST_USER} + - HOST_UID=${HOST_UID} + - ALPINE_VERSION=${ALPINE_VERSION} + - PROJECT_NAME=${PROJECT_NAME} + - GIT_SERVER=${GIT_SERVER} + - GIT_PROFILE=${GIT_PROFILE} + - BITCOIN_CONF=${BITCOIN_CONF} + - NETWORK=${NETWORK} + - DATADIR=${DATADIR} + - NOCACHE=${NOCACHE} + - VERBOSE=${VERBOSE} + - PUBLIC_PORT=${PUBLIC_PORT} + - NODE_PORT=${NODE_PORT} + - PASSWORD=${PASSWORD} + - CMD_ARGUMENTS=${CMD_ARGUMENTS} + # Run container as a service. Replace with something useful. + #command: ["tail", "-f", "/dev/null"] + #command: ["/usr/local/bin/entrypoint"] + # Expose current project folder to container. + volumes: + - ${HOME:-.}:/home/${HOST_USER}:consistent + - ${HOME:-.}/.statoshi:/home/${HOST_USER}/.bitcoin:consistent + - ${PWD:-.}:/home/${HOST_USER}/${PROJECT_NAME}:consistent + - ${PWD:-.}:/tmp:consistent + ports: + #hostPORT:imagePORT + - "8332:8332" + #- "${NODE_PORT}:${NODE_PORT}" + - "18332:18332" + - "38333:38333" + + torproxy: + links: + - statoshi + # Makefile fills PROJECT_NAME to current directory name. + # add UID to allow multiple users run this in parallel + container_name: ${PROJECT_NAME}_${HOST_UID:-4000} + hostname: ${PROJECT_NAME} + # These variables are passed into the container. + user: ${HOST_USER:-nodummy} + image: ${PROJECT_NAME}_torproxy:${HOST_USER:-nodummy} + restart: unless-stopped + command: ["/sbin/tini", "--", "/usr/bin/torproxy.sh"] + # Expose current project folder to container. + volumes: + - /etc/tor + - /var/lib/tor + ports: + #hostPORT:imagePORT + #we expose tor proxy ports for 'make torproxy' + - "8118:8118" + - "9050:9050" + - "9051:9051" + diff --git a/statoshi.dockerfile b/statoshi.dockerfile new file mode 100644 index 000000000000..e33113a5f41e --- /dev/null +++ b/statoshi.dockerfile @@ -0,0 +1,142 @@ +ARG BASE_IMAGE=docker.io/graphiteapp/graphite-statsd:latest +##################################### +FROM ${BASE_IMAGE} as header +##################################### +ENV PROFILE_NAME=${PROFILE_NAME} +ENV PROJECT_NAME=${PROJECT_NAME} +LABEL org.opencontainers.image.source https://github.com/${PROFILE_NAME}/${PROJECT_NAME} +LABEL org.opencontainers.image.description Dockerized Statoshi.info node +# linux-headers for futex.h in Qt depends build +# qt5-qttools-dev for lrelease +RUN apk ${VERBOSE} ${NOCACHE} --update add \ + autoconf \ + automake \ + #bash-completion \ + bison \ + #busybox \ + boost-dev \ + #core-utils \ + cmake \ + curl \ + g++ \ + gcc \ + git \ + libevent-dev \ + libqrencode-dev \ + libtool \ + linux-headers \ + make \ + #mingw-w64-gcc \ + miniupnpc-dev \ + #musl \ + patch \ + perl \ + pkgconfig \ + python3 \ + python3-dev \ + qt5-qtbase-dev \ + qt5-qttools-dev \ + sqlite \ + valgrind \ + vim \ + zeromq-dev +#RUN apk update && apk upgrade +#RUN apk add ${VERBOSE} ${NOCACHE} \ +# autoconf \ +# automake \ +# binutils \ +# ca-certificates \ +# cmake \ +# curl \ +# doxygen \ +# git \ +# libtool \ +# make \ +# patch \ +# pkgconfig \ +# python3 \ +# py3-psutil \ +# vim +# +#RUN apk add ${VERBOSE} ${NOCACHE} \ +# g++ \ +# build-base \ +# boost-libs \ +# libgcc \ +# libstdc++ \ +# musl \ +# boost-system \ +# boost-build \ +# boost-dev \ +# openssl-dev \ +# libevent-dev \ +# libzmq \ +# zeromq-dev \ +# protobuf-dev \ +# linux-headers \ +# libbz2 \ +# libcap-dev \ +# librsvg \ +# tiff-tools \ +# zlib-dev \ +# py3-setuptools +# install statsd (as we have to use this ugly way) +RUN apk add libzmq +RUN python3 -m ensurepip --upgrade +RUN python3 -m pip install pyzmq + +#ARG GIT_SERVER=${GIT_SERVER} +#ARG PROFILE=${PROFILE} +#ARG PROJECT_NAME=${PROJECT_NAME} +#ENV GIT_SERVER=${GIT_SERVER} +#ENV PROFILE=${PROFILE} +#ENV PROJECT_NAME=${PROJECT_NAME} +############################ +RUN mkdir -p /root/.bitcoin +WORKDIR /tmp/statoshi +COPY . /tmp/statoshi +COPY ./src/statsd_client.h /usr/local/include/ +COPY ./src/statsd_client.cpp /usr/local/include/ +############################ +FROM header as build-statoshi +# Place Holders +RUN ls /tmp/statoshi/* +RUN ls /usr/local/include/* +############################ +FROM build-statoshi as autogen +############################ +ARG NETWORK=${NETWORK} +ENV NETWORK=${NETWORK} +WORKDIR /tmp/statoshi +# COPY ./conf/usr/local/bin/blocknotify /etc/periodic/15min/blocknotify +# COPY ./conf/${NETWORK}.conf /root/.bitcoin/bitcoin.conf +RUN ./autogen.sh +######################### +FROM autogen as configure +######################### +WORKDIR /tmp/statoshi +# RUN make -f Makefile -C depends +RUN ./configure --disable-tests --disable-hardening --disable-man --disable-bench --with-gui=no --disable-wallet +###################### +FROM configure as make +###################### +WORKDIR /tmp/statoshi +RUN make -f Makefile +###################### +FROM make as install +###################### +WORKDIR /tmp/statoshi +RUN mkdir -p /usr/local/bin/ +RUN make -f Makefile install +###################### +EXPOSE 80 2003-2004 2013-2014 2023-2024 3000 8080 8118 8333 8332 18333 8125 8125/udp 8126 9050 9051 +###################### +FROM install as install-statsd +###################### +COPY --from=install /usr /usr +COPY --from=install /etc /etc +COPY --from=install /root/.bitcoin /root/.bitcoin + +ENTRYPOINT ["entrypoint"] +CMD ["bitcoind"] + From 370c5342e9744182b40f0862234eaa5bf8248327 Mon Sep 17 00:00:00 2001 From: "@RandyMcMillan" Date: Sat, 4 Jun 2022 01:00:18 -0400 Subject: [PATCH 02/39] Create c-cpp.yml --- .github/workflows/c-cpp.yml | 94 +++++++++++++++++++++++++++++++++++++ 1 file changed, 94 insertions(+) create mode 100644 .github/workflows/c-cpp.yml diff --git a/.github/workflows/c-cpp.yml b/.github/workflows/c-cpp.yml new file mode 100644 index 000000000000..ff7daca80064 --- /dev/null +++ b/.github/workflows/c-cpp.yml @@ -0,0 +1,94 @@ +name: C/C++ CI + +on: + pull_request: + branches: #[ master ] + - '*' # matches every branch that doesn't contain a '/' + - '*/*' # matches every branch containing a single '/' + - '**' # matches every branch + - 'master' # includes master + - 'main' # includes main + # Triggers the workflow on push or pull request events but only for the master branch + push: + #paths: + # - '.github/workflows/automate.yml' + #schedule: + # - cron: "*/5 * * * *" + branches: #[ master ] + - '*' # matches every branch that doesn't contain a '/' + - '*/*' # matches every branch containing a single '/' + - '**' # matches every branch + - 'master' # includes master + - 'main' # includes main + + workflow_dispatch: + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + - uses: actions/cache@v3 + with: + path: | + ${{ github.workspace }}/src/bitcoind + key: ${{ runner.os }}-bitcoind + restore-keys: | + ${{ runner.os }}-bitcoind- + - name: install libs-1 + run: | + sudo \ + apt-get install --no-install-recommends -y \ + automake \ + binutils \ + bsdmainutils \ + ca-certificates \ + cmake \ + curl \ + diffoscope \ + doxygen \ + g++-multilib \ + git \ + libbz2-dev \ + libcap-dev \ + libtinfo5 \ + libtool \ + lbzip2 \ + libz-dev \ + make \ + nsis \ + patch \ + pkg-config \ + python3 \ + python3-setuptools \ + ripgrep \ + vim \ + xz-utils + # Split cross-compilers out. + # apt cant install everything at once + - name: install libs-2 + run: | + sudo \ + apt-get install --no-install-recommends -y \ + g++-aarch64-linux-gnu \ + binutils-aarch64-linux-gnu \ + g++-arm-linux-gnueabihf \ + binutils-arm-linux-gnueabihf \ + binutils-riscv64-linux-gnu \ + g++-riscv64-linux-gnu # \ + # g++-mingw-w64-x86-64-posix + - name: autogen.sh + run: | + ./autogen.sh + - name: make -C depends + run: | + make -C depends + - name: configure + run: | + ./configure + - name: make check + run: make check + - name: make distcheck + run: make distcheck From 43b325331d3645ac159054a9fb0b017f6a8bd250 Mon Sep 17 00:00:00 2001 From: randymcmillan Date: Sat, 4 Jun 2022 01:39:09 -0400 Subject: [PATCH 03/39] workflow: install -v ./src/statsd_client.h/cpp /usr/local/include/ --- .github/workflows/c-cpp.yml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/workflows/c-cpp.yml b/.github/workflows/c-cpp.yml index ff7daca80064..f40a113d0422 100644 --- a/.github/workflows/c-cpp.yml +++ b/.github/workflows/c-cpp.yml @@ -79,12 +79,16 @@ jobs: binutils-riscv64-linux-gnu \ g++-riscv64-linux-gnu # \ # g++-mingw-w64-x86-64-posix + - name: install statsd + run: | + install -v ./src/statsd_client.h /usr/local/include/ + install -v ./src/statsd_client.cpp /usr/local/include/ - name: autogen.sh run: | ./autogen.sh - - name: make -C depends + - name: make download -C depends run: | - make -C depends + make download -C depends - name: configure run: | ./configure From f2a0efa1548f49637a6ea25298ef69e336f40e8d Mon Sep 17 00:00:00 2001 From: randymcmillan Date: Sat, 4 Jun 2022 01:48:47 -0400 Subject: [PATCH 04/39] .github/workflows/c-cpp.yml: cache depends --- .github/workflows/c-cpp.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/c-cpp.yml b/.github/workflows/c-cpp.yml index f40a113d0422..80e8dcc64cec 100644 --- a/.github/workflows/c-cpp.yml +++ b/.github/workflows/c-cpp.yml @@ -33,6 +33,7 @@ jobs: - uses: actions/cache@v3 with: path: | + ${{ github.workspace }}/depends ${{ github.workspace }}/src/bitcoind key: ${{ runner.os }}-bitcoind restore-keys: | @@ -81,14 +82,15 @@ jobs: # g++-mingw-w64-x86-64-posix - name: install statsd run: | - install -v ./src/statsd_client.h /usr/local/include/ - install -v ./src/statsd_client.cpp /usr/local/include/ + sudo -s install -v ./src/statsd_client.h /usr/local/include/ + sudo -s install -v ./src/statsd_client.cpp /usr/local/include/ - name: autogen.sh run: | ./autogen.sh - name: make download -C depends run: | make download -C depends + make install -C depends - name: configure run: | ./configure From c3956d15a163e2369902393603d477468d7fd8e4 Mon Sep 17 00:00:00 2001 From: randymcmillan Date: Sat, 4 Jun 2022 01:54:50 -0400 Subject: [PATCH 05/39] workflow: cache depends bitcoind --- .github/workflows/c-cpp.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.github/workflows/c-cpp.yml b/.github/workflows/c-cpp.yml index 80e8dcc64cec..33e2237c241f 100644 --- a/.github/workflows/c-cpp.yml +++ b/.github/workflows/c-cpp.yml @@ -30,6 +30,13 @@ jobs: steps: - uses: actions/checkout@v3 + - uses: actions/cache@v3 + with: + path: | + ${{ github.workspace }}/depends + key: ${{ runner.os }}-depends + restore-keys: | + ${{ runner.os }}-depends - uses: actions/cache@v3 with: path: | From 73a326a1cbab8789328d98a78d1a46efe0355dc8 Mon Sep 17 00:00:00 2001 From: randymcmillan Date: Sat, 4 Jun 2022 02:34:33 -0400 Subject: [PATCH 06/39] .github/workflows/c-cpp.yml: install everything for linux --- .github/workflows/c-cpp.yml | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/.github/workflows/c-cpp.yml b/.github/workflows/c-cpp.yml index 33e2237c241f..7f5c52f21664 100644 --- a/.github/workflows/c-cpp.yml +++ b/.github/workflows/c-cpp.yml @@ -73,7 +73,15 @@ jobs: python3-setuptools \ ripgrep \ vim \ - xz-utils + xz-utils \ + build-essential libtool autotools-dev \ + automake pkg-config bsdmainutils python3 \ + libevent-dev libboost-dev \ + libsqlite3-dev libminiupnpc-dev libnatpmp-dev \ + libzmq3-dev systemtap-sdt-dev \ + libqt5gui5 libqt5core5a libqt5dbus5 qttools5-dev qttools5-dev-tools \ + qtwayland5 libqrencode-dev + # Split cross-compilers out. # apt cant install everything at once - name: install libs-2 @@ -96,8 +104,9 @@ jobs: ./autogen.sh - name: make download -C depends run: | - make download -C depends - make install -C depends + # make download -C depends + # make install -C depends + echo - name: configure run: | ./configure From 6e5fb3e38c9501e51ede97c2cbdd77638076a3df Mon Sep 17 00:00:00 2001 From: randymcmillan Date: Sat, 4 Jun 2022 02:42:42 -0400 Subject: [PATCH 07/39] .github/workflows/c-cpp.yml: aarch64 cross compile --- .github/workflows/c-cpp.yml | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/.github/workflows/c-cpp.yml b/.github/workflows/c-cpp.yml index 7f5c52f21664..75b8265ae595 100644 --- a/.github/workflows/c-cpp.yml +++ b/.github/workflows/c-cpp.yml @@ -91,10 +91,14 @@ jobs: g++-aarch64-linux-gnu \ binutils-aarch64-linux-gnu \ g++-arm-linux-gnueabihf \ - binutils-arm-linux-gnueabihf \ + binutils-arm-linux-gnueabihf curl \ binutils-riscv64-linux-gnu \ - g++-riscv64-linux-gnu # \ - # g++-mingw-w64-x86-64-posix + g++-riscv64-linux-gnu \ + binutils-gold \ + bsdmainutils pkg-config python3 patch bison \ + g++-arm-linux-gnueabihf binutils-arm-linux-gnueabihf \ + g++-aarch64-linux-gnu #\ + # binutils-aarch64-linux-gnu - name: install statsd run: | sudo -s install -v ./src/statsd_client.h /usr/local/include/ @@ -104,13 +108,20 @@ jobs: ./autogen.sh - name: make download -C depends run: | + cd depends + make HOST=arm-linux-gnueabihf NO_QT=1 + cd .. # make download -C depends # make install -C depends + ./autogen.sh echo - name: configure run: | - ./configure + # ./configure + # CONFIG_SITE=$PWD/depends/arm-linux-gnueabihf/share/config.site ./configure --enable-reduce-exports LDFLAGS=-static-libstdc++ + CONFIG_SITE=$PWD/depends/aarch64-linux-gnu/share/config.site ./configure --enable-reduce-exports LDFLAGS=-static-libstdc++ - name: make check - run: make check + run: | + make check - name: make distcheck run: make distcheck From 61dc627f468180facc2e0935c7a8dd649bc4fbf8 Mon Sep 17 00:00:00 2001 From: randymcmillan Date: Sat, 4 Jun 2022 04:09:08 -0400 Subject: [PATCH 08/39] configure: aarch64-linux-gnu --disable tests bench man wallet gui=no --- .github/workflows/c-cpp.yml | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/.github/workflows/c-cpp.yml b/.github/workflows/c-cpp.yml index 75b8265ae595..c179dc439935 100644 --- a/.github/workflows/c-cpp.yml +++ b/.github/workflows/c-cpp.yml @@ -109,7 +109,8 @@ jobs: - name: make download -C depends run: | cd depends - make HOST=arm-linux-gnueabihf NO_QT=1 + # make HOST=arm-linux-gnueabihf NO_QT=1 + make HOST=aarch64-linux-gnu NO_QT=1 cd .. # make download -C depends # make install -C depends @@ -119,7 +120,13 @@ jobs: run: | # ./configure # CONFIG_SITE=$PWD/depends/arm-linux-gnueabihf/share/config.site ./configure --enable-reduce-exports LDFLAGS=-static-libstdc++ - CONFIG_SITE=$PWD/depends/aarch64-linux-gnu/share/config.site ./configure --enable-reduce-exports LDFLAGS=-static-libstdc++ + CONFIG_SITE=$PWD/depends/aarch64-linux-gnu/share/config.site ./configure \ + --disable-wallet \ + --disable-tests \ + --disable-bench \ + --disable-man \ + --with-gui=no \ + --enable-reduce-exports LDFLAGS=-static-libstdc++ - name: make check run: | make check From bca2da49a75a88d886a346c76ec6ac1725e2eb16 Mon Sep 17 00:00:00 2001 From: randymcmillan Date: Sat, 4 Jun 2022 05:01:17 -0400 Subject: [PATCH 09/39] .github/workflows/c-cpp.yml: make install end --- .github/workflows/c-cpp.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/c-cpp.yml b/.github/workflows/c-cpp.yml index c179dc439935..2a64155055cf 100644 --- a/.github/workflows/c-cpp.yml +++ b/.github/workflows/c-cpp.yml @@ -130,5 +130,5 @@ jobs: - name: make check run: | make check - - name: make distcheck - run: make distcheck + - name: make install + run: sudo make install From 961e9e478a39b0e3eced8f15da92835e31fac4b8 Mon Sep 17 00:00:00 2001 From: randymcmillan Date: Sat, 4 Jun 2022 14:07:32 -0400 Subject: [PATCH 10/39] make: shell nocache=true working --- GNUmakefile | 794 ++++++++++++++++++++++----------------- docker-compose.yml | 110 ++---- docker/ubuntu.dockerfile | 121 ++++++ 3 files changed, 599 insertions(+), 426 deletions(-) mode change 100755 => 100644 docker-compose.yml create mode 100644 docker/ubuntu.dockerfile diff --git a/GNUmakefile b/GNUmakefile index 099c5c0296a5..280155102174 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -1,202 +1,313 @@ SHELL := /bin/bash -PWD ?= pwd_unknown -THIS_FILE := $(lastword $(MAKEFILE_LIST)) +NOHUP := $(shell which nohup) + +PWD ?= pwd_unknown + +THIS_FILE := $(lastword $(MAKEFILE_LIST)) export THIS_FILE -TIME := $(shell date +%s) +TIME := $(shell date +%s) export TIME -ARCH := $(shell uname -m) + +ARCH :=$(shell uname -m) export ARCH -ifeq ($(user),) -#DEFAULT to root -HOST_USER := root -HOST_UID := $(strip $(if $(uid),$(uid),0)) +ifeq ($(ARCH),x86_64) +TRIPLET :=x86_64-linux-gnu +export TRIPLET +endif +ifeq ($(ARCH),arm64) +TRIPLET :=aarch64-linux-gnu +export TRIPLET +endif + +ifneq ($(target),) +SERVICE_TARGET := $(target) +else +SERVICE_TARGET := ubuntu +endif +export SERVICE_TARGET + +ifeq ($(nocache),true) +NOCACHE:=--no-cache +endif +ifeq ($(verbose),true) +NOCACHE:=--verbose +endif + +ifeq ($(user),root) +HOST_USER :=root +HOST_UID :=$(strip $(if $(uid),$(uid),0)) else -HOST_USER := $(strip $(if $(user),$(user),nodummy)) -HOST_UID := $(strip $(if $(shell id -u),$(shell id -u),4000)) +#allow override by adding user= and/ or uid= (lowercase!). +#uid= defaults to 0 if user= set (i.e. root). +#USER retrieved from env, UID from shell. +HOST_USER :=$(strip $(if $(USER),$(USER),nodummy)) +HOST_UID :=$(strip $(if $(shell id -u),$(shell id -u),4000)) endif export HOST_USER export HOST_UID -ifeq ($(target),) -SERVICE_TARGET ?= statoshi + + +PYTHON := $(shell which python) +export PYTHON +PYTHON2 := $(shell which python2) +export PYTHON2 +PYTHON3 := $(shell which python3) +export PYTHON3 + +PIP := $(shell which pip) +export PIP +PIP2 := $(shell which pip2) +export PIP2 +PIP3 := $(shell which pip3) +export PIP3 + +python_version_full := $(wordlist 2,4,$(subst ., ,$(shell python3 --version 2>&1))) +python_version_major := $(word 1,${python_version_full}) +python_version_minor := $(word 2,${python_version_full}) +python_version_patch := $(word 3,${python_version_full}) + +my_cmd.python.3 := $(PYTHON3) some_script.py3 +my_cmd := ${my_cmd.python.${python_version_major}} + +PYTHON_VERSION := ${python_version_major}.${python_version_minor}.${python_version_patch} +PYTHON_VERSION_MAJOR := ${python_version_major} +PYTHON_VERSION_MINOR := ${python_version_minor} + +export python_version_major +export python_version_minor +export python_version_patch +export PYTHON_VERSION + + +# NOTE: docker doesnt like names with dots +# Use $(GIT_REPO_NAME) for commands that need the dotted name +# $(PROJECT_NAME) is used in many docker commands in the GNUmakefile +ifeq ($(project),) +PROJECT_NAME := timechain-academy#$(notdir $(PWD)) else -SERVICE_TARGET := $(target) +PROJECT_NAME := $(project) endif -export SERVICE_TARGET -ifeq ($(docker),) -DOCKER := $(shell which docker) +export PROJECT_NAME + +ifeq ($(user),root) +HOST_USER := root +HOST_UID := $(strip $(if $(uid),$(uid),0)) else -DOCKER := $(docker) +#allow override by adding user= and/ or uid= (lowercase!). +#uid= defaults to 0 if user= set (i.e. root). +#USER retrieved from env, UID from shell. +HOST_USER := $(strip $(if $(USER),$(USER),nodummy)) +HOST_UID := $(strip $(if $(shell id -u),$(shell id -u),4000)) endif -export DOCKER -ifeq ($(compose),) -DOCKER_COMPOSE := $(shell which docker-compose) +ifneq ($(uid),) +HOST_UID := $(uid) +endif + +ifeq ($(ssh-pkey),) +SSH_PRIVATE_KEY := $(HOME)/.ssh/id_rsa else -DOCKER_COMPOSE := $(compose) +SSH_PRIVATE_KEY := $(ssh-pkey) endif -export DOCKER_COMPOSE +export SSH_PRIVATE_KEY + ifeq ($(alpine),) -ALPINE_VERSION := 3.11.6 +ALPINE_VERSION := 3.15 else -ALPINE_VERSION := $(alpine) +ALPINE_VERSION := $(alpine) endif export ALPINE_VERSION -ifeq ($(project),) -PROJECT_NAME := $(notdir $(PWD)) -else -PROJECT_NAME := $(project) -endif -export PROJECT_NAME -GIT_USER_NAME := $(shell git config user.name) -export GIT_USER_NAME -GIT_USER_EMAIL := $(shell git config user.email) -export GIT_USER_EMAIL -GIT_SERVER := https://github.com -export GIT_SERVER -GIT_REPO_NAME := $(PROJECT_NAME) -export GIT_REPO_NAME -ifeq ($(profile),) -#USAGE EXAMPLE: make init profile=jlopp -GIT_PROFILE := bitcoincore-dev + +ifeq ($(dind),) +DIND_VERSION := 20.10.16 else -GIT_PROFILE := $(profile) +DIND_VERSION := $(dind) endif -export GIT_PROFILE -#GIT_BRANCH := $(shell git rev-parse --abbrev-ref HEAD) -GIT_BRANCH := $(shell git rev-parse --short HEAD~0) -export GIT_BRANCH -GIT_HASH := $(shell git rev-parse --short HEAD~0) -export GIT_HASH -GIT_PREVIOUS_HASH := $(shell git rev-parse --short master@{1}) -export GIT_PREVIOUS_HASH -GIT_REPO_ORIGIN := $(shell git remote get-url origin) -export GIT_REPO_ORIGIN -GIT_REPO_PATH := $(HOME)/$(GIT_REPO_NAME) -export GIT_REPO_PATH -DOCKERFILE := $(PROJECT_NAME).dockerfile -export DOCKERFILE -DOCKERFILE_PATH := $(HOME)/$(PROJECT_NAME)/$(DOCKERFILE) -export DOCKERFILE_PATH -BITCOIN_CONF := $(HOME)/$(PROJECT_NAME)/conf/bitcoin.conf -export BITCOIN_CONF -ifeq ($(network),) -NETWORK := signet +export DIND_VERSION + +ifeq ($(debian),) +DEBIAN_VERSION := bookworm else -NETWORK := $(network) +DEBIAN_VERSION := $(debian) endif -export NETWORK -ifeq ($(datadir),) -DATADIR := $(HOME)/.statoshi +export DEBIAN_VERSION + +ifeq ($(ubuntu),) +UBUNTU_VERSION := jammy else -DATADIR := $(datadir) +UBUNTU_VERSION := $(ubuntu) endif -export DATADIR +export UBUNTU_VERSION + ifeq ($(nocache),true) -NOCACHE := --no-cache +NO_CACHE := --no-cache else -NOCACHE := +NO_CACHE := endif -export NOCACHE +export NO_CACHE + ifeq ($(verbose),true) -VERBOSE := --verbose +VERBOSE := --verbose else -VERBOSE := +VERBOSE := endif export VERBOSE -ifeq ($(port),) -PUBLIC_PORT := 80 + +ifneq ($(passwd),) +PASSWORD := $(passwd) else -PUBLIC_PORT := $(port) +PASSWORD := changeme endif -export PUBLIC_PORT -ifeq ($(nodeport),) -NODE_PORT := 8333 +export PASSWORD + +ifneq ($(cmd),) +CMD_ARGUMENTS := $(cmd) else -NODE_PORT := $(nodeport) +CMD_ARGUMENTS := endif -export NODE_PORT -ifneq ($(passwd),) -PASSWORD := $(passwd) +export CMD_ARGUMENTS + +ifeq ($(private),true) +PRIVATE := true else -PASSWORD := changeme +PRIVATE := false +endif +export PRIVATE + +DOCKER:=$(shell which docker) +export DOCKER +DOCKER_COMPOSE:=$(shell which docker-compose) +export DOCKER_COMPOSE + +#GIT CONFIG +GIT_USER_NAME := $(shell git config user.name) +export GIT_USER_NAME +GIT_USER_EMAIL := $(shell git config user.email) +export GIT_USER_EMAIL +GIT_SERVER := https://github.com +export GIT_SERVER +# NOTE: We use the dotted name for some commands +# ie. ghp-import -c $(GIT_REPO_NAME) in make push-docs +GIT_REPO_NAME := $(subst -,.,$(PROJECT_NAME)) +export GIT_REPO_NAME + +#Usage +#make push profile=timechain-academy +#note on GH_TOKEN.txt file below +ifeq ($(profile),) +GIT_PROFILE :=$(GIT_USER_NAME) +ifeq ($(GIT_REPO_ORIGIN),git@github.com:timechain-academy/timechain.academy.git) +GIT_PROFILE :=timechain-academy +endif +ifeq ($(GIT_REPO_ORIGIN),https://github.com/$(GITHUB_USER_NAME)/timechain.academy.git) +GIT_PROFILE :=$(GITHUB_USER_NAME) endif -export PASSWORD -ifeq ($(cmd),) -CMD_ARGUMENTS := else -CMD_ARGUMENTS := $(cmd) +GIT_PROFILE :=$(profile) endif -export CMD_ARGUMENTS -PACKAGE_PREFIX := ghcr.io -export PACKAGE_PREFIX +export GIT_PROFILE + +GIT_BRANCH := $(shell git rev-parse --abbrev-ref HEAD) +export GIT_BRANCH +GIT_HASH := $(shell git rev-parse --short HEAD) +export GIT_HASH +GIT_PREVIOUS_HASH := $(shell git rev-parse --short HEAD^1) +export GIT_PREVIOUS_HASH +GIT_REPO_ORIGIN := $(shell git remote get-url origin) +export GIT_REPO_ORIGIN +GIT_REPO_PATH := $(HOME)/$(GIT_REPO_NAME) +export GIT_REPO_PATH + +PORT:=8000 +export PORT +export + +#REF: https://linuxize.com/post/bash-printf-command/ +#Width directive +#Here is an example: +# +#printf "%20s %d\n" Mark 305 +#Copy +#%20s means set the field at least 20 characters long. Blanks are added before the text because, by default, the output is right-justified. To align the text to left, use the - flag (%-20s). +# +# Mark 305 +# +#\\ - Displays a backslash character. +#\b - Displays a backspace character. +#\n - Displays a new line. +#\r - Displays a carriage return. +#\t - Displays a horizontal tab. +#\v - Displays a vertical tab. + + +.PHONY: - help init build serve push signin git-add +-: + #NOTE: 2 hashes are detected as 1st column output with color + @awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?##/ {printf "\033[36m%-15s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST) + +help:## verbose help +# help:print help +# test +# test +# test +# test +# test:test +# test:test +# test:test +# test:test +# test: test +# test: test +# test: test +# test: test +## help:print help +## test +## test +## test +## test +## test:test +## test:test +## test:test +## test:test +## test: test +## test: test +## test: test +## test: test +### help:print help +### test +### test +### test +### test +### test:test +### test:test +### test:test +### test:test +### test: test +### test: test +### test: test +### test: test + @sed -n 's/^# //p' ${MAKEFILE_LIST} | column -t -s ':' | sed -e 's/^/# /' + @sed -n 's/^## //p' ${MAKEFILE_LIST} | column -t -s ':' | sed -e 's/^/## /' + @sed -n 's/^### //p' ${MAKEFILE_LIST} | column -t -s ':' | sed -e 's/^/### /' -.PHONY: help -help: - @echo '' - @echo ' [USAGE]: make [BUILD] run [EXTRA_ARGUMENTS] ' - @echo '' - @echo ' make init' - @echo '' - @echo ' bitcoin commands:' - @echo '' - @echo ' make local-autogen' - @echo ' make local-configure' - @echo '' - @echo ' docker commands:' - @echo '' - @echo ' make build-docker' - @echo '' - @echo ' make init user=root uid=0 nocache=false verbose=true' - @echo '' - @echo ' [DEV ENVIRONMENT]: ' - @echo '' - @echo ' make build user=root' - @echo ' make run user=root' - @echo ' make shell user=$(HOST_USER)' - @echo '' - @echo ' [EXTRA_ARGUMENTS]: set build variables ' - @echo '' - @echo ' nocache=true' - @echo ' add --no-cache to docker command and apk add $(NOCACHE)' - @echo '' - @echo ' nodeport=integer' - @echo ' set NODE_PORT default 8333' - @echo '' - @echo ' TODO' - @echo '' - @echo ' [DOCKER COMMANDS]: push a command to the container ' - @echo '' - @echo ' cmd=command ' - @echo ' cmd="command" ' - @echo ' send CMD_ARGUMENTS to the [TARGET]' - @echo '' - @echo ' [EXAMPLE]:' - @echo '' - @echo ' make all run user=root uid=0 no-cache=true verbose=true' - @echo ' make report build run user=root uid=0 no-cache=true verbose=true cmd="top"' - @echo '' .PHONY: report -report: +report:## report @echo '' @echo ' [ARGUMENTS] ' @echo ' args:' - @echo ' - HOME=${HOME}' - @echo ' - PWD=${PWD}' - @echo ' - UMBREL=${UMBREL}' @echo ' - THIS_FILE=${THIS_FILE}' @echo ' - TIME=${TIME}' - @echo ' - PACKAGE_PREFIX=${PACKAGE_PREFIX}' - @echo ' - ARCH=${ARCH}' - @echo ' - HOST_USER=${HOST_USER}' - @echo ' - HOST_UID=${HOST_UID}' - @echo ' - PUBLIC_PORT=${PUBLIC_PORT}' - @echo ' - NODE_PORT=${NODE_PORT}' - @echo ' - SERVICE_TARGET=${SERVICE_TARGET}' - @echo ' - ALPINE_VERSION=${ALPINE_VERSION}' @echo ' - PROJECT_NAME=${PROJECT_NAME}' - @echo ' - DOCKER_BUILD_TYPE=${DOCKER_BUILD_TYPE}' - @echo ' - DOCKER_COMPOSE=${DOCKER_COMPOSE}' - @echo ' - DOCKERFILE=${DOCKERFILE}' - @echo ' - DOCKERFILE_BODY=${DOCKERFILE_BODY}' + @echo ' - HOME=${HOME}' + @echo ' - PWD=${PWD}' + @echo ' - PYTHON=${PYTHON}' + @echo ' - PYTHON3=${PYTHON3}' + @echo ' - PYTHON_VERSION=${PYTHON_VERSION}' + @echo ' - PYTHON_VERSION_MAJOR=${PYTHON_VERSION_MAJOR}' + @echo ' - PYTHON_VERSION_MINOR=${PYTHON_VERSION_MINOR}' + @echo ' - PIP=${PIP}' + @echo ' - PIP3=${PIP3}' + @echo ' - ARCH=${ARCH}' + @echo ' - TRIPLET=${TRIPLET}' + @echo ' - PORT=${PORT}' @echo ' - GIT_USER_NAME=${GIT_USER_NAME}' @echo ' - GIT_USER_EMAIL=${GIT_USER_EMAIL}' @echo ' - GIT_SERVER=${GIT_SERVER}' @@ -207,202 +318,205 @@ report: @echo ' - GIT_REPO_ORIGIN=${GIT_REPO_ORIGIN}' @echo ' - GIT_REPO_NAME=${GIT_REPO_NAME}' @echo ' - GIT_REPO_PATH=${GIT_REPO_PATH}' - @echo ' - DOCKERFILE=${DOCKERFILE}' - @echo ' - DOCKERFILE_PATH=${DOCKERFILE_PATH}' - @echo ' - BITCOIN_CONF=${BITCOIN_CONF}' - @echo ' - NETWORK=${NETWORK}' - @echo ' - DATADIR=${DATADIR}' - @echo ' - NOCACHE=${NOCACHE}' - @echo ' - VERBOSE=${VERBOSE}' - @echo ' - NODE_PORT=${NODE_PORT}' - @echo ' - PASSWORD=${PASSWORD}' - @echo ' - CMD_ARGUMENTS=${CMD_ARGUMENTS}' - -####################### - -ORIGIN_DIR:=$(PWD) -MACOS_TARGET_DIR:=/var/root/$(PROJECT_NAME) -LINUX_TARGET_DIR:=/root/$(PROJECT_NAME) -export ORIGIN_DIR -export TARGET_DIR - -.PHONY: super -super: -ifneq ($(shell id -u),0) - @echo switch to superuser - @echo cd $(TARGET_DIR) - #sudo ln -s $(PWD) $(TARGET_DIR) -#.ONESHELL: - sudo -s -endif -####################### -####################### -# Backup $HOME/.bitcoin -######################## -#backup: -# @echo '' -# bash -c 'mkdir -p $(HOME)/.bitcoin' -## bash -c 'conf/get_size.sh' -# bash -c 'tar czv --exclude=*.log --exclude=banlist.dat \ -# --exclude=fee_exstimates.dat --exclude=mempool.dat \ -# --exclude=peers.dat --exclude=.cookie --exclude=database \ -# --exclude=.lock --exclude=.walletlock --exclude=.DS_Store\ -# -f $(HOME)/.bitcoin-$(TIME).tar.gz $(HOME)/.bitcoin' -# bash -c 'openssl md5 $(HOME)/.bitcoin-$(TIME).tar.gz > $(HOME)/bitcoin-$(TIME).tar.gz.md5' -# bash -c 'openssl md5 -c $(HOME)/bitcoin-$(TIME).tar.gz.md5' -# -# -# @echo '' -####################### -# Some initial setup -######################## -####################### - -.PHONY: host -host: - @echo 'host' - bash -c './host' - -####################### -.PHONY: init + +.PHONY: init initialize docs +initialize:## initialize + ./scripts/initialize + test ./sources/playground/docker/scripts/initialize && ./sources/playground/docker/scripts/initialize || echo "Try: `make resources`" +init: initialize## init + python3 -m pip install -r sources/requirements.txt + +docs:## docs + $(DOCKER_COMPOSE) $(VERBOSE) -p $(PROJECT_NAME)_$(HOST_UID) build $(NOCACHE) docs + # $(DOCKER_COMPOSE) $(VERBOSE) run --rm --publish 18000:18000 docs + #$(DOCKER_COMPOSE) $(VERBOSE) run -d --rm docs + $(DOCKER_COMPOSE) $(VERBOSE) up -d + + +run: docs shell + $(NOHUP) $(DOCKER_COMPOSE) $(VERBOSE) up & + + + +.PHONY: clean-resources clean sources resources +clean-sources: clean sources +clean:## clean + rm -rf sources/playground/docker + rm -rf sources/git + rm -rf sources/ide + rm -rf sources/books/bitcoinbook + rm -rf sources/books/lnbook + rm -rf sources/books/python + rm -rf sources/qt/webengine + rm -f *.log + .SILENT: -init: - git config --global core.editor vim - docker pull docker.io/graphiteapp/graphite-statsd:latest - docker pull ghcr.io/bitcoincore-dev/statoshi/$(ARCH)/root:latest -ifneq ($(shell id -u),0) - sudo bash -c 'mkdir -p /usr/local/include/' - sudo bash -c 'install -v $(PWD)/src/statsd_client.h /usr/local/include/statsd_client.h' - sudo bash -c 'install -v $(PWD)/src/statsd_client.cpp /usr/local/include/statsd_client.cpp' +sources: resources## sources +resources: + ( \ + rm -f resources.log; \ + tail resources.log & \ + echo $(TIME) > resources.log; \ + $(MAKE) playground; \ + $(MAKE) qt-webengine; \ + $(MAKE) books; \ + ); + +playground:## clone-playground + git clone --progress --verbose --depth 1 -b master https://github.com/PLEBNET-PLAYGROUND/plebnet-playground-docker.git \ + sources/playground/docker \ + >> resources.log 2>&1 \ + || >> resources.log 2>&1 +qt-webengine:## qt webengine + git clone --progress --verbose --depth 1 -b v5.15.5-lts git://code.qt.io/qt/qtwebengine.git \ + sources/qt/webengine \ + >> resources.log 2>&1 \ + || >> resources.log 2>&1 + git clone --progress --verbose --depth 1 -b v5.15.2 git://code.qt.io/qt/qtwebengine-chromium.git \ + sources/qt/webengine/src/3rdparty/qtwebengine-chromium \ + >> resources.log 2>&1 \ + || >> resources.log 2>&1 + +clean-books:## clean + rm -rf sources/books/bitcoinbook + rm -rf sources/books/lnbook + rm -rf sources/books/python + rm -rf sources/books/*.html + # $(MAKE) books +books: mastering-bitcoin mastering-lightning python + mkdir -p sources/books + apt install pandoc || brew install pandoc + #bash -c "if hash pandoc 2>/dev/null; then echo; fi || brew or apt install pandoc" + #bash -c 'pandoc -s sources/books/README.md -o sources/books/index.html --metadata title="" ' + apt install asciidoctor || brew install asciidoctor +ifeq ($(PRIVATE),true) + pushd sources/books/bitcoinbook > /dev/null; for string in *.asciidoc; do echo "$$string"; done; popd || echo "." + pushd sources/books/bitcoinbook > /dev/null; for string in *.md; do sed 's/asciidoc/html/g' $$string | tee $$string; done; popd || echo "....." + pushd sources/books/bitcoinbook > /dev/null; for string in *.asciidoc; do asciidoctor $$string; done; popd || echo "..." + pushd sources/books/lnbook > /dev/null; for string in *.asciidoc; do echo "$$string"; done; popd || echo "...." + pushd sources/books/lnbook > /dev/null; for string in *.md; do sed 's/asciidoc/html/g' $$string | tee $$string; done; popd || echo "....." + pushd sources/books/lnbook > /dev/null; for string in *.asciidoc; do asciidoctor $$string; done; popd || echo "......" endif - rm -f Makefile -####################### -.PHONY: local-autogen -local-autogen: - ./autogen.sh -.PHONY: local-configure -local-configure: - ./configure --disable-wallet --disable-tests --disable-hardening --disable-man --enable-util-cli --enable-util-tx --with-gui=no --disable-bench -.PHONY: signin -signin: - bash -c 'cat ~/GH_TOKEN.txt | docker login ghcr.io -u RandyMcMillan --password-stdin' - docker tag $(PROJECT_NAME):$(HOST_USER) $(PACKAGE_PREFIX)/$(GIT_PROFILE)/$(PROJECT_NAME)/$(ARCH)/$(HOST_USER) - -.PHONY: build build-docker -build: build-docker -build-docker: - @echo 'build' - #$(DOCKER_COMPOSE) $(VERBOSE) build --pull $(NOCACHE) statoshi - $(DOCKER_COMPOSE) $(VERBOSE) build $(NOCACHE) statoshi - @echo '' -####################### -.PHONY: run -run: init - @echo 'run' -ifeq ($(CMD_ARGUMENTS),) - @echo '' - $(DOCKER_COMPOSE) $(VERBOSE) -p $(PROJECT_NAME)_$(HOST_UID) run -d statoshi sh - #$(DOCKER_COMPOSE) $(VERBOSE) -p $(PROJECT_NAME)_$(HOST_UID) run -d --publish 8125:8125 --publish 8126:8126 --publish 8333:8333 --publish 8332:8332 statoshi sh - @echo '' + +mastering-bitcoin:## mastering bitcoin +ifeq ($(PRIVATE),true) + git clone --progress --verbose --depth 1 -b 1653630097/6f13274/77b91b1 https://github.com/randymcmillan/bitcoinbook.git \ + sources/books/bitcoinbook \ + >> resources.log 2>&1 \ + || >> resources.log 2>&1 else - @echo '' - $(DOCKER_COMPOSE) $(VERBOSE) -p $(PROJECT_NAME)_$(HOST_UID) run -d statoshi sh -c "$(CMD_ARGUMENTS)" - #$(DOCKER_COMPOSE) $(VERBOSE) -p $(PROJECT_NAME)_$(HOST_UID) run -d --publish 8125:8125 --publish 8126:8126 --publish 8333:8333 --publish 8332:8332 statoshi sh -c "$(CMD_ARGUMENTS)" - @echo '' + rm -rf sources/books/bitcoinbook + rm -rf docs/books/bitcoinbook endif -####################### -.PHONY: torproxy -torproxy: - @echo '' - #REF: https://hub.docker.com/r/dperson/torproxy - bash -c 'docker run -it -p 8118:8118 -p 9050:9050 -p 9051:9051 -d dperson/torproxy' - @echo '' -ifneq ($(shell id -u),0) - bash -c 'sudo make torproxy user=root &' +mastering-lightning:## mastering lightning +ifeq ($(PRIVATE),true) + git clone --progress --verbose --depth 1 https://github.com/lnbook/lnbook.git \ + sources/books/lnbook \ + >> resources.log 2>&1 \ + || >> resources.log 2>&1 +else + rm -rf sources/books/lnbook + rm -rf docs/books/lnbook endif +python:## python +ifeq ($(PRIVATE),true) + git clone --progress --verbose --depth 1 https://github.com/kyclark/tiny_python_projects.git \ + sources/books/python \ + >> resources.log 2>&1 \ + || >> resources.log 2>&1 +else + rm -rf sources/books/python + rm -rf docs/books/python +endif + +.PHONY: build serve build-readme build-shell shell shell-test +build-readme:## build-readme + cat sources/HEADER.md > sources/README.md + #echo '```' >> README.md + make help > sources/COMMANDS.md + #echo '```' >> README.md + cat sources/FOOTER.md >> sources/README.md + # bash -c "if hash pandoc 2>/dev/null; then echo; fi || brew or apt install pandoc" + # bash -c 'pandoc -s README.md -o index.html --metadata title="" ' +build-docs: build-readme## build mkdocs + $(MAKE) resources + mkdir -p docs + apt install pandoc || brew install pandoc + apt install asciidoctor || brew install asciidoctor +ifeq ($(PRIVATE),true) + pushd sources/books/bitcoinbook > /dev/null; for string in *.asciidoc; do echo "$$string"; done; popd || echo "." + pushd sources/books/bitcoinbook > /dev/null; for string in *.md; do sed 's/asciidoc/html/g' $$string | tee $$string; done; popd || echo "....." + pushd sources/books/bitcoinbook > /dev/null; for string in *.asciidoc; do asciidoctor --doctype=book $$string; done; popd || echo "..." + pushd sources/books/lnbook > /dev/null; for string in *.asciidoc; do echo "$$string"; done; popd || echo "...." + pushd sources/books/lnbook > /dev/null; for string in *.md; do sed 's/asciidoc/html/g' $$string | tee $$string; done; popd || echo "....." + pushd sources/books/lnbook > /dev/null; for string in *.asciidoc; do asciidoctor --doctype book $$string; done; popd || echo "......" +endif + mkdocs $(VERBOSE) build + +build-playground:## build-playground + pushd sources/playground/docker && make initialize init build && popd + +run-playground:## run-playground + pushd sources/playground/docker && make install && popd + +run-playground-cluster:## run-playground-cluster + pushd sources/playground/docker && make install-cluster && popd + +serve: build## serve mkdocs + $(NOHUP) mkdocs serve & open http://127.0.0.1:$(PORT) || open http://127.0.0.1:$(PORT) + #$(PYTHON3) -m http.server $(PORT) --bind 127.0.0.1 -d $(PWD)/docs > /dev/null 2>&1 || open http://127.0.0.1:$(PORT) + +build-shell:## build the ubuntu docker image + docker-compose build $(NOCACHE) $(VERBOSE) ${SERVICE_TARGET} & + +.PHONY: shell +shell: build-shell## run the ubuntu docker environment ifeq ($(CMD_ARGUMENTS),) - $(DOCKER_COMPOSE) $(VERBOSE) -f docker-compose.yml -p $(PROJECT_NAME)_$(HOST_UID) run --publish 8118:8118 --publish 9050:9050 --publish 9051:9051 --rm torproxy + $(DOCKER_COMPOSE) $(VERBOSE) -p $(PROJECT_NAME)_$(HOST_UID) run -it --rm ${SERVICE_TARGET} bash else - $(DOCKER_COMPOSE) $(VERBOSE) -f docker-compose.yml -p $(PROJECT_NAME)_$(HOST_UID) run --publish 8118:8118 --publish 9050:9050 --publish 9051:9051 --rm torproxy sh -c "$(CMD_ARGUMENTS)" + $(DOCKER_COMPOSE) $(VERBOSE) -p $(PROJECT_NAME)_$(HOST_UID) run -it --rm $(SERVICE_TARGET) bash -c "$(CMD_ARGUMENTS)" endif - @echo '' -####################### -.PHONY: clean -clean: - # remove created images - @$(DOCKER_COMPOSE) -p $(PROJECT_NAME)_$(HOST_UID) down --remove-orphans --rmi all 2>/dev/null \ - && echo 'Image(s) for "$(PROJECT_NAME):$(HOST_USER)" removed.' \ - || echo 'Image(s) for "$(PROJECT_NAME):$(HOST_USER)" already removed.' - @rm -f Makefile -####################### -.PHONY: prune -prune: - @echo 'prune' - $(DOCKER_COMPOSE) -p $(PROJECT_NAME)_$(HOST_UID) down - docker system prune -f -####################### -.PHONY: prune-network -prune-network: - @echo 'prune-network' - $(DOCKER_COMPOSE) -p $(PROJECT_NAME)_$(HOST_UID) down - docker network prune -f -####################### -.PHONY: docs -statoshi-docs: -#$ make report no-cache=true verbose=true cmd='make doc' user=root doc -#SHELL := /bin/bash - @echo 'docs' - #bash -c "if pgrep MacDown; then pkill MacDown; fi" - bash -c "touch $(PWD)/docker/README.md" - curl -o $(PWD)/docker/README.md https://raw.githubusercontent.com/jlopp/statoshi/master/README.md - bash -c "cat $(PWD)/docker/README.md" - bash -c "cat $(PWD)/docker/README.md > README.md" - bash -c "echo ' ' >> README.md" - #bash -c "echo '' >> README.md" - bash -c "echo '----' >> README.md" - bash -c "cat $(PWD)/docker/DOCKER.md >> README.md" - #bash -c "echo '## [$(PROJECT_NAME)]($(GIT_SERVER)/$(GIT_PROFILE)/$(PROJECT_NAME)) ' >> README.md" - bash -c "echo '##### $ make' >> README.md" - bash -c "make help >> README.md" - #bash -c "if hash open 2>/dev/null; then open README.md; fi || echo failed to open README.md" -.PHONY: push + +shell-test:## shell-test + docker-compose -p $(PROJECT_NAME)_$(HOST_UID) run --rm ${SERVICE_TARGET} sh -c "curl -fsSL https://raw.githubusercontent.com/timechain-academy/timechain.academy/master/scripts/shell-test" + +#shell-network-test:## shell-network-test +# docker-compose -p $(PROJECT_NAME)_$(HOST_UID) run --rm ${SERVICE_TARGET} bash -c "curl -fsSL https://raw.githubusercontent.com/timechain-academy/timechain.academy/master/scripts/shell-network-test" + +push-docs: ## ghp-import to deploy docs folder + # NOTES: The docs folder becomes the root on the gh-pages branch + # NOTES: In the github.com pages setting use branch: gh-pages / (root) + ghp-import -n \ + -m "$(TIME):Deployed by $(GIT_USER_NAME) commit: $(GIT_HASH)" \ + -c $(GIT_REPO_NAME) \ + -p \ + -r origin \ + -b gh-pages \ + docs + + push: - @echo 'push' - #bash -c "git reset --soft HEAD~1 || echo failed to add docs..." - #bash -c "git add README.md docker/README.md docker/DOCKER.md *.md docker/*.md || echo failed to add docs..." - #bash -c "git commit --amend --no-edit --allow-empty -m '$(GIT_HASH)' || echo failed to commit --amend --no-edit" - #bash -c "git commit --no-edit --allow-empty -m '$(GIT_PREVIOUS_HASH)' || echo failed to commit --amend --no-edit" - bash -c "git push -f --all git@github.com:$(GIT_PROFILE)/$(PROJECT_NAME).git || echo failed to push docs" -.PHONY: push-docs -push-docs: docs push - @echo 'push-docs' -####################### -package-statoshi: init signin - #@echo "legit . -m "$(HOST_USER):$(TIME)" -p 0000000 && make user=root package && GPF" - bash -c 'cat ~/GH_TOKEN.txt | docker login ghcr.io -u RandyMcMillan --password-stdin' - bash -c 'docker tag $(PROJECT_NAME):$(HOST_USER) ghcr.io/$(GIT_PROFILE)/$(PROJECT_NAME)/$(ARCH)/$(HOST_USER):$(TIME)' - bash -c 'docker push ghcr.io/$(GIT_PROFILE)/$(PROJECT_NAME)/$(ARCH)/$(HOST_USER):$(TIME)' - bash -c 'docker tag $(PROJECT_NAME):$(HOST_USER) ghcr.io/$(GIT_PROFILE)/$(PROJECT_NAME)/$(ARCH)/$(HOST_USER)' - bash -c 'docker push ghcr.io/$(GIT_PROFILE)/$(PROJECT_NAME)/$(ARCH)/$(HOST_USER)' -# -# touch TIME && echo $(TIME) > TIME && git add -f TIME -# #legit . -m "make package-header at $(TIME)" -p 00000 -# git commit --amend --no-edit --allow-empty -# bash -c 'docker tag $(PROJECT_NAME):$(HOST_USER) $(PACKAGE_PREFIX)/$(GIT_PROFILE)/$(PROJECT_NAME)/$(ARCH)/$(HOST_USER):$(TIME)' -# bash -c 'docker push $(PACKAGE_PREFIX)/$(GIT_PROFILE)/$(PROJECT_NAME)/$(ARCH)/$(HOST_USER):$(TIME)' -# bash -c 'docker tag $(PROJECT_NAME):$(HOST_USER) $(PACKAGE_PREFIX)/$(GIT_PROFILE)/$(PROJECT_NAME)/$(ARCH)/$(HOST_USER)' #defaults to latest -# bash -c 'docker push $(PACKAGE_PREFIX)/$(GIT_PROFILE)/$(PROJECT_NAME)/$(ARCH)/$(HOST_USER)' - -######################## -.PHONY: package-build-all -package-build-all: init signin package-statoshi - - make build-docker package-statoshi - -######################## -.PHONY: automate -automate: - ./.github/workflows/automate.sh + @echo push + $(MAKE) docs + git checkout -b $(TIME)/$(GIT_PREVIOUS_HASH)/$(GIT_HASH) + git push --set-upstream origin $(TIME)/$(GIT_PREVIOUS_HASH)/$(GIT_HASH) + #git add docs + #git commit --no-edit --allow-empty -m "$(TIME)" || echo failed to commit --amend --no-edit + git push -f origin $(TIME)/$(GIT_PREVIOUS_HASH)/$(GIT_HASH):$(TIME)/$(GIT_PREVIOUS_HASH)/$(GIT_HASH) + +push-all: push-to-master push-docs#push-to-main ## push-to-master push-docs +push-to-master:## push-to-master + git push -f $(GIT_REPO_ORIGIN) $(GIT_BRANCH):master || echo failed to push docs +push-to-main:## push-to-main + git push -f $(GIT_REPO_ORIGIN) $(GIT_BRANCH):main || echo failed to push docs + + +SIGNIN=randymcmillan +export SIGNIN + +signin: +#Place a file named GH_TOKEN.txt in your $HOME - create in https://github.com/settings/tokens (Personal access tokens) + bash -c 'cat ~/GH_TOKEN.txt | docker login ghcr.io -u $(GIT_PROFILE) --password-stdin' + #-include funcs.mk -include Makefile - diff --git a/docker-compose.yml b/docker-compose.yml old mode 100755 new mode 100644 index aa3c8c03d96f..af28e5d949fd --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,96 +1,34 @@ +--- version: '3.4' +networks: {} services: - statoshi: - # Makefile fills PROJECT_NAME to current directory name. - # add UID to allow multiple users run this in parallel + ubuntu: container_name: ${PROJECT_NAME}_${HOST_UID:-4000} - hostname: ${PROJECT_NAME} - ## These variables are passed into the container. - #environment: - # - TIME=${TIME} - # - PACKAGE_PREFIX=${PACKAGE_PREFIX} - # - ARCH=${ARCH} - # - HOST_USER=${HOST_USER} - # - HOST_UID=${HOST_UID} - # - ALPINE_VERSION=${ALPINE_VERSION} - # - PROJECT_NAME=${PROJECT_NAME} - # - GIT_SERVER=${GIT_SERVER} - # - GIT_PROFILE=${GIT_PROFILE} - # - GIT_REPO_NAME=${GIT_REPO_NAME} - # - BITCOIN_CONF=${BITCOIN_CONF} - # - NETWORK=${NETWORK} - # - DATADIR=${DATADIR} - # - NOCACHE=${NOCACHE} - # - VERBOSE=${VERBOSE} - # - PUBLIC_PORT=${PUBLIC_PORT} - # - NODE_PORT=${NODE_PORT} - # - PASSWORD=${PASSWORD} - # - CMD_ARGUMENTS=${CMD_ARGUMENTS} - ## Run with user priviliges by default. + hostname: ${PROJECT_NAME}_${HOST_UID:-4000} + environment: + - UID=${HOST_UID:-4000} user: ${HOST_USER:-nodummy} - image: ghcr.io/bitcoincore-dev/statoshi/${ARCH}/root:latest - restart: unless-stopped + image: ${PROJECT_NAME}:${HOST_USER:-nodummy} + privileged: true build: context: . - # This is the name of the last layer in stats.bitcoincore.dev - dockerfile: ${PROJECT_NAME}.dockerfile - # These variables are passed to Dockerfile. + target: base + dockerfile: docker/ubuntu.dockerfile args: - - TIME=${TIME} - - PACKAGE_PREFIX=${PACKAGE_PREFIX} - - ARCH=${ARCH} - - HOST_USER=${HOST_USER} - - HOST_UID=${HOST_UID} - - ALPINE_VERSION=${ALPINE_VERSION} - - PROJECT_NAME=${PROJECT_NAME} - - GIT_SERVER=${GIT_SERVER} - - GIT_PROFILE=${GIT_PROFILE} - - BITCOIN_CONF=${BITCOIN_CONF} - - NETWORK=${NETWORK} - - DATADIR=${DATADIR} - - NOCACHE=${NOCACHE} - - VERBOSE=${VERBOSE} - - PUBLIC_PORT=${PUBLIC_PORT} - - NODE_PORT=${NODE_PORT} + - HOST_UID=${HOST_UID:-4000} + - HOST_USER=${HOST_USER:-nodummy} + - SSH_PRIVATE_KEY=${SSH_PRIVATE_KEY} - PASSWORD=${PASSWORD} - - CMD_ARGUMENTS=${CMD_ARGUMENTS} - # Run container as a service. Replace with something useful. - #command: ["tail", "-f", "/dev/null"] - #command: ["/usr/local/bin/entrypoint"] - # Expose current project folder to container. + - UBUNTU_VERSION=${UBUNTU_VERSION} + command: ["ssh-agent ssh-add"] volumes: - - ${HOME:-.}:/home/${HOST_USER}:consistent - - ${HOME:-.}/.statoshi:/home/${HOST_USER}/.bitcoin:consistent - - ${PWD:-.}:/home/${HOST_USER}/${PROJECT_NAME}:consistent - - ${PWD:-.}:/tmp:consistent - ports: - #hostPORT:imagePORT - - "8332:8332" - #- "${NODE_PORT}:${NODE_PORT}" - - "18332:18332" - - "38333:38333" - - torproxy: - links: - - statoshi - # Makefile fills PROJECT_NAME to current directory name. - # add UID to allow multiple users run this in parallel - container_name: ${PROJECT_NAME}_${HOST_UID:-4000} - hostname: ${PROJECT_NAME} - # These variables are passed into the container. - user: ${HOST_USER:-nodummy} - image: ${PROJECT_NAME}_torproxy:${HOST_USER:-nodummy} - restart: unless-stopped - command: ["/sbin/tini", "--", "/usr/bin/torproxy.sh"] - # Expose current project folder to container. - volumes: - - /etc/tor - - /var/lib/tor - ports: - #hostPORT:imagePORT - #we expose tor proxy ports for 'make torproxy' - - "8118:8118" - - "9050:9050" - - "9051:9051" - + - type: bind + source: ${HOME:-.} + target: /home/${HOST_USER} + - type: bind + source: ${PWD:-.} + target: /home/${HOST_USER}/${PROJECT_NAME} + - type: bind + source: ~/.ssh + target: /home/${HOST_USER}/.ssh diff --git a/docker/ubuntu.dockerfile b/docker/ubuntu.dockerfile new file mode 100644 index 000000000000..946a5df5a602 --- /dev/null +++ b/docker/ubuntu.dockerfile @@ -0,0 +1,121 @@ +ARG UBUNTU_VERSION=${UBUNTU_VERSION} +FROM ubuntu:${UBUNTU_VERSION} as base +RUN set -xe; \ +apt install -y apt +RUN apt-get -y upgrade +RUN apt-get -y update +ENV DEBIAN_FRONTEND noninteractive +RUN apt-get update && apt-get upgrade -y && apt-get install --no-install-recommends -y \ + debconf --reinstall \ + bsdmainutils socat \ + apt-utils sudo adduser bash-completion \ + openssh-client openssh-server \ + git make vim python3 python3-pip curl + +RUN DEBIAN_FRONTEND=noninteractive TZ=Etc/UTC apt-get -y install tzdata +RUN apt-get install -y \ +debconf --reinstall \ +locales apt-utils bsdmainutils \ +sudo adduser bash-completion \ +openssh-client openssh-server \ +autoconf automake pkg-config \ +libtool g++ \ +git make vim python3 python3-pip mkdocs +## NOTE: match CI +RUN apt-get install --no-install-recommends -y \ + automake \ + binutils \ + bsdmainutils \ + ca-certificates \ + cmake \ + curl \ + diffoscope \ + doxygen \ + # gcc-multilib \ + # g++-multilib \ + git \ + libbz2-dev \ + libcap-dev \ + libevent-dev libboost-dev \ + libtinfo5 \ + libtool \ + lbzip2 \ + libz-dev \ + make \ + nsis \ + patch \ + pkg-config \ + python3 \ + python3-setuptools \ + ripgrep \ + vim \ + xz-utils \ + build-essential libtool autotools-dev \ + automake pkg-config bsdmainutils python3 \ + libevent-dev libboost-dev \ + libsqlite3-dev libminiupnpc-dev libnatpmp-dev \ + libzmq3-dev systemtap-sdt-dev \ + libqt5gui5 libqt5core5a libqt5dbus5 qttools5-dev qttools5-dev-tools \ + qtwayland5 libqrencode-dev \ + g++-aarch64-linux-gnu \ + binutils-aarch64-linux-gnu \ + g++-arm-linux-gnueabihf \ + binutils-arm-linux-gnueabihf curl \ + binutils-riscv64-linux-gnu \ + g++-riscv64-linux-gnu \ + binutils-gold \ + bsdmainutils pkg-config python3 patch bison \ + g++-arm-linux-gnueabihf binutils-arm-linux-gnueabihf \ + g++-aarch64-linux-gnu \ + fzf #\ + # binutils-aarch64-linux-gnu + + + + + +RUN sed -i -e 's/# en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/' /etc/locale.gen && \ +locale-gen + +ENV LC_ALL en_US.UTF-8 +ENV LANG en_US.UTF-8 +ENV LANGUAGE en_US:en +ENV DEBIAN_FRONTEND noninteractive + +ARG PASSWORD=${PASSWORD} +ENV GIT_DISABLE_UNTRACKED_CACHE=true +ARG HOST_UID=${HOST_UID:-4000} +ARG HOST_USER=${HOST_USER:-nodummy} + +ENV SSH_DIR=/home/${HOST_USER}/.ssh +ENV SOCKET_DIR=/home/${HOST_USER}/.ssh-agent +ENV SSH_AUTH_SOCK=/home/${HOST_USER}${SOCKET_DIR}/socket +ENV SSH_AUTH_PROXY_SOCK=/home/${HOST_USER}${SOCKET_DIR}/proxy-socket + +VOLUME ${SOCKET_DIR} + +RUN chmod 640 /etc/shadow +RUN chmod 4511 /usr/bin/passwd +RUN mkdir -p /var/cache/debconf + +RUN if [ -r ~/.ssh/id_rsa ]; then y | ssh-keygen; fi + +RUN if [ ${HOST_UID} != 0 ]; then adduser --system --disabled-password --ingroup sudo --home /home/${HOST_USER} --uid ${HOST_UID} ${HOST_USER}; fi +RUN echo root:${PASSWORD} | chpasswd +RUN echo ${HOST_USER}:${PASSWORD} | chpasswd +RUN echo "Set disable_coredump false" >> /etc/sudo.conf + +ENTRYPOINT ["docker-entrypoint.sh"] + +USER ${HOST_USER} +COPY docker/bin /usr/local/bin +COPY docker/opt/healthcheck.sh /opt/healthcheck.sh + +WORKDIR /home/${HOST_USER}/statoshi +CMD [ "./autogen.sh" ] +# CMD [ " CONFIG_SITE=$PWD/depends/aarch64-linux-gnu/share/config.site","./configure ", " --disable-wallet", "--disable-tests ", "--disable-bench", "--disable-man", "--with-gui=no", "--enable-reduce-exports", "LDFLAGS=-static-libstdc++" ] +CMD [ "./configure ", " --disable-wallet", "--disable-tests ", "--disable-bench", "--disable-man", "--with-gui=no", "--enable-reduce-exports", "LDFLAGS=-static-libstdc++" ] +CMD [ "make", "check" ] +CMD [ "ssh-agent" ] +HEALTHCHECK --interval=5s --timeout=1s --retries=3 CMD ["/opt/healthcheck.sh"] + From 2cbcdbfbf360d14d6618627eeb4f1e13ec21a282 Mon Sep 17 00:00:00 2001 From: randymcmillan Date: Sat, 4 Jun 2022 14:27:47 -0400 Subject: [PATCH 11/39] docker: make shell working dirty --- docker/README.md | 0 docker/bin/docker-entrypoint.sh | 34 +++++ docker/bin/ssh-key | 117 ++++++++++++++ docker/bin/whatami | 260 ++++++++++++++++++++++++++++++++ docker/opt/healthcheck.sh | 16 ++ docker/ubuntu.dockerfile | 8 +- 6 files changed, 433 insertions(+), 2 deletions(-) create mode 100644 docker/README.md create mode 100755 docker/bin/docker-entrypoint.sh create mode 100755 docker/bin/ssh-key create mode 100755 docker/bin/whatami create mode 100755 docker/opt/healthcheck.sh diff --git a/docker/README.md b/docker/README.md new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/docker/bin/docker-entrypoint.sh b/docker/bin/docker-entrypoint.sh new file mode 100755 index 000000000000..c927a888ccd5 --- /dev/null +++ b/docker/bin/docker-entrypoint.sh @@ -0,0 +1,34 @@ +#!/usr/bin/env bash + +set -e # Abort if anything fails + +# Create the temporary key storage directory +mkdir -p ${SSH_DIR} + +# Service mode +if [[ "$1" == "ssh-agent" ]]; then + # Clean up previous socket files + rm -f ${SSH_AUTH_SOCK} ${SSH_AUTH_PROXY_SOCK} + + # Create proxy-socket for ssh-agent (to give anyone accees to the ssh-agent socket) + echo "Creating proxy socket..." + socat UNIX-LISTEN:${SSH_AUTH_PROXY_SOCK},perm=0666,fork UNIX-CONNECT:${SSH_AUTH_SOCK} & + + # Start ssh-agent + echo "Launching ssh-agent..." + exec /usr/bin/ssh-agent -a ${SSH_AUTH_SOCK} -d + +# Proxy mode +elif [[ "$1" == "ssh-proxy" ]]; then + # Clean up previous socket files + rm -f ${SSH_AUTH_SOCK} ${SSH_AUTH_PROXY_SOCK} + + # Create proxy-socket for TCP target + tcp_target_ip="$2" + tcp_target_port="$3" + exec socat UNIX-LISTEN:${SSH_AUTH_PROXY_SOCK},perm=0666,fork TCP:${tcp_target_ip}:${tcp_target_port} + +# Command mode +else + exec "$@" +fi diff --git a/docker/bin/ssh-key b/docker/bin/ssh-key new file mode 100755 index 000000000000..7c1a4279d41a --- /dev/null +++ b/docker/bin/ssh-key @@ -0,0 +1,117 @@ +#!/usr/bin/env bash + +DEBUG=${DEBUG:-0} +# Print a debug message if debug mode is on +# @param message +echo_debug () +{ + [[ "${DEBUG}" != 0 ]] && echo "$(date +"%F %H:%M:%S") | $@" +} + +# Helper function to check whether an key is already loaded in the ssh-agent +# This is useful for keys with a passphrase, which otherwise would require the user to re-enter it. +# @param $1 ssh key name +ssh_key_loaded () +{ + # Get fingerprints for keys already loaded in the agent + # This function may be called multiple times, so we should cache this value + if [[ "$existing_fingerprints" == "" ]]; then + existing_fingerprints=$(ssh-add -l) + export existing_fingerprints + fi + + new_fingerprint=$(ssh-keygen -lf ${SSH_DIR}/${1} | awk '{print $2}') + + [[ ${existing_fingerprints} == *${new_fingerprint}* ]] +} + +ssh_key_add () +{ + ssh_key_name="${1}" + ssh_key_path="${SSH_DIR}/${ssh_key_name}" + + # Make sure the key file was provided and exists + [[ "${ssh_key_name}" == "" ]] && echo 'Missing SSH key file name' >&2 && return 1 + [[ ! -f "${ssh_key_path}" ]] && echo "SSH key file does not exist in '${ssh_key_path}'" >&2 && return 1 + + # Fix permissions on keys before trying to add them to the agent + chmod 700 ${SSH_DIR} + chmod 600 ${SSH_DIR}/* >/dev/null 2>&1 || true + chmod 644 ${SSH_DIR}/*.pub >/dev/null 2>&1 || true + + # Check whether the key is already loaded in the agent and skip adding if so. + if ssh_key_loaded ${ssh_key_name}; then + [[ ${QUIET} != 1 ]] && echo "Key '${ssh_key_name}' already loaded in the agent. Skipping." + return 0 + fi + + # Calling ssh-add. This should handle all arguments cases. + _command="ssh-add ${ssh_key_path}" + echo_debug "Executing: ${_command}" + # We do a sed hack here to strip out the key path in the output from ssh-add, since it may confuse people. + ${_command} 2>&1 0>&1 | sed "s|${SSH_DIR}/||g" + ret=${PIPESTATUS[0]} + + # Remove the key immediately + rm -f ${ssh_key_path} + + # Return the exit code from ssh-add above + return ${ret} +} + +ssh_key_remove () +{ + ssh-add -D +} + +ssh_key_list () +{ + # We do a sed hack here to strip out the key path in the output from ssh-add, since it may confuse people. + ssh-add -l 2>&1 0>&1 | sed "s|${SSH_DIR}/||g" + # Return the exit code of th first command in the pipe list + return ${PIPESTATUS[0]} +} + +ssh_key_new () +{ + echo "$@" +} + +#-------------------------- RUNTIME STARTS HERE ---------------------------- + +# Parse parameters +args=$@ + +QUIET=0 +while [[ $# -gt 0 ]]; do + case "$1" in + --quiet) + QUIET=1 + args=${args/ --quiet} + ;; + esac + shift +done +set -- ${args} + +# Parse arguments +case "$1" in + add) + shift + ssh_key_add "$@" + ;; + rm) + shift + ssh_key_remove "$@" + ;; + ls) + shift + ssh_key_list "$@" + ;; + debug) + shift + eval "$@" + ;; + *) + echo "Usage: ssh-key add|rm|ls" +esac diff --git a/docker/bin/whatami b/docker/bin/whatami new file mode 100755 index 000000000000..cbbd401eacd3 --- /dev/null +++ b/docker/bin/whatami @@ -0,0 +1,260 @@ +#!/bin/sh +# +# Script tests the operating system for some interesting information. +# Idea and concept from a script by Wayne Thommpson, for Sun +# workstations. Attempts to modify the script for Linux unsuccessful +# and this is mostly completely rewritten. +# +# Written by: CMDRae, January 2002 +# +PATH=/bin:/usr/bin:/usr/local/bin:/usr/X11R6/bin:/sbin:/usr/sbin:/usr/local/sbin +# + +DMESG=dmesg + +if [ -f /var/log/dmesg ] ; then + DMESG="cat /var/log/dmesg" +elif [ -f /var/log/boot.msg ] ; then + DMESG="cat /var/log/boot.msg" +fi + + +############ This script information ######################## +echo "### QUERY ###" +echo " DATE: " `date` +echo " USER: " `whoami` + +########### HARDWARE ######################################## +echo "### HARDWARE ###" +echo "ARCHITECTURE TYPE: " `arch` +cat /proc/cpuinfo | tac | + awk ' + /^processor/{print " PROCESSOR: ",$3,"=",vend,mod,spd,"MHz"} + /^model name/{mod=gensub(/^[[:alpha:][:blank:]]*:/,"",1)} + /^vendor_id/{vend=gensub(/^[[:alpha:][:blank:]_]*:/,"",1)} + /^cpu MHz/{spd=gensub(/^[[:alpha:][:blank:]]*:/,"",1)} + ' | tac +HOSTID=`hostid 2>&-` && echo " HOST ID: "$HOSTID + +# +# MEMORY +# +cat /proc/meminfo | awk '/MemTotal:/{sub(/MemTotal: /,""); print " TOTAL MEMORY: ",$0}' +cat /proc/meminfo | awk '/MemFree:/{sub(/MemFree: /,""); print " FREE MEMORY: ",$0}' +cat /proc/meminfo | awk '/SwapTotal:/{sub(/SwapTotal: /,""); print " TOTAL SWAP: ",$0}' +cat /proc/meminfo | awk '/SwapFree:/{sub(/SwapFree: /,""); print " FREE SWAP: ",$0}' +swapon -s | awk 'NR>1{print " SWAP DEVICE: ",$2 "=" $1 ", " int($3/1024+0.5) "MiB"}' + +# +# DRIVES +# +for drive in `echo /dev/hd[a-z]|sed 's/\/dev\///g'`; do + [ "$DMESG" ] && + $DMESG | grep ^$drive | awk 'NR==1{print " IDE DEVICE: ",$0}NR==2{print " DEVICE GEOMETRY: ",$0}' +done + +SCSI=`$DMESG | awk '/^scsi[0-9]/{print $1}'` +for f in $SCSI; do + $DMESG | awk '/^'$f'/{print " SCSI DEVICE: ",$0}' +done + +# +# NETWORK CARD +# + +if [ "$DMESG" ]; then + $DMESG | awk '/^[[:blank:]]*arc[0-9]|^[[:blank:]]*eth[0-9]/{ \ + if ($0~/IRQ/){print " NETWORK CARD: ", $0}}' +fi + +################### NETWORK ################################## +## HOSTNAMES and INTERFACES +# + +ifaces=` ifconfig | cut -b-10 | awk '!/^[[:blank:]]*$|^lo/{print $1}' ` + +for iface in $ifaces +do + ip=` + ifconfig $iface 2>&- | + awk ' $1 == "inet" { gsub(/[[:alpha:]:]/,""); print $1; } ' + ` + + nm=` + ifconfig $iface 2>&- | + awk ' $1 == "inet" { gsub(/[[:alpha:]:]/,""); print $3; } ' + ` + hw=` + ifconfig $iface 2>&- | + awk '/HWaddr/{match($0,/HWaddr.*$/); + hwaddr=substr($0,RSTART,RLENGTH); + sub(/HWaddr /,"",hwaddr);print hwaddr}' + ` + + [ $ip ] && ( grep -w $ip /etc/hosts || echo "$ip [unnamed]" ) | + awk ' + { + printf ("%'$offset's %s = %s\n"\ + , " HOSTNAME: " \ + , "'"$iface"'" \ + , $2 \ + ); + } + + END { + printf ("%'$offset's %s = %s\n"\ + , " IP ADDRESS: " \ + , "'"$iface"'" \ + , "'"$ip"'" \ + ); + printf ("%'$offset's %s = %s\n"\ + , " NETWORK MASK: " \ + , "'"$iface"'" \ + , "'"$nm"'" \ + ); + printf ("%'$offset's %s = %s\n"\ + , " ETHERNET ADDRESS: " \ + , "'"$iface"'" \ + , "'"$hw"'" \ + ); + } + ' +done + + +### END of HOSTNAMES and INTERFACES + + +################# STORAGE #################### +# +# LOCAL DISKS +# +Drive=` mount | grep ^/dev | awk '{sub(/\/dev\//,"",$1);gsub(/[[:digit:]]/,"",$1); print $1}' | sort | uniq ` + + +# Partition=` mount | grep ^/dev | awk '{print $1}' ` +Partition=` mount | grep ^/dev | awk '{print $3}' ` + +for drive in $Drive; do + for partition in $Partition; do + df $partition | + awk '/'${drive/\//\\/}'/{print " PARTITION: ",$1,"mounted on",$6,"(" int($2/1024) "MiB, " $5 " full)"}' + done +done + +# +# REMOTE MOUNTS +# + + +mount -t nfs,smb | awk '{print " NETWORK MOUNT: ",$1,"mounted",$2,$3}' +if [ -e /etc/exports ]; then + ( + showmount -d 2>&- || cat /etc/exports | + awk '/^[[:blank:]]*[^#]/{print $1}{while(/\\$/){getline}}' + ) | awk 'NR>1{print " EXPORTING: ", $1}' +fi + +### END of DISKS + +smbclient -N -L $HOSTNAME < /dev/null 2> /dev/null | + awk ' + /^Domain/{ + wg=gensub(/^[^\[]*\[([^\]]*).*$/,"\\1",1); + print " WORKGROUP: ",wg + } + /^[[:blank:]]*$/{st=0} + st{ + sub(/^[[:blank:]]*/,""); + share=gensub(/[[:blank:]]+/,",","1"); + share=gensub(/[[:blank:]]+/,",","1",share); + print " SHARE: ", share + } + /^[[:blank:]]*Sharename/{st=1; getline} + ' + +############ DISPLAY ####################################### + +# only interested in the video graphics card right now. Probably want to +# print out all the pci device information, which obtained by lspci +lspci | grep -i "display\|vga"| sed 's/^[0-9a-f]\{2\}:[0-9a-f]\{2\}.[0-9]/ DISPLAY: /' + +############ OPERATING SYSTEM ############################### +echo "### SOFTWARE ###" +echo " SYSTEM KERNEL: " `uname -sr` +# +echo " UPTIME: " `uptime|awk '{ sub(/.*/,"",$2); sub(/.*/,"",$1); print}'` +# +[ -e /etc/slackware-version ] && +echo "BASE DISTRIBUTION: Slackware "`cat /etc/slackware-version` +[ -e /etc/redhat-release ] && +echo " DISTRIBUTION: " `cat /etc/redhat-release` +[ -e /etc/debian_version ] && +echo " DISTRIBUTION: " Debian `cat /etc/debian_version` +[ -e /etc/SuSE-release ] && +echo " DISTRIBUTION: " `head -n1 /etc/SuSE-release` + # 'Mandrake' +[ -e /etc/mandrake-release ] && +echo " DISTRIBUTION: " `head -n1 /etc/mandrake-release` + +DISTFILE=/etc/lsb-release +if [ -x "`which lsb_release 2> /dev/null`" ] ; then + lsb_release -a +elif [ -e $DISTFILE ] ; then + cat $DISTFILE | awk '/DISTRIB_ID/{printf "%20s%s\n"," ",$0}' + cat $DISTFILE | awk '/DISTRIB_RELEASE/{printf "%20s%s\n"," ",$0}' + cat $DISTFILE | awk '/DISTRIB_CODENAME/{printf "%20s%s\n"," ",$0}' +fi + +( gcc -dumpversion >/dev/null 2>/dev/null ) && +echo " GCC VERSION: " `gcc -dumpversion` + +MATLAB_EXEC=`which matlab 2> /dev/null` +[ -x "$MATLAB_EXEC" ] && +echo " MATLAB VERSION: " `matlab -help | grep Revision` + +PYTHON_EXEC=`which python` +[ -x "$PYTHON_EXEC" ] && +echo " PYTHON VERSION: " `python --version 2>&1 | sed 's/[Pp]ython//' ` + + + +# SunOS 5.x: +# DATE: Sun Jul 5 11:05:30 PDT 1992 +# USER: root +# HOSTNAME: le0 = anywhere +# IP ADDRESS: le0 = 129.150.30.23 +# MODEL: SUNW,Sun 4/75 +# FRAME BUFFER(S): cgthree +# SunOS RELEASE: 5.0.1 +# TYPE: homeless +# HOME FILESERVER: mirrors +# MEMORY: 32MB +# SWAP: 53.4MB total, 25.6MB used, 27.8MB available +# LOAD AVERAGE: 1.01, 0.58, 0.58 +# DNS DOMAINNAME: EBay.Sun.COM +# NIS DOMAINNAME: mlpirws.EBay.Sun.COM +# SOFTWARE SERVER(S): speedo1 +# DEFAULT PRINTER: pug +# ETHERNET ADDRESS: 8:0:20:e:47:6d +# HOSTID: 5540a99d +# DISK: c0t3d0 "SUN0207" (208MB unformatted) +# PARTITION: c0t3d0s0 mounted on / (11MB, 87% full) +# PARTITION: c0t3d0s6 mounted on /usr (127MB, 100% full) +# SWAP PARTITION: c0t3d0s1 (32MB) +# DNS DOMAINNAME: EBay.Sun.COM +# NIS DOMAINNAME: mlpirws.EBay.Sun.COM +# SOFTWARE SERVER(S): speedo1 +# DEFAULT PRINTER: pug +# ETHERNET ADDRESS: 8:0:20:e:47:6d +# HOSTID: 5540a99d +# DISK: c0t3d0 "SUN0207" (208MB unformatted) +# PARTITION: c0t3d0s0 mounted on / (11MB, 87% full) +# PARTITION: c0t3d0s6 mounted on /usr (127MB, 100% full) +# SWAP PARTITION: c0t3d0s1 (32MB) +# CDROM: c0t6d0 +# FLOPPY: fd0 (3.5-inch floppy) +# TAPE: rst4 - Archive QIC-150 tape drive (150MB) + +# vim: se nowrap tw=0 : + diff --git a/docker/opt/healthcheck.sh b/docker/opt/healthcheck.sh new file mode 100755 index 000000000000..4a7ae0ad7871 --- /dev/null +++ b/docker/opt/healthcheck.sh @@ -0,0 +1,16 @@ +#!/usr/bin/env bash +set -eo pipefail + +# Get the name of the process with pid=1 +docker_cmd=$(cat /proc/1/comm) + +# Health checks for ssh-agent mode +if [[ "${docker_cmd}" == "ssh-agent" ]]; then + netstat -nlp | grep -qE "LISTENING.*${SSH_AUTH_PROXY_SOCK}" + netstat -nlp | grep -qE "LISTENING.*${SSH_AUTH_SOCK}" +fi + +# Health checks for ssh-proxy mode +if [[ "${docker_cmd}" == "socat" ]]; then + netstat -nlp | grep -qE "LISTENING.*${SSH_AUTH_PROXY_SOCK}" +fi diff --git a/docker/ubuntu.dockerfile b/docker/ubuntu.dockerfile index 946a5df5a602..364c63df091a 100644 --- a/docker/ubuntu.dockerfile +++ b/docker/ubuntu.dockerfile @@ -112,10 +112,14 @@ COPY docker/bin /usr/local/bin COPY docker/opt/healthcheck.sh /opt/healthcheck.sh WORKDIR /home/${HOST_USER}/statoshi +CMD [ "apt-get instal pkg-config" ] CMD [ "./autogen.sh" ] +# RUN ./autogen.sh # CMD [ " CONFIG_SITE=$PWD/depends/aarch64-linux-gnu/share/config.site","./configure ", " --disable-wallet", "--disable-tests ", "--disable-bench", "--disable-man", "--with-gui=no", "--enable-reduce-exports", "LDFLAGS=-static-libstdc++" ] -CMD [ "./configure ", " --disable-wallet", "--disable-tests ", "--disable-bench", "--disable-man", "--with-gui=no", "--enable-reduce-exports", "LDFLAGS=-static-libstdc++" ] -CMD [ "make", "check" ] +# CMD [ "./configure ", " --disable-wallet", "--disable-tests ", "--disable-bench", "--disable-man", "--with-gui=no", "--enable-reduce-exports", "LDFLAGS=-static-libstdc++" ] +# CMD [ "./configure ", " --disable-wallet", "--disable-tests ", "--disable-bench", "--disable-man", "--with-gui=no" ] +# RUN ./configure --disable-wallet --disable-tests --disable-bench --disable-man --with-gui=no +# CMD [ "make", "check" ] CMD [ "ssh-agent" ] HEALTHCHECK --interval=5s --timeout=1s --retries=3 CMD ["/opt/healthcheck.sh"] From 360f5fb9530fb430080ccea68c1998e119b14fce Mon Sep 17 00:00:00 2001 From: randymcmillan Date: Sat, 4 Jun 2022 14:30:01 -0400 Subject: [PATCH 12/39] workflow: make build-shell --- .github/workflows/c-cpp.yml | 20 +++++++++++--------- docker/ubuntu.dockerfile | 2 +- statoshi.dockerfile | 18 ++++++++++++------ 3 files changed, 24 insertions(+), 16 deletions(-) diff --git a/.github/workflows/c-cpp.yml b/.github/workflows/c-cpp.yml index 2a64155055cf..91744bd994ad 100644 --- a/.github/workflows/c-cpp.yml +++ b/.github/workflows/c-cpp.yml @@ -103,24 +103,24 @@ jobs: run: | sudo -s install -v ./src/statsd_client.h /usr/local/include/ sudo -s install -v ./src/statsd_client.cpp /usr/local/include/ - - name: autogen.sh - run: | - ./autogen.sh - name: make download -C depends - run: | + run: | cd depends - # make HOST=arm-linux-gnueabihf NO_QT=1 + make HOST=arm-linux-gnueabihf NO_QT=1 make HOST=aarch64-linux-gnu NO_QT=1 cd .. # make download -C depends # make install -C depends + - name: autogen.sh + run: | ./autogen.sh - echo - name: configure - run: | + run: | # ./configure - # CONFIG_SITE=$PWD/depends/arm-linux-gnueabihf/share/config.site ./configure --enable-reduce-exports LDFLAGS=-static-libstdc++ - CONFIG_SITE=$PWD/depends/aarch64-linux-gnu/share/config.site ./configure \ + # CONFIG_SITE=$PWD/depends/arm-linux-gnueabihf/share/config.site \ + # ./configure --enable-reduce-exports LDFLAGS=-static-libstdc++ + CONFIG_SITE=$PWD/depends/aarch64-linux-gnu/share/config.site \ + ./configure \ --disable-wallet \ --disable-tests \ --disable-bench \ @@ -132,3 +132,5 @@ jobs: make check - name: make install run: sudo make install + - name: make build-shell + run: make build-shell diff --git a/docker/ubuntu.dockerfile b/docker/ubuntu.dockerfile index 364c63df091a..29663f506a16 100644 --- a/docker/ubuntu.dockerfile +++ b/docker/ubuntu.dockerfile @@ -67,7 +67,7 @@ RUN apt-get install --no-install-recommends -y \ bsdmainutils pkg-config python3 patch bison \ g++-arm-linux-gnueabihf binutils-arm-linux-gnueabihf \ g++-aarch64-linux-gnu \ - fzf #\ + fzf # binutils-aarch64-linux-gnu diff --git a/statoshi.dockerfile b/statoshi.dockerfile index e33113a5f41e..20456c06dbce 100644 --- a/statoshi.dockerfile +++ b/statoshi.dockerfile @@ -9,9 +9,9 @@ LABEL org.opencontainers.image.description Dockerized Statoshi.info node # linux-headers for futex.h in Qt depends build # qt5-qttools-dev for lrelease RUN apk ${VERBOSE} ${NOCACHE} --update add \ - autoconf \ automake \ - #bash-completion \ + autoconf \ + bash-completion \ bison \ #busybox \ boost-dev \ @@ -92,16 +92,22 @@ RUN python3 -m pip install pyzmq #ENV PROFILE=${PROFILE} #ENV PROJECT_NAME=${PROJECT_NAME} ############################ -RUN mkdir -p /root/.bitcoin +VOLUME /tmp/statoshi WORKDIR /tmp/statoshi -COPY . /tmp/statoshi +RUN git init +RUN mkdir -p /root/.bitcoin +RUN mkdir -p /tmp/statoshi +COPY ./autogen.sh /tmp/statoshi +#COPY . /tmp/statoshi +COPY ./autogen.sh /tmp/statoshi +COPY ./configure.ac /tmp/statoshi COPY ./src/statsd_client.h /usr/local/include/ COPY ./src/statsd_client.cpp /usr/local/include/ ############################ FROM header as build-statoshi # Place Holders -RUN ls /tmp/statoshi/* -RUN ls /usr/local/include/* +# RUN ls /tmp/statoshi/* +# RUN ls /usr/local/include/* ############################ FROM build-statoshi as autogen ############################ From e697b1d63c35bfbc9ed478237adbacebb995d5fe Mon Sep 17 00:00:00 2001 From: randymcmillan Date: Sat, 4 Jun 2022 17:04:28 -0400 Subject: [PATCH 13/39] .github/workflows/c-cpp.yml: cache depends/sources --- .github/workflows/c-cpp.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/c-cpp.yml b/.github/workflows/c-cpp.yml index 91744bd994ad..43b6d979cd2f 100644 --- a/.github/workflows/c-cpp.yml +++ b/.github/workflows/c-cpp.yml @@ -33,18 +33,18 @@ jobs: - uses: actions/cache@v3 with: path: | - ${{ github.workspace }}/depends - key: ${{ runner.os }}-depends + ${{ github.workspace }}/depends/sources + key: ${{ runner.os }}-depends-sources restore-keys: | - ${{ runner.os }}-depends + ${{ runner.os }}-depends-sources - uses: actions/cache@v3 with: path: | - ${{ github.workspace }}/depends ${{ github.workspace }}/src/bitcoind key: ${{ runner.os }}-bitcoind restore-keys: | ${{ runner.os }}-bitcoind- + - name: install libs-1 run: | sudo \ From 7036be51db2fb6f2f3ee557e5e20340332858c06 Mon Sep 17 00:00:00 2001 From: randymcmillan Date: Sat, 4 Jun 2022 17:17:00 -0400 Subject: [PATCH 14/39] make HOST=... --- .github/workflows/c-cpp.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/c-cpp.yml b/.github/workflows/c-cpp.yml index 43b6d979cd2f..1efe041d281c 100644 --- a/.github/workflows/c-cpp.yml +++ b/.github/workflows/c-cpp.yml @@ -129,7 +129,10 @@ jobs: --enable-reduce-exports LDFLAGS=-static-libstdc++ - name: make check run: | - make check + # make check + make check HOST=arm-linux-gnueabihf NO_QT=1 + make check HOST=aarch64-linux-gnu NO_QT=1 + - name: make install run: sudo make install - name: make build-shell From 15b83af7adf40f0dd7efa02577e11ae1b01b53ac Mon Sep 17 00:00:00 2001 From: randymcmillan Date: Sat, 4 Jun 2022 17:31:56 -0400 Subject: [PATCH 15/39] .github/workflows/c-cpp.yml: cache sources/.libs --- .github/workflows/c-cpp.yml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/.github/workflows/c-cpp.yml b/.github/workflows/c-cpp.yml index 1efe041d281c..3f883ce67d03 100644 --- a/.github/workflows/c-cpp.yml +++ b/.github/workflows/c-cpp.yml @@ -44,6 +44,20 @@ jobs: key: ${{ runner.os }}-bitcoind restore-keys: | ${{ runner.os }}-bitcoind- + - uses: actions/cache@v3 + with: + path: | + ${{ github.workspace }}/src/bitcoin-cli + key: ${{ runner.os }}-bitcoin-cli + restore-keys: | + ${{ runner.os }}-bitcoind-cli + - uses: actions/cache@v3 + with: + path: | + ${{ github.workspace }}/src/.libs + key: ${{ runner.os }}-libs + restore-keys: | + ${{ runner.os }}-libs - name: install libs-1 run: | From 8392e9876b57e00b6c4b04d8d9ef1e22d04d5298 Mon Sep 17 00:00:00 2001 From: randymcmillan Date: Sat, 4 Jun 2022 17:37:54 -0400 Subject: [PATCH 16/39] .github/workflows/c-cpp.yml: cache src/*.a --- .github/workflows/c-cpp.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.github/workflows/c-cpp.yml b/.github/workflows/c-cpp.yml index 3f883ce67d03..e3dc133be4bb 100644 --- a/.github/workflows/c-cpp.yml +++ b/.github/workflows/c-cpp.yml @@ -58,6 +58,13 @@ jobs: key: ${{ runner.os }}-libs restore-keys: | ${{ runner.os }}-libs + - uses: actions/cache@v3 + with: + path: | + ${{ github.workspace }}/src/*.a + key: ${{ runner.os }}-src-a + restore-keys: | + ${{ runner.os }}-src-a - name: install libs-1 run: | From 558d17b0b21be41bec6d7deb84644fe8c8603781 Mon Sep 17 00:00:00 2001 From: randymcmillan Date: Sat, 4 Jun 2022 17:44:26 -0400 Subject: [PATCH 17/39] .github/workflows/c-cpp.yml: HOST=aarch64.. make --- .github/workflows/c-cpp.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/c-cpp.yml b/.github/workflows/c-cpp.yml index e3dc133be4bb..94d8492e75a4 100644 --- a/.github/workflows/c-cpp.yml +++ b/.github/workflows/c-cpp.yml @@ -148,11 +148,11 @@ jobs: --disable-man \ --with-gui=no \ --enable-reduce-exports LDFLAGS=-static-libstdc++ - - name: make check + - name: HOST=aarch64-linux-gnu NO_QT=1 make run: | # make check - make check HOST=arm-linux-gnueabihf NO_QT=1 - make check HOST=aarch64-linux-gnu NO_QT=1 + # make check HOST=arm-linux-gnueabihf NO_QT=1 + HOST=aarch64-linux-gnu NO_QT=1 make - name: make install run: sudo make install From 6c2a4ad0d7d8a0f2ed3c20ed29c962078d05b5f2 Mon Sep 17 00:00:00 2001 From: randymcmillan Date: Sat, 4 Jun 2022 18:46:49 -0400 Subject: [PATCH 18/39] .github/workflows/c-cpp.yml: make build-shell rm -f Makefile --- .github/workflows/c-cpp.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/c-cpp.yml b/.github/workflows/c-cpp.yml index 94d8492e75a4..af379556c1c4 100644 --- a/.github/workflows/c-cpp.yml +++ b/.github/workflows/c-cpp.yml @@ -157,4 +157,6 @@ jobs: - name: make install run: sudo make install - name: make build-shell - run: make build-shell + run: | + rm -f Makefile + make build-shell From 4ee7cd1ab2c7bb2a9d8316039a48a4a3076634b7 Mon Sep 17 00:00:00 2001 From: randymcmillan Date: Sat, 4 Jun 2022 18:58:06 -0400 Subject: [PATCH 19/39] .github/workflows/c-cpp.yml: docker-cache to gh registry --- .github/workflows/c-cpp.yml | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/.github/workflows/c-cpp.yml b/.github/workflows/c-cpp.yml index af379556c1c4..bd1853dc71a9 100644 --- a/.github/workflows/c-cpp.yml +++ b/.github/workflows/c-cpp.yml @@ -156,7 +156,15 @@ jobs: - name: make install run: sudo make install - - name: make build-shell - run: | - rm -f Makefile - make build-shell + build_with_gpr: + - name: make build-shell + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - run: echo ${{ secrets.GITHUB_TOKEN }} | docker login docker.pkg.github.com -u $GITHUB_ACTOR --password-stdin + - run: docker pull docker.pkg.github.com/$GITHUB_REPOSITORY/build-cache-no-buildkit || true + - run: docker build -f docker/ubuntu.dockerfile . -t thing --cache-from=docker.pkg.github.com/$GITHUB_REPOSITORY/build-cache-no-buildkit + - run: docker tag ubuntu-cache docker.pkg.github.com/$GITHUB_REPOSITORY/build-cache-no-buildkit && docker push docker.pkg.github.com/$GITHUB_REPOSITORY/build-cache-no-buildkit || true + - run: | + - rm -f Makefile + - make build-shell From ee7e3323dd768b593a926e3befeaec5b686c6b86 Mon Sep 17 00:00:00 2001 From: randymcmillan Date: Sat, 4 Jun 2022 19:00:23 -0400 Subject: [PATCH 20/39] github/workflows/dockerimage.yml --- .github/workflows/c-cpp.yml | 23 +++++------ .github/workflows/dockerimage.yml | 68 +++++++++++++++++++++++++++++++ Dockerfile | 17 ++++++++ 3 files changed, 95 insertions(+), 13 deletions(-) create mode 100644 .github/workflows/dockerimage.yml create mode 100644 Dockerfile diff --git a/.github/workflows/c-cpp.yml b/.github/workflows/c-cpp.yml index bd1853dc71a9..104dc76ac315 100644 --- a/.github/workflows/c-cpp.yml +++ b/.github/workflows/c-cpp.yml @@ -155,16 +155,13 @@ jobs: HOST=aarch64-linux-gnu NO_QT=1 make - name: make install - run: sudo make install - build_with_gpr: - - name: make build-shell - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - run: echo ${{ secrets.GITHUB_TOKEN }} | docker login docker.pkg.github.com -u $GITHUB_ACTOR --password-stdin - - run: docker pull docker.pkg.github.com/$GITHUB_REPOSITORY/build-cache-no-buildkit || true - - run: docker build -f docker/ubuntu.dockerfile . -t thing --cache-from=docker.pkg.github.com/$GITHUB_REPOSITORY/build-cache-no-buildkit - - run: docker tag ubuntu-cache docker.pkg.github.com/$GITHUB_REPOSITORY/build-cache-no-buildkit && docker push docker.pkg.github.com/$GITHUB_REPOSITORY/build-cache-no-buildkit || true - - run: | - - rm -f Makefile - - make build-shell + run: | + sudo make install + - name: make build-shell + run: | + echo ${{ secrets.GITHUB_TOKEN }} | docker login docker.pkg.github.com -u $GITHUB_ACTOR --password-stdin + docker pull docker.pkg.github.com/$GITHUB_REPOSITORY/build-cache-no-buildkit || true + docker build -f docker/ubuntu.dockerfile . -t thing --cache-from=docker.pkg.github.com/$GITHUB_REPOSITORY/build-cache-no-buildkit + docker tag ubuntu-cache docker.pkg.github.com/$GITHUB_REPOSITORY/build-cache-no-buildkit && docker push docker.pkg.github.com/$GITHUB_REPOSITORY/build-cache-no-buildkit || true + rm -f Makefile + make build-shell diff --git a/.github/workflows/dockerimage.yml b/.github/workflows/dockerimage.yml new file mode 100644 index 000000000000..a93e93ac2d90 --- /dev/null +++ b/.github/workflows/dockerimage.yml @@ -0,0 +1,68 @@ +# Increase number to trigger CI -> 1 +name: The showdown +on: + push: {} +jobs: + build_no_cache: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - run: docker build . -t thing + build_no_cache_buildkit: + env: + DOCKER_BUILDKIT: '1' + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - run: docker build . -t thing + build_with_docker_save_load: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - id: cache-docker + uses: actions/cache@v1 + with: + path: /tmp/docker-save + key: docker-save-${{ hashFiles('Dockerfile') }} + - run: docker load -i /tmp/docker-save/snapshot.tar || true + if: steps.cache-docker.outputs.cache-hit == 'true' + - run: docker build . -t thing --cache-from=thing-cache + - run: docker tag thing thing-cache && mkdir -p /tmp/docker-save && docker save thing-cache -o /tmp/docker-save/snapshot.tar && ls -lh /tmp/docker-save || true + if: always() && steps.cache-docker.outputs.cache-hit != 'true' + build_with_local_registry: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - id: cache-docker + uses: actions/cache@v1 + with: + path: /tmp/docker-registry + key: docker-registry-no-buildkit-${{ hashFiles('Dockerfile') }} + - run: docker run -d -p 5000:5000 --restart=always --name registry -v /tmp/docker-registry:/var/lib/registry registry:2 && npx wait-on tcp:5000 + - run: docker pull localhost:5000/thing || true + - run: docker build . -t thing --cache-from=localhost:5000/thing + - run: docker tag thing localhost:5000/thing && docker push localhost:5000/thing || true + if: steps.cache.outputs.cache-hit != 'true' + build_with_local_registry_buildkit: + env: + DOCKER_BUILDKIT: '1' + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - id: cache-docker + uses: actions/cache@v1 + with: + path: /tmp/docker-registry + key: docker-registry-buildkit-${{ hashFiles('Dockerfile') }} + - run: docker run -d -p 5000:5000 --restart=always --name registry -v /tmp/docker-registry:/var/lib/registry registry:2 && npx wait-on tcp:5000 + - run: docker build . -t thing --cache-from=localhost:5000/thing --build-arg BUILDKIT_INLINE_CACHE=1 + - run: docker tag thing localhost:5000/thing && docker push localhost:5000/thing || true + if: steps.cache.outputs.cache-hit != 'true' + build_with_gpr: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - run: echo ${{ secrets.GITHUB_TOKEN }} | docker login docker.pkg.github.com -u $GITHUB_ACTOR --password-stdin + - run: docker pull docker.pkg.github.com/$GITHUB_REPOSITORY/build-cache-no-buildkit || true + - run: docker build . -t thing --cache-from=docker.pkg.github.com/$GITHUB_REPOSITORY/build-cache-no-buildkit + - run: docker tag thing docker.pkg.github.com/$GITHUB_REPOSITORY/build-cache-no-buildkit && docker push docker.pkg.github.com/$GITHUB_REPOSITORY/build-cache-no-buildkit || true \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 000000000000..d5299175d109 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,17 @@ +FROM node:14 +RUN yarn create react-app my-react-app +RUN cd my-react-app && yarn build +RUN npm install -g @vue/cli && (yes | vue create my-vue-app --default) +RUN cd my-vue-app && yarn build +RUN mkdir -p my-tests && cd my-tests && yarn add playwright +# test +# test +# test +# test +# test +# test +# test +# test +# test +# test + From fb3408f5027d6d0ca62cbaaa387c3dc68f3e3b61 Mon Sep 17 00:00:00 2001 From: randymcmillan Date: Sat, 4 Jun 2022 19:07:58 -0400 Subject: [PATCH 21/39] .github/workflows/c-cpp.yml: apt cache --- .github/workflows/c-cpp.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.github/workflows/c-cpp.yml b/.github/workflows/c-cpp.yml index 104dc76ac315..59da0edf6f39 100644 --- a/.github/workflows/c-cpp.yml +++ b/.github/workflows/c-cpp.yml @@ -65,6 +65,13 @@ jobs: key: ${{ runner.os }}-src-a restore-keys: | ${{ runner.os }}-src-a + - uses: actions/cache@v3 + with: + path: | + ${{ github.workspace }}/var/cache/apt/archives + key: ${{ runner.os }}-apt-cache + restore-keys: | + ${{ runner.os }}-apt-cache - name: install libs-1 run: | From 4a4f46a3cb9c22461c2f11d9a5c205a55efbec07 Mon Sep 17 00:00:00 2001 From: randymcmillan Date: Sat, 4 Jun 2022 19:40:42 -0400 Subject: [PATCH 22/39] Dockerfile: test node:14 then node:16 --- Dockerfile | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Dockerfile b/Dockerfile index d5299175d109..097174663a07 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,6 +4,12 @@ RUN cd my-react-app && yarn build RUN npm install -g @vue/cli && (yes | vue create my-vue-app --default) RUN cd my-vue-app && yarn build RUN mkdir -p my-tests && cd my-tests && yarn add playwright +FROM node:16 +RUN yarn create react-app my-react-app16 +RUN cd my-react-app16 && yarn build +RUN npm install -g @vue/cli && (yes | vue create my-vue-app --default) +RUN cd my-vue-app && yarn build +RUN mkdir -p my-tests && cd my-tests && yarn add playwright # test # test # test From 446253a7291ad9c9610192c2d09bd5323a33b024 Mon Sep 17 00:00:00 2001 From: randymcmillan Date: Sat, 4 Jun 2022 20:14:36 -0400 Subject: [PATCH 23/39] .github/workflows/c-cpp.yml: UBUNTU_VERSION=jamy --- .github/workflows/c-cpp.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/c-cpp.yml b/.github/workflows/c-cpp.yml index 59da0edf6f39..36a677aca7c8 100644 --- a/.github/workflows/c-cpp.yml +++ b/.github/workflows/c-cpp.yml @@ -167,7 +167,7 @@ jobs: - name: make build-shell run: | echo ${{ secrets.GITHUB_TOKEN }} | docker login docker.pkg.github.com -u $GITHUB_ACTOR --password-stdin - docker pull docker.pkg.github.com/$GITHUB_REPOSITORY/build-cache-no-buildkit || true + UBUNTU_VERSION=jammy docker pull docker.pkg.github.com/$GITHUB_REPOSITORY/build-cache-no-buildkit || true docker build -f docker/ubuntu.dockerfile . -t thing --cache-from=docker.pkg.github.com/$GITHUB_REPOSITORY/build-cache-no-buildkit docker tag ubuntu-cache docker.pkg.github.com/$GITHUB_REPOSITORY/build-cache-no-buildkit && docker push docker.pkg.github.com/$GITHUB_REPOSITORY/build-cache-no-buildkit || true rm -f Makefile From 99f2fd107f6d967a4127d6da4af249df827e78ef Mon Sep 17 00:00:00 2001 From: randymcmillan Date: Sat, 4 Jun 2022 20:38:53 -0400 Subject: [PATCH 24/39] make: PROJECT_NAME=$PWD --- GNUmakefile | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/GNUmakefile b/GNUmakefile index 280155102174..b4b82c156c8a 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -83,7 +83,7 @@ export PYTHON_VERSION # Use $(GIT_REPO_NAME) for commands that need the dotted name # $(PROJECT_NAME) is used in many docker commands in the GNUmakefile ifeq ($(project),) -PROJECT_NAME := timechain-academy#$(notdir $(PWD)) +PROJECT_NAME := $(notdir $(PWD)) else PROJECT_NAME := $(project) endif @@ -307,6 +307,7 @@ report:## report @echo ' - PIP3=${PIP3}' @echo ' - ARCH=${ARCH}' @echo ' - TRIPLET=${TRIPLET}' + @echo ' - UBUNTU_VERSION=${UBUNTU_VERSION}' @echo ' - PORT=${PORT}' @echo ' - GIT_USER_NAME=${GIT_USER_NAME}' @echo ' - GIT_USER_EMAIL=${GIT_USER_EMAIL}' @@ -326,14 +327,7 @@ initialize:## initialize init: initialize## init python3 -m pip install -r sources/requirements.txt -docs:## docs - $(DOCKER_COMPOSE) $(VERBOSE) -p $(PROJECT_NAME)_$(HOST_UID) build $(NOCACHE) docs - # $(DOCKER_COMPOSE) $(VERBOSE) run --rm --publish 18000:18000 docs - #$(DOCKER_COMPOSE) $(VERBOSE) run -d --rm docs - $(DOCKER_COMPOSE) $(VERBOSE) up -d - - -run: docs shell +run: shell $(NOHUP) $(DOCKER_COMPOSE) $(VERBOSE) up & From 90e149f46f03bb225f8a657b56f40a291489d6c4 Mon Sep 17 00:00:00 2001 From: randymcmillan Date: Sat, 4 Jun 2022 20:39:57 -0400 Subject: [PATCH 25/39] .github/workflows/c-cpp.yml: build shell: make && \ ... --- .github/workflows/c-cpp.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/c-cpp.yml b/.github/workflows/c-cpp.yml index 36a677aca7c8..5a3e425dc59c 100644 --- a/.github/workflows/c-cpp.yml +++ b/.github/workflows/c-cpp.yml @@ -166,6 +166,7 @@ jobs: sudo make install - name: make build-shell run: | + make && \ echo ${{ secrets.GITHUB_TOKEN }} | docker login docker.pkg.github.com -u $GITHUB_ACTOR --password-stdin UBUNTU_VERSION=jammy docker pull docker.pkg.github.com/$GITHUB_REPOSITORY/build-cache-no-buildkit || true docker build -f docker/ubuntu.dockerfile . -t thing --cache-from=docker.pkg.github.com/$GITHUB_REPOSITORY/build-cache-no-buildkit From 3d388774b740e48ee5d1b6ba972804556a533d2c Mon Sep 17 00:00:00 2001 From: randymcmillan Date: Sat, 4 Jun 2022 21:01:39 -0400 Subject: [PATCH 26/39] docker/bin/initialize: add file: make initialize --- .github/workflows/c-cpp.yml | 1 + .gitignore | 1 + GNUmakefile | 161 +-------------------- docker/bin/initialize | 272 ++++++++++++++++++++++++++++++++++++ 4 files changed, 276 insertions(+), 159 deletions(-) create mode 100755 docker/bin/initialize diff --git a/.github/workflows/c-cpp.yml b/.github/workflows/c-cpp.yml index 5a3e425dc59c..16dbdf4469e8 100644 --- a/.github/workflows/c-cpp.yml +++ b/.github/workflows/c-cpp.yml @@ -75,6 +75,7 @@ jobs: - name: install libs-1 run: | + make init sudo \ apt-get install --no-install-recommends -y \ automake \ diff --git a/.gitignore b/.gitignore index 6c888bfdc46e..307e49ff839a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +bitcoin-* *.tar.gz *.exe diff --git a/GNUmakefile b/GNUmakefile index b4b82c156c8a..e0164c0667f3 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -322,144 +322,13 @@ report:## report .PHONY: init initialize docs initialize:## initialize - ./scripts/initialize + docker/bin/initialize test ./sources/playground/docker/scripts/initialize && ./sources/playground/docker/scripts/initialize || echo "Try: `make resources`" init: initialize## init - python3 -m pip install -r sources/requirements.txt run: shell $(NOHUP) $(DOCKER_COMPOSE) $(VERBOSE) up & - - -.PHONY: clean-resources clean sources resources -clean-sources: clean sources -clean:## clean - rm -rf sources/playground/docker - rm -rf sources/git - rm -rf sources/ide - rm -rf sources/books/bitcoinbook - rm -rf sources/books/lnbook - rm -rf sources/books/python - rm -rf sources/qt/webengine - rm -f *.log - -.SILENT: -sources: resources## sources -resources: - ( \ - rm -f resources.log; \ - tail resources.log & \ - echo $(TIME) > resources.log; \ - $(MAKE) playground; \ - $(MAKE) qt-webengine; \ - $(MAKE) books; \ - ); - -playground:## clone-playground - git clone --progress --verbose --depth 1 -b master https://github.com/PLEBNET-PLAYGROUND/plebnet-playground-docker.git \ - sources/playground/docker \ - >> resources.log 2>&1 \ - || >> resources.log 2>&1 -qt-webengine:## qt webengine - git clone --progress --verbose --depth 1 -b v5.15.5-lts git://code.qt.io/qt/qtwebengine.git \ - sources/qt/webengine \ - >> resources.log 2>&1 \ - || >> resources.log 2>&1 - git clone --progress --verbose --depth 1 -b v5.15.2 git://code.qt.io/qt/qtwebengine-chromium.git \ - sources/qt/webengine/src/3rdparty/qtwebengine-chromium \ - >> resources.log 2>&1 \ - || >> resources.log 2>&1 - -clean-books:## clean - rm -rf sources/books/bitcoinbook - rm -rf sources/books/lnbook - rm -rf sources/books/python - rm -rf sources/books/*.html - # $(MAKE) books -books: mastering-bitcoin mastering-lightning python - mkdir -p sources/books - apt install pandoc || brew install pandoc - #bash -c "if hash pandoc 2>/dev/null; then echo; fi || brew or apt install pandoc" - #bash -c 'pandoc -s sources/books/README.md -o sources/books/index.html --metadata title="" ' - apt install asciidoctor || brew install asciidoctor -ifeq ($(PRIVATE),true) - pushd sources/books/bitcoinbook > /dev/null; for string in *.asciidoc; do echo "$$string"; done; popd || echo "." - pushd sources/books/bitcoinbook > /dev/null; for string in *.md; do sed 's/asciidoc/html/g' $$string | tee $$string; done; popd || echo "....." - pushd sources/books/bitcoinbook > /dev/null; for string in *.asciidoc; do asciidoctor $$string; done; popd || echo "..." - pushd sources/books/lnbook > /dev/null; for string in *.asciidoc; do echo "$$string"; done; popd || echo "...." - pushd sources/books/lnbook > /dev/null; for string in *.md; do sed 's/asciidoc/html/g' $$string | tee $$string; done; popd || echo "....." - pushd sources/books/lnbook > /dev/null; for string in *.asciidoc; do asciidoctor $$string; done; popd || echo "......" -endif - -mastering-bitcoin:## mastering bitcoin -ifeq ($(PRIVATE),true) - git clone --progress --verbose --depth 1 -b 1653630097/6f13274/77b91b1 https://github.com/randymcmillan/bitcoinbook.git \ - sources/books/bitcoinbook \ - >> resources.log 2>&1 \ - || >> resources.log 2>&1 -else - rm -rf sources/books/bitcoinbook - rm -rf docs/books/bitcoinbook -endif -mastering-lightning:## mastering lightning -ifeq ($(PRIVATE),true) - git clone --progress --verbose --depth 1 https://github.com/lnbook/lnbook.git \ - sources/books/lnbook \ - >> resources.log 2>&1 \ - || >> resources.log 2>&1 -else - rm -rf sources/books/lnbook - rm -rf docs/books/lnbook -endif -python:## python -ifeq ($(PRIVATE),true) - git clone --progress --verbose --depth 1 https://github.com/kyclark/tiny_python_projects.git \ - sources/books/python \ - >> resources.log 2>&1 \ - || >> resources.log 2>&1 -else - rm -rf sources/books/python - rm -rf docs/books/python -endif - -.PHONY: build serve build-readme build-shell shell shell-test -build-readme:## build-readme - cat sources/HEADER.md > sources/README.md - #echo '```' >> README.md - make help > sources/COMMANDS.md - #echo '```' >> README.md - cat sources/FOOTER.md >> sources/README.md - # bash -c "if hash pandoc 2>/dev/null; then echo; fi || brew or apt install pandoc" - # bash -c 'pandoc -s README.md -o index.html --metadata title="" ' -build-docs: build-readme## build mkdocs - $(MAKE) resources - mkdir -p docs - apt install pandoc || brew install pandoc - apt install asciidoctor || brew install asciidoctor -ifeq ($(PRIVATE),true) - pushd sources/books/bitcoinbook > /dev/null; for string in *.asciidoc; do echo "$$string"; done; popd || echo "." - pushd sources/books/bitcoinbook > /dev/null; for string in *.md; do sed 's/asciidoc/html/g' $$string | tee $$string; done; popd || echo "....." - pushd sources/books/bitcoinbook > /dev/null; for string in *.asciidoc; do asciidoctor --doctype=book $$string; done; popd || echo "..." - pushd sources/books/lnbook > /dev/null; for string in *.asciidoc; do echo "$$string"; done; popd || echo "...." - pushd sources/books/lnbook > /dev/null; for string in *.md; do sed 's/asciidoc/html/g' $$string | tee $$string; done; popd || echo "....." - pushd sources/books/lnbook > /dev/null; for string in *.asciidoc; do asciidoctor --doctype book $$string; done; popd || echo "......" -endif - mkdocs $(VERBOSE) build - -build-playground:## build-playground - pushd sources/playground/docker && make initialize init build && popd - -run-playground:## run-playground - pushd sources/playground/docker && make install && popd - -run-playground-cluster:## run-playground-cluster - pushd sources/playground/docker && make install-cluster && popd - -serve: build## serve mkdocs - $(NOHUP) mkdocs serve & open http://127.0.0.1:$(PORT) || open http://127.0.0.1:$(PORT) - #$(PYTHON3) -m http.server $(PORT) --bind 127.0.0.1 -d $(PWD)/docs > /dev/null 2>&1 || open http://127.0.0.1:$(PORT) - build-shell:## build the ubuntu docker image docker-compose build $(NOCACHE) $(VERBOSE) ${SERVICE_TARGET} & @@ -477,33 +346,7 @@ shell-test:## shell-test #shell-network-test:## shell-network-test # docker-compose -p $(PROJECT_NAME)_$(HOST_UID) run --rm ${SERVICE_TARGET} bash -c "curl -fsSL https://raw.githubusercontent.com/timechain-academy/timechain.academy/master/scripts/shell-network-test" -push-docs: ## ghp-import to deploy docs folder - # NOTES: The docs folder becomes the root on the gh-pages branch - # NOTES: In the github.com pages setting use branch: gh-pages / (root) - ghp-import -n \ - -m "$(TIME):Deployed by $(GIT_USER_NAME) commit: $(GIT_HASH)" \ - -c $(GIT_REPO_NAME) \ - -p \ - -r origin \ - -b gh-pages \ - docs - - -push: - @echo push - $(MAKE) docs - git checkout -b $(TIME)/$(GIT_PREVIOUS_HASH)/$(GIT_HASH) - git push --set-upstream origin $(TIME)/$(GIT_PREVIOUS_HASH)/$(GIT_HASH) - #git add docs - #git commit --no-edit --allow-empty -m "$(TIME)" || echo failed to commit --amend --no-edit - git push -f origin $(TIME)/$(GIT_PREVIOUS_HASH)/$(GIT_HASH):$(TIME)/$(GIT_PREVIOUS_HASH)/$(GIT_HASH) - -push-all: push-to-master push-docs#push-to-main ## push-to-master push-docs -push-to-master:## push-to-master - git push -f $(GIT_REPO_ORIGIN) $(GIT_BRANCH):master || echo failed to push docs -push-to-main:## push-to-main - git push -f $(GIT_REPO_ORIGIN) $(GIT_BRANCH):main || echo failed to push docs - +# ADD docker push... SIGNIN=randymcmillan export SIGNIN diff --git a/docker/bin/initialize b/docker/bin/initialize new file mode 100755 index 000000000000..0034705f90e2 --- /dev/null +++ b/docker/bin/initialize @@ -0,0 +1,272 @@ +#!/usr/bin/env bash +# Check for group sudo +if groups | grep "\" &> /dev/null; then + echo "You are a sudoer!" + export SUDO="sudo -s" +else + echo "You are not a sudoer!" +fi +# Check for group admin +if groups | grep "\" &> /dev/null; then + echo "You are an admin!" + export SUDO="sudo -s" +else + echo "You are not an admin!" +fi +#DETECT ENV VARS +OS=$(uname) +OS_VERSION=$(uname -r) +UNAME_M=$(uname -m) +UNAME_P=$(uname -p) +ARCH=$(uname -m) +if [[ "$OS" != "Linux"* ]]; then + if hash brew; then + BREW=$(which brew) + BREW_AWK=$(brew --prefix awk) + BREW_GAWK=$(brew --prefix gawk) + export HOMEBREW_NO_ENV_HINTS=0 + export HOMEBREW_NO_INSTALL_CLEANUP=false + fi +fi +PYTHON3=$(which python3) +PIP=$(which pip) +PIP3=$(which pip3) +if [ -z "$SUDO" ]; then + DASH_U="-U" +else + DASH_U= +fi +AWK=$(which awk) +GAWK=$(which gawk) + +echo "OS=$OS" +echo "OS_VERSION=$OS_VERSION" +echo "UNAME_M=$UNAME_M" +echo "UNAME_P=$UNAME_P" +echo "ARCH=$ARCH" +echo "BREW=$BREW" +echo "PYTHON3=$PYTHON3" +echo "PIP=$PIP" +echo "PIP3=$PIP3" +echo "DASH_U=$DASH_U" +echo "AWK=$AWK" +echo "GAWK=$GAWK" +echo "BREW_AWK=$BREW_AWK" +echo "BREW_GAWK=$BREW_GAWK" + +if [ "${UNAME_M}" = "x86_64" ]; then + if [ "${OS}" = "Darwin"* ]; then + if [ "$(sysctl -in sysctl.proc_translated)" = "1" ]; then + echo "Running on Rosetta 2" + ROSETTA=1 + export ROSETTA + else + echo "Running on native Intel" + fi + fi +elif [ "${UNAME_M}" = "arm64" ]; then + echo "Running on arm64" +elif [ "${UNAME_M}" = "aarch64" ]; then + echo "Running on aarch64" +else + echo "Unknown architecture: ${UNAME_M}" +fi + +if [[ ! -z "$GAWK" ]]; then + AWK=$(which gawk) + export AWK +fi + +function initialize-add-python3-to-path(){ +#ADD python3 to PATH +if [[ ! -z "${python_version_major}" ]]; then + if [[ ! -z "${python_version_minor}" ]]; then + export PATH=$PATH:/usr/local/opt/python@${python_version_major}.${python_version_minor}/Frameworks/Python.framework/Versions/${python_version_major}.${python_version_minor}/bin + fi +fi +} + +function initialize-use-apk(){ +# alpine linux... not android + echo "more apk support needed" + apk add "$AWK" + apk add python3 py3-pip + python3 -m pip install -r sources/requirements.txt || \ + python3 -m pip install -r ../requirements.txt + +} +function initialize-use-apt(){ + +DEBIAN_FRONTEND=noninteractive TZ=Etc/UTC apt-get -y install tzdata + +if hash apt-get 2>/dev/null; then + $SUDO apt-get update + $SUDO apt-get install --no-install-recommends -y \ + automake \ + binutils \ + bsdmainutils \ + ca-certificates \ + cmake \ + curl \ + diffoscope \ + doxygen \ + g++-multilib \ + git \ + libbz2-dev \ + libcap-dev \ + libtinfo5 \ + libtool \ + lbzip2 \ + libz-dev \ + make \ + nsis \ + patch \ + pkg-config \ + python3 \ + python3-setuptools \ + ripgrep \ + vim \ + xz-utils \ + build-essential libtool autotools-dev \ + automake pkg-config bsdmainutils python3 \ + libevent-dev libboost-dev \ + libsqlite3-dev libminiupnpc-dev libnatpmp-dev \ + libzmq3-dev systemtap-sdt-dev \ + libqt5gui5 libqt5core5a libqt5dbus5 qttools5-dev qttools5-dev-tools \ + qtwayland5 libqrencode-dev \ + g++-aarch64-linux-gnu \ + binutils-aarch64-linux-gnu \ + g++-arm-linux-gnueabihf \ + binutils-arm-linux-gnueabihf curl \ + binutils-riscv64-linux-gnu \ + g++-riscv64-linux-gnu \ + binutils-gold \ + bsdmainutils pkg-config python3 patch bison \ + g++-arm-linux-gnueabihf binutils-arm-linux-gnueabihf \ + g++-aarch64-linux-gnu #\ + # binutils-aarch64-linux-gnu + + + + if ! hash docker 2>/dev/null; then + $SUDO apt-get install -y runc containerd docker.io + fi + if ! hash docker-compose 2>/dev/null; then + $SUDO apt-get install -y docker-compose + fi + if ! hash flake8 2>/dev/null; then + $SUDO apt-get install -y flake8 + fi + if ! hash isort 2>/dev/null; then + $SUDO apt-get install -y isort + fi + if ! hash black 2>/dev/null; then + $SUDO apt-get install -y black + fi +else + apt install apt-get python3 python3-pip + initialize-use-apt +fi +$PYTHON3 -m pip install $DASH_U omegaconf glom +} + +function checkbrew() { + +if hash brew 2>/dev/null; then + # We want to use gawk + if ! hash gawk 2>/dev/null; then + if [[ ! -z $BREW_AWK ]]; then + brew link --overwrite gawk + fi + brew install gawk + brew link gawk + fi + if ! hash docker 2>/dev/null; then + brew install --cask docker + brew install docker + brew link docker + fi + if ! hash docker-compose 2>/dev/null; then + brew install docker-compose + fi + if ! hash mkdocs 2>/dev/null; then + brew install mkdocs + fi + if ! hash jq 2>/dev/null; then + brew install jq + fi + brew install --quiet --force python@3.9 + #echo $(brew --prefix python@3.9) + # omegaconf works with python3.9 + # stability on other versions needs to be retested and updated + $(which python3.9) -m ensurepip $DASH_U 2>/dev/null + $(which python3.9) -m pip -q install omegaconf 2>/dev/null + echo +else + /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)" + checkbrew +fi +} +checkraspi(){ + + echo 'Checking Raspi' + if [ -e /etc/rpi-issue ]; then + echo "- Original Installation" + cat /etc/rpi-issue + fi + if [ -e /usr/bin/lsb_release ]; then + echo "- Current OS" + lsb_release -irdc + fi + echo "- Kernel" + uname -r + echo "- Model" + cat /proc/device-tree/model && echo + echo "- hostname" + hostname + echo "- Firmware" + /opt/vc/bin/vcgencmd version +} + +if [[ "$OSTYPE" == "linux"* ]]; then + #CHECK APT + if [[ "$OSTYPE" == "linux-gnu" ]]; then + if hash apt 2>/dev/null; then + initialize-use-apt + fi + fi + if [[ "$OSTYPE" == "linux-musl" ]]; then + if hash apk 2>/dev/null; then + initialize-use-apk + apk add "$AWK" + apk add python3 py3-pip + python3 -m pip install -r requirements.txt || \ + python3 -m pip install -r ../requirements.txt + + + fi + fi + if [[ "$OSTYPE" == "linux-arm"* ]]; then + checkraspi + if hash apt 2>/dev/null; then + apt install "$AWK" + report + echo 'Using apt...' + + fi + fi +elif [[ "$OSTYPE" == "darwin"* ]]; then + echo "checking brew..." + checkbrew +elif [[ "$OSTYPE" == "cygwin" ]]; then + echo TODO add support for $OSTYPE +elif [[ "$OSTYPE" == "msys" ]]; then + echo TODO add support for $OSTYPE +elif [[ "$OSTYPE" == "win32" ]]; then + echo TODO add support for $OSTYPE +elif [[ "$OSTYPE" == "freebsd"* ]]; then + echo TODO add support for $OSTYPE +else + echo TODO add support for $OSTYPE +fi + From 0500c2a0c95a804d77cb955f254074a8802eaddf Mon Sep 17 00:00:00 2001 From: randymcmillan Date: Sat, 4 Jun 2022 21:11:13 -0400 Subject: [PATCH 27/39] .github/workflows/dockerimage.yml -> *.yml.disable --- .github/workflows/{dockerimage.yml => dockerimage.yml.disable} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .github/workflows/{dockerimage.yml => dockerimage.yml.disable} (100%) diff --git a/.github/workflows/dockerimage.yml b/.github/workflows/dockerimage.yml.disable similarity index 100% rename from .github/workflows/dockerimage.yml rename to .github/workflows/dockerimage.yml.disable From 1398cc0997a0d31042b2977e31c56792b20a6727 Mon Sep 17 00:00:00 2001 From: randymcmillan Date: Sat, 4 Jun 2022 22:26:19 -0400 Subject: [PATCH 28/39] make: package-all working --- GNUmakefile | 76 +++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 65 insertions(+), 11 deletions(-) diff --git a/GNUmakefile b/GNUmakefile index e0164c0667f3..7874519e431b 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -191,14 +191,15 @@ GIT_REPO_NAME := $(subst -,.,$(PROJECT_NAME)) export GIT_REPO_NAME #Usage -#make push profile=timechain-academy +#make push profile=bitcoincore-dev +#make package-all profile=bitcoincore-dev #note on GH_TOKEN.txt file below ifeq ($(profile),) GIT_PROFILE :=$(GIT_USER_NAME) -ifeq ($(GIT_REPO_ORIGIN),git@github.com:timechain-academy/timechain.academy.git) -GIT_PROFILE :=timechain-academy +ifeq ($(GIT_REPO_ORIGIN),git@github.com:bitcoincore-dev/$(PROJECT_NAME).git) +GIT_PROFILE :=bitcoinccore-dev endif -ifeq ($(GIT_REPO_ORIGIN),https://github.com/$(GITHUB_USER_NAME)/timechain.academy.git) +ifeq ($(GIT_REPO_ORIGIN),https://github.com/$(GITHUB_USER_NAME)/$(PROJECT_NAME).git) GIT_PROFILE :=$(GITHUB_USER_NAME) endif else @@ -217,6 +218,9 @@ export GIT_REPO_ORIGIN GIT_REPO_PATH := $(HOME)/$(GIT_REPO_NAME) export GIT_REPO_PATH +PACKAGE_PREFIX := ghcr.io +export PACKAGE_PREFIX + PORT:=8000 export PORT export @@ -323,21 +327,20 @@ report:## report .PHONY: init initialize docs initialize:## initialize docker/bin/initialize - test ./sources/playground/docker/scripts/initialize && ./sources/playground/docker/scripts/initialize || echo "Try: `make resources`" init: initialize## init run: shell - $(NOHUP) $(DOCKER_COMPOSE) $(VERBOSE) up & + $(NOHUP) $(DOCKER_COMPOSE) $(VERBOSE) up -d build-shell:## build the ubuntu docker image - docker-compose build $(NOCACHE) $(VERBOSE) ${SERVICE_TARGET} & + $(DOCKER_COMPOSE) build $(NOCACHE) $(VERBOSE) ${SERVICE_TARGET} & .PHONY: shell shell: build-shell## run the ubuntu docker environment ifeq ($(CMD_ARGUMENTS),) - $(DOCKER_COMPOSE) $(VERBOSE) -p $(PROJECT_NAME)_$(HOST_UID) run -it --rm ${SERVICE_TARGET} bash + $(DOCKER_COMPOSE) $(VERBOSE) -p $(PROJECT_NAME)_$(HOST_UID) run -it --rm ${SERVICE_TARGET} bash else - $(DOCKER_COMPOSE) $(VERBOSE) -p $(PROJECT_NAME)_$(HOST_UID) run -it --rm $(SERVICE_TARGET) bash -c "$(CMD_ARGUMENTS)" + $(DOCKER_COMPOSE) $(VERBOSE) -p $(PROJECT_NAME)_$(HOST_UID) run -dit --rm $(SERVICE_TARGET) bash -c "$(CMD_ARGUMENTS)" endif shell-test:## shell-test @@ -348,12 +351,63 @@ shell-test:## shell-test # ADD docker push... +####################### +.PHONY: clean +clean-statoshi:## clean-statoshi + # remove created images + @$(DOCKER_COMPOSE) -p $(PROJECT_NAME) down --remove-orphans --rmi all 2>/dev/null \ + && echo 'Image(s) for "$(PROJECT_NAME)" removed.' \ + || echo 'Image(s) for "$(PROJECT_NAME)" already removed.' +####################### +.PHONY: prune +prune-system:## docker system prune -af (very destructive!) +ifeq ($(user),root) + $(DOCKER_COMPOSE) -p $(PROJECT_NAME) down || true + docker system prune -af & +else + @echo "make prune-system user=root" +endif +####################### +.PHONY: prune-network +prune-statoshi:## remove statoshi network + $(DOCKER_COMPOSE) -p $(PROJECT_NAME) down + docker network rm $(PROJECT_NAME)* 2>/dev/null || echo +####################### +.PHONY: push +push: + @echo push + git checkout -b $(TIME)/$(GIT_PREVIOUS_HASH)/$(GIT_HASH) + git push --set-upstream origin $(TIME)/$(GIT_PREVIOUS_HASH)/$(GIT_HASH) + git add docs + git commit --amend --no-edit --allow-empty || echo failed to commit --amend --no-edit + git push -f origin $(TIME)/$(GIT_PREVIOUS_HASH)/$(GIT_HASH):$(TIME)/$(GIT_PREVIOUS_HASH)/$(GIT_HASH) + +.PHONY: push-docs +push-docs: statoshi-docs push + @echo 'push-docs' + SIGNIN=randymcmillan export SIGNIN -signin: +.PHONY: signin +signin: report #Place a file named GH_TOKEN.txt in your $HOME - create in https://github.com/settings/tokens (Personal access tokens) bash -c 'cat ~/GH_TOKEN.txt | docker login ghcr.io -u $(GIT_PROFILE) --password-stdin' - +####################### +package-$(PROJECT_NAME): signin + + #touch TIME && echo $(TIME) > TIME && git add -f TIME + #legit . -m "make package-header at $(TIME)" -p 00000 + #git commit --amend --no-edit --allow-empty + + bash -c 'docker tag $(PROJECT_NAME):$(HOST_USER) $(PACKAGE_PREFIX)/$(GIT_PROFILE)/$(PROJECT_NAME)/statoshi-$(TRIPLET)/$(HOST_USER):$(TIME) || echo skip statoshi' + bash -c 'docker push $(PACKAGE_PREFIX)/$(GIT_PROFILE)/$(PROJECT_NAME)/statoshi-$(TRIPLET)/$(HOST_USER):$(TIME) || echo skip statoshi' + +######################## +.PHONY: package-all +package-all: init package-$(PROJECT_NAME) +#INSERT other scripting here + bash -c "echo insert more scripting here..." +######################## #-include funcs.mk -include Makefile From c299345b15efd1e5b9f96b63a3bff40f4e8ff02b Mon Sep 17 00:00:00 2001 From: randymcmillan Date: Sat, 4 Jun 2022 22:40:11 -0400 Subject: [PATCH 29/39] .github/workflows/c-cpp.yml: add -name: id: to cache-depends-sources --- .github/workflows/c-cpp.yml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/.github/workflows/c-cpp.yml b/.github/workflows/c-cpp.yml index 16dbdf4469e8..91590a082181 100644 --- a/.github/workflows/c-cpp.yml +++ b/.github/workflows/c-cpp.yml @@ -29,7 +29,11 @@ jobs: runs-on: ubuntu-latest steps: + - uses: styfle/cancel-workflow-action@0.9.1 + with: + access_token: ${{ github.token }} - uses: actions/checkout@v3 + - uses: actions/cache@v3 with: path: | @@ -37,6 +41,7 @@ jobs: key: ${{ runner.os }}-depends-sources restore-keys: | ${{ runner.os }}-depends-sources + - uses: actions/cache@v3 with: path: | @@ -44,6 +49,7 @@ jobs: key: ${{ runner.os }}-bitcoind restore-keys: | ${{ runner.os }}-bitcoind- + - uses: actions/cache@v3 with: path: | @@ -51,6 +57,7 @@ jobs: key: ${{ runner.os }}-bitcoin-cli restore-keys: | ${{ runner.os }}-bitcoind-cli + - uses: actions/cache@v3 with: path: | @@ -58,6 +65,7 @@ jobs: key: ${{ runner.os }}-libs restore-keys: | ${{ runner.os }}-libs + - uses: actions/cache@v3 with: path: | @@ -65,6 +73,7 @@ jobs: key: ${{ runner.os }}-src-a restore-keys: | ${{ runner.os }}-src-a + - uses: actions/cache@v3 with: path: | @@ -74,6 +83,7 @@ jobs: ${{ runner.os }}-apt-cache - name: install libs-1 + if: steps.cache- run: | make init sudo \ From 6e4c9c7f49fe8eae5f21fa2a15df8ec1c9768b1c Mon Sep 17 00:00:00 2001 From: randymcmillan Date: Sat, 4 Jun 2022 23:03:18 -0400 Subject: [PATCH 30/39] workflow: if: steps.apt-cache.outputs.cache-hit != 'true' --- .github/workflows/c-cpp.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/c-cpp.yml b/.github/workflows/c-cpp.yml index 91590a082181..d4557c83ffb5 100644 --- a/.github/workflows/c-cpp.yml +++ b/.github/workflows/c-cpp.yml @@ -75,6 +75,7 @@ jobs: ${{ runner.os }}-src-a - uses: actions/cache@v3 + id: apt-cache with: path: | ${{ github.workspace }}/var/cache/apt/archives @@ -83,7 +84,7 @@ jobs: ${{ runner.os }}-apt-cache - name: install libs-1 - if: steps.cache- + if: steps.apt-cache.outputs.cache-hit != 'true' run: | make init sudo \ @@ -124,6 +125,7 @@ jobs: # Split cross-compilers out. # apt cant install everything at once - name: install libs-2 + if: steps.apt-cache.outputs.cache-hit != 'true' run: | sudo \ apt-get install --no-install-recommends -y \ From 37782d904558f9d288aaf587e9dbce9d59860cb4 Mon Sep 17 00:00:00 2001 From: randymcmillan Date: Sat, 4 Jun 2022 23:26:28 -0400 Subject: [PATCH 31/39] docker: comply with valid image reference ubuntu:jammy --- docker/ubuntu.dockerfile | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/docker/ubuntu.dockerfile b/docker/ubuntu.dockerfile index 29663f506a16..b4327ccc4b97 100644 --- a/docker/ubuntu.dockerfile +++ b/docker/ubuntu.dockerfile @@ -1,5 +1,4 @@ -ARG UBUNTU_VERSION=${UBUNTU_VERSION} -FROM ubuntu:${UBUNTU_VERSION} as base +FROM ubuntu:jammy as base RUN set -xe; \ apt install -y apt RUN apt-get -y upgrade From f4461fb24aec57a4ec0521af081130307adf270b Mon Sep 17 00:00:00 2001 From: randymcmillan Date: Sun, 5 Jun 2022 00:11:22 -0400 Subject: [PATCH 32/39] .github/workflows/c-cpp.yml: make build-shell --- .github/workflows/c-cpp.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/c-cpp.yml b/.github/workflows/c-cpp.yml index d4557c83ffb5..e367af068206 100644 --- a/.github/workflows/c-cpp.yml +++ b/.github/workflows/c-cpp.yml @@ -179,10 +179,10 @@ jobs: sudo make install - name: make build-shell run: | + rm -f Makefile + make build-shell user=root make && \ echo ${{ secrets.GITHUB_TOKEN }} | docker login docker.pkg.github.com -u $GITHUB_ACTOR --password-stdin UBUNTU_VERSION=jammy docker pull docker.pkg.github.com/$GITHUB_REPOSITORY/build-cache-no-buildkit || true docker build -f docker/ubuntu.dockerfile . -t thing --cache-from=docker.pkg.github.com/$GITHUB_REPOSITORY/build-cache-no-buildkit docker tag ubuntu-cache docker.pkg.github.com/$GITHUB_REPOSITORY/build-cache-no-buildkit && docker push docker.pkg.github.com/$GITHUB_REPOSITORY/build-cache-no-buildkit || true - rm -f Makefile - make build-shell From 117bea3ea2082965db71a799a73b445321cb7299 Mon Sep 17 00:00:00 2001 From: randymcmillan Date: Sun, 5 Jun 2022 01:14:34 -0400 Subject: [PATCH 33/39] .github/workflows/c-cpp.yml: make package-all signin --- .github/workflows/c-cpp.yml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/workflows/c-cpp.yml b/.github/workflows/c-cpp.yml index e367af068206..16fcc3d533b1 100644 --- a/.github/workflows/c-cpp.yml +++ b/.github/workflows/c-cpp.yml @@ -183,6 +183,8 @@ jobs: make build-shell user=root make && \ echo ${{ secrets.GITHUB_TOKEN }} | docker login docker.pkg.github.com -u $GITHUB_ACTOR --password-stdin - UBUNTU_VERSION=jammy docker pull docker.pkg.github.com/$GITHUB_REPOSITORY/build-cache-no-buildkit || true - docker build -f docker/ubuntu.dockerfile . -t thing --cache-from=docker.pkg.github.com/$GITHUB_REPOSITORY/build-cache-no-buildkit - docker tag ubuntu-cache docker.pkg.github.com/$GITHUB_REPOSITORY/build-cache-no-buildkit && docker push docker.pkg.github.com/$GITHUB_REPOSITORY/build-cache-no-buildkit || true + echo ${{ secrets.GITHUB_TOKEN }} > ~/GH_TOKEN.txt + make package-all user=root && make package-all user=git + # UBUNTU_VERSION=jammy docker pull docker.pkg.github.com/$GITHUB_REPOSITORY/build-cache-no-buildkit || true + # docker build -f docker/ubuntu.dockerfile . -t thing --cache-from=docker.pkg.github.com/$GITHUB_REPOSITORY/build-cache-no-buildkit + # docker tag ubuntu-cache docker.pkg.github.com/$GITHUB_REPOSITORY/build-cache-no-buildkit && docker push docker.pkg.github.com/$GITHUB_REPOSITORY/build-cache-no-buildkit || true From b8c9883ef7fc5e6e2ac401fa8ef1c2884e9abd17 Mon Sep 17 00:00:00 2001 From: randymcmillan Date: Tue, 7 Jun 2022 12:49:57 -0400 Subject: [PATCH 34/39] workflow: begin make use github runner env variables --- .github/workflows/{c-cpp.yml => statoshi.yml} | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) rename .github/workflows/{c-cpp.yml => statoshi.yml} (91%) diff --git a/.github/workflows/c-cpp.yml b/.github/workflows/statoshi.yml similarity index 91% rename from .github/workflows/c-cpp.yml rename to .github/workflows/statoshi.yml index 16fcc3d533b1..b49306d7a820 100644 --- a/.github/workflows/c-cpp.yml +++ b/.github/workflows/statoshi.yml @@ -1,10 +1,11 @@ -name: C/C++ CI +name: statoshi on: pull_request: branches: #[ master ] - '*' # matches every branch that doesn't contain a '/' - '*/*' # matches every branch containing a single '/' + - '*/*/*' # matches every branch containing a single '/' - '**' # matches every branch - 'master' # includes master - 'main' # includes main @@ -83,6 +84,13 @@ jobs: restore-keys: | ${{ runner.os }}-apt-cache + - name: printenv make + run: | + printenv + make + make help + make report + - name: install libs-1 if: steps.apt-cache.outputs.cache-hit != 'true' run: | @@ -184,7 +192,8 @@ jobs: make && \ echo ${{ secrets.GITHUB_TOKEN }} | docker login docker.pkg.github.com -u $GITHUB_ACTOR --password-stdin echo ${{ secrets.GITHUB_TOKEN }} > ~/GH_TOKEN.txt - make package-all user=root && make package-all user=git + # make package-all user=root && make package-all user=git + # UBUNTU_VERSION=jammy docker pull docker.pkg.github.com/$GITHUB_REPOSITORY/build-cache-no-buildkit || true # UBUNTU_VERSION=jammy docker pull docker.pkg.github.com/$GITHUB_REPOSITORY/build-cache-no-buildkit || true - # docker build -f docker/ubuntu.dockerfile . -t thing --cache-from=docker.pkg.github.com/$GITHUB_REPOSITORY/build-cache-no-buildkit + docker build -f docker/ubuntu.dockerfile . -t thing --cache-from=docker.pkg.github.com/$GITHUB_REPOSITORY/build-cache-no-buildkit # docker tag ubuntu-cache docker.pkg.github.com/$GITHUB_REPOSITORY/build-cache-no-buildkit && docker push docker.pkg.github.com/$GITHUB_REPOSITORY/build-cache-no-buildkit || true From dd6b4fa7e267d0d09f29e22c5b5007b95b080373 Mon Sep 17 00:00:00 2001 From: randymcmillan Date: Tue, 7 Jun 2022 13:27:25 -0400 Subject: [PATCH 35/39] docker/ubuntu.dockerfile: remove second install debconf --- docker/ubuntu.dockerfile | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/docker/ubuntu.dockerfile b/docker/ubuntu.dockerfile index b4327ccc4b97..3d02aca2fb7f 100644 --- a/docker/ubuntu.dockerfile +++ b/docker/ubuntu.dockerfile @@ -4,6 +4,7 @@ apt install -y apt RUN apt-get -y upgrade RUN apt-get -y update ENV DEBIAN_FRONTEND noninteractive +RUN DEBIAN_FRONTEND=noninteractive TZ=Etc/UTC apt-get -y install tzdata RUN apt-get update && apt-get upgrade -y && apt-get install --no-install-recommends -y \ debconf --reinstall \ bsdmainutils socat \ @@ -11,9 +12,7 @@ RUN apt-get update && apt-get upgrade -y && apt-get install --no-install-recomme openssh-client openssh-server \ git make vim python3 python3-pip curl -RUN DEBIAN_FRONTEND=noninteractive TZ=Etc/UTC apt-get -y install tzdata RUN apt-get install -y \ -debconf --reinstall \ locales apt-utils bsdmainutils \ sudo adduser bash-completion \ openssh-client openssh-server \ From d4f0ee01e2af834f8f75757b50e6f2aea1087305 Mon Sep 17 00:00:00 2001 From: randymcmillan Date: Tue, 7 Jun 2022 13:32:33 -0400 Subject: [PATCH 36/39] .github/workflows/statoshi.yml: make init initialize for missing libs --- .github/workflows/statoshi.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/statoshi.yml b/.github/workflows/statoshi.yml index b49306d7a820..ad8652fa3e51 100644 --- a/.github/workflows/statoshi.yml +++ b/.github/workflows/statoshi.yml @@ -94,7 +94,8 @@ jobs: - name: install libs-1 if: steps.apt-cache.outputs.cache-hit != 'true' run: | - make init + sudo make init initialize + echo "check to see what init initialize is missing!!!" sudo \ apt-get install --no-install-recommends -y \ automake \ @@ -135,6 +136,8 @@ jobs: - name: install libs-2 if: steps.apt-cache.outputs.cache-hit != 'true' run: | + sudo make init initialize + echo "check to see what init initialize is missing!!!" sudo \ apt-get install --no-install-recommends -y \ g++-aarch64-linux-gnu \ From e65e926f2a7e6b8785eaa0d8d3b374b9304b6390 Mon Sep 17 00:00:00 2001 From: randymcmillan Date: Tue, 7 Jun 2022 13:38:35 -0400 Subject: [PATCH 37/39] docker/bin/initialize: install recommends for completeness --- docker/bin/initialize | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docker/bin/initialize b/docker/bin/initialize index 0034705f90e2..1913b027faac 100755 --- a/docker/bin/initialize +++ b/docker/bin/initialize @@ -101,7 +101,8 @@ DEBIAN_FRONTEND=noninteractive TZ=Etc/UTC apt-get -y install tzdata if hash apt-get 2>/dev/null; then $SUDO apt-get update - $SUDO apt-get install --no-install-recommends -y \ + # $SUDO apt-get install --no-install-recommends -y \ + $SUDO apt-get install -y \ automake \ binutils \ bsdmainutils \ From ac4c818c6e3707c78b83bfe14ffa729207c5d931 Mon Sep 17 00:00:00 2001 From: randymcmillan Date: Tue, 7 Jun 2022 14:04:19 -0400 Subject: [PATCH 38/39] .github/workflows/statoshi.yml: call make init initialize again! --- .github/workflows/statoshi.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/statoshi.yml b/.github/workflows/statoshi.yml index ad8652fa3e51..1aec69bf5c7e 100644 --- a/.github/workflows/statoshi.yml +++ b/.github/workflows/statoshi.yml @@ -151,6 +151,7 @@ jobs: g++-arm-linux-gnueabihf binutils-arm-linux-gnueabihf \ g++-aarch64-linux-gnu #\ # binutils-aarch64-linux-gnu + sudo make init initialize - name: install statsd run: | sudo -s install -v ./src/statsd_client.h /usr/local/include/ From 6afda3118b64a62b148fd8b1cd7c1ad53214a54e Mon Sep 17 00:00:00 2001 From: "@RandyMcMillan" Date: Wed, 17 Aug 2022 04:07:25 +0100 Subject: [PATCH 39/39] Update statoshi.yml (#1) * Update statoshi.yml * Update statoshi.yml (#2) * Update statoshi.yml * Update ubuntu.dockerfile * Update statoshi.yml * Update ubuntu.dockerfile * Update statoshi.yml --- .github/workflows/statoshi.yml | 10 +++++----- docker/ubuntu.dockerfile | 2 ++ 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/.github/workflows/statoshi.yml b/.github/workflows/statoshi.yml index 1aec69bf5c7e..13b4a6755df0 100644 --- a/.github/workflows/statoshi.yml +++ b/.github/workflows/statoshi.yml @@ -38,10 +38,10 @@ jobs: - uses: actions/cache@v3 with: path: | - ${{ github.workspace }}/depends/sources - key: ${{ runner.os }}-depends-sources + ${{ github.workspace }}/depends + key: ${{ runner.os }}-depends restore-keys: | - ${{ runner.os }}-depends-sources + ${{ runner.os }}-depends - uses: actions/cache@v3 with: @@ -195,9 +195,9 @@ jobs: make build-shell user=root make && \ echo ${{ secrets.GITHUB_TOKEN }} | docker login docker.pkg.github.com -u $GITHUB_ACTOR --password-stdin - echo ${{ secrets.GITHUB_TOKEN }} > ~/GH_TOKEN.txt + # echo ${{ secrets.GITHUB_TOKEN }} > ~/GH_TOKEN.txt # make package-all user=root && make package-all user=git # UBUNTU_VERSION=jammy docker pull docker.pkg.github.com/$GITHUB_REPOSITORY/build-cache-no-buildkit || true # UBUNTU_VERSION=jammy docker pull docker.pkg.github.com/$GITHUB_REPOSITORY/build-cache-no-buildkit || true - docker build -f docker/ubuntu.dockerfile . -t thing --cache-from=docker.pkg.github.com/$GITHUB_REPOSITORY/build-cache-no-buildkit + sudo docker build --build-arg=changeme -f docker/ubuntu.dockerfile . -t thing --cache-from=docker.pkg.github.com/$GITHUB_REPOSITORY/build-cache-no-buildkit # docker tag ubuntu-cache docker.pkg.github.com/$GITHUB_REPOSITORY/build-cache-no-buildkit && docker push docker.pkg.github.com/$GITHUB_REPOSITORY/build-cache-no-buildkit || true diff --git a/docker/ubuntu.dockerfile b/docker/ubuntu.dockerfile index 3d02aca2fb7f..0046901d923e 100644 --- a/docker/ubuntu.dockerfile +++ b/docker/ubuntu.dockerfile @@ -98,6 +98,8 @@ RUN mkdir -p /var/cache/debconf RUN if [ -r ~/.ssh/id_rsa ]; then y | ssh-keygen; fi +ARG PASSWORD=changeme + RUN if [ ${HOST_UID} != 0 ]; then adduser --system --disabled-password --ingroup sudo --home /home/${HOST_USER} --uid ${HOST_UID} ${HOST_USER}; fi RUN echo root:${PASSWORD} | chpasswd RUN echo ${HOST_USER}:${PASSWORD} | chpasswd