diff --git a/.github/workflows/dockerimage.yml.disable b/.github/workflows/dockerimage.yml.disable new file mode 100644 index 000000000000..a93e93ac2d90 --- /dev/null +++ b/.github/workflows/dockerimage.yml.disable @@ -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/.github/workflows/statoshi.yml b/.github/workflows/statoshi.yml new file mode 100644 index 000000000000..13b4a6755df0 --- /dev/null +++ b/.github/workflows/statoshi.yml @@ -0,0 +1,203 @@ +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 + # 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: styfle/cancel-workflow-action@0.9.1 + with: + access_token: ${{ github.token }} + - 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: | + ${{ github.workspace }}/src/bitcoind + 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 + + - uses: actions/cache@v3 + with: + path: | + ${{ github.workspace }}/src/*.a + key: ${{ runner.os }}-src-a + restore-keys: | + ${{ runner.os }}-src-a + + - uses: actions/cache@v3 + id: apt-cache + with: + path: | + ${{ github.workspace }}/var/cache/apt/archives + key: ${{ runner.os }}-apt-cache + 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: | + sudo make init initialize + echo "check to see what init initialize is missing!!!" + 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 + + # Split cross-compilers out. + # apt cant install everything at once + - 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 \ + 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 + sudo make init initialize + - name: install statsd + run: | + sudo -s install -v ./src/statsd_client.h /usr/local/include/ + sudo -s install -v ./src/statsd_client.cpp /usr/local/include/ + - name: make download -C depends + run: | + cd depends + 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 + - name: configure + 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 \ + --disable-wallet \ + --disable-tests \ + --disable-bench \ + --disable-man \ + --with-gui=no \ + --enable-reduce-exports LDFLAGS=-static-libstdc++ + - name: HOST=aarch64-linux-gnu NO_QT=1 make + run: | + # make check + # make check HOST=arm-linux-gnueabihf NO_QT=1 + HOST=aarch64-linux-gnu NO_QT=1 make + + - name: make install + run: | + 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 + # 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 + 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/.gitignore b/.gitignore index 6c888bfdc46e..307e49ff839a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +bitcoin-* *.tar.gz *.exe diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 000000000000..097174663a07 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,23 @@ +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 +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 +# test +# test +# test +# test +# test +# test +# test + diff --git a/GNUmakefile b/GNUmakefile new file mode 100644 index 000000000000..7874519e431b --- /dev/null +++ b/GNUmakefile @@ -0,0 +1,413 @@ +SHELL := /bin/bash +NOHUP := $(shell which nohup) + +PWD ?= pwd_unknown + +THIS_FILE := $(lastword $(MAKEFILE_LIST)) +export THIS_FILE +TIME := $(shell date +%s) +export TIME + +ARCH :=$(shell uname -m) +export ARCH +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 +#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 + + +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 := $(notdir $(PWD)) +else +PROJECT_NAME := $(project) +endif +export PROJECT_NAME + +ifeq ($(user),root) +HOST_USER := root +HOST_UID := $(strip $(if $(uid),$(uid),0)) +else +#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 +ifneq ($(uid),) +HOST_UID := $(uid) +endif + +ifeq ($(ssh-pkey),) +SSH_PRIVATE_KEY := $(HOME)/.ssh/id_rsa +else +SSH_PRIVATE_KEY := $(ssh-pkey) +endif +export SSH_PRIVATE_KEY + +ifeq ($(alpine),) +ALPINE_VERSION := 3.15 +else +ALPINE_VERSION := $(alpine) +endif +export ALPINE_VERSION + +ifeq ($(dind),) +DIND_VERSION := 20.10.16 +else +DIND_VERSION := $(dind) +endif +export DIND_VERSION + +ifeq ($(debian),) +DEBIAN_VERSION := bookworm +else +DEBIAN_VERSION := $(debian) +endif +export DEBIAN_VERSION + +ifeq ($(ubuntu),) +UBUNTU_VERSION := jammy +else +UBUNTU_VERSION := $(ubuntu) +endif +export UBUNTU_VERSION + +ifeq ($(nocache),true) +NO_CACHE := --no-cache +else +NO_CACHE := +endif +export NO_CACHE + +ifeq ($(verbose),true) +VERBOSE := --verbose +else +VERBOSE := +endif +export VERBOSE + +ifneq ($(passwd),) +PASSWORD := $(passwd) +else +PASSWORD := changeme +endif +export PASSWORD + +ifneq ($(cmd),) +CMD_ARGUMENTS := $(cmd) +else +CMD_ARGUMENTS := +endif +export CMD_ARGUMENTS + +ifeq ($(private),true) +PRIVATE := true +else +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=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:bitcoincore-dev/$(PROJECT_NAME).git) +GIT_PROFILE :=bitcoinccore-dev +endif +ifeq ($(GIT_REPO_ORIGIN),https://github.com/$(GITHUB_USER_NAME)/$(PROJECT_NAME).git) +GIT_PROFILE :=$(GITHUB_USER_NAME) +endif +else +GIT_PROFILE :=$(profile) +endif +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 + +PACKAGE_PREFIX := ghcr.io +export PACKAGE_PREFIX + +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: report +report:## report + @echo '' + @echo ' [ARGUMENTS] ' + @echo ' args:' + @echo ' - THIS_FILE=${THIS_FILE}' + @echo ' - TIME=${TIME}' + @echo ' - PROJECT_NAME=${PROJECT_NAME}' + @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 ' - UBUNTU_VERSION=${UBUNTU_VERSION}' + @echo ' - PORT=${PORT}' + @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}' + +.PHONY: init initialize docs +initialize:## initialize + docker/bin/initialize +init: initialize## init + +run: shell + $(NOHUP) $(DOCKER_COMPOSE) $(VERBOSE) up -d + +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) -p $(PROJECT_NAME)_$(HOST_UID) run -it --rm ${SERVICE_TARGET} bash +else + $(DOCKER_COMPOSE) $(VERBOSE) -p $(PROJECT_NAME)_$(HOST_UID) run -dit --rm $(SERVICE_TARGET) bash -c "$(CMD_ARGUMENTS)" +endif + +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" + +# 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 + +.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 diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 000000000000..af28e5d949fd --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,34 @@ +--- +version: '3.4' +networks: {} +services: + + ubuntu: + container_name: ${PROJECT_NAME}_${HOST_UID:-4000} + hostname: ${PROJECT_NAME}_${HOST_UID:-4000} + environment: + - UID=${HOST_UID:-4000} + user: ${HOST_USER:-nodummy} + image: ${PROJECT_NAME}:${HOST_USER:-nodummy} + privileged: true + build: + context: . + target: base + dockerfile: docker/ubuntu.dockerfile + args: + - HOST_UID=${HOST_UID:-4000} + - HOST_USER=${HOST_USER:-nodummy} + - SSH_PRIVATE_KEY=${SSH_PRIVATE_KEY} + - PASSWORD=${PASSWORD} + - UBUNTU_VERSION=${UBUNTU_VERSION} + command: ["ssh-agent ssh-add"] + volumes: + - 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/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/initialize b/docker/bin/initialize new file mode 100755 index 000000000000..1913b027faac --- /dev/null +++ b/docker/bin/initialize @@ -0,0 +1,273 @@ +#!/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 \ + $SUDO apt-get install -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 + 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 new file mode 100644 index 000000000000..0046901d923e --- /dev/null +++ b/docker/ubuntu.dockerfile @@ -0,0 +1,125 @@ +FROM ubuntu:jammy as base +RUN set -xe; \ +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 \ + apt-utils sudo adduser bash-completion \ + openssh-client openssh-server \ + git make vim python3 python3-pip curl + +RUN apt-get install -y \ +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 + +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 +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 [ "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 [ "./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"] + diff --git a/statoshi.dockerfile b/statoshi.dockerfile new file mode 100644 index 000000000000..20456c06dbce --- /dev/null +++ b/statoshi.dockerfile @@ -0,0 +1,148 @@ +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 \ + automake \ + autoconf \ + 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} +############################ +VOLUME /tmp/statoshi +WORKDIR /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/* +############################ +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"] +