From ba3727c5cd2a2c335fdb3ea1921f20a0cdb5e11d Mon Sep 17 00:00:00 2001 From: Yann Autissier Date: Mon, 9 May 2022 02:32:23 +0200 Subject: [PATCH] ipfs on arm --- Makefile | 20 +++++++++++++++++++- docker/ipfs/Dockerfile | 9 +++++++++ docker/ipfs/ipfs-config.sh | 11 +++++++++++ make/apps/common.mk | 21 +++------------------ make/apps/myos/def.setup.mk | 2 +- make/apps/myos/setup.mk | 2 +- make/def.mk | 11 +++-------- stack/node.mk | 4 +++- stack/node/node.yml | 9 ++++++++- 9 files changed, 58 insertions(+), 31 deletions(-) create mode 100644 docker/ipfs/Dockerfile create mode 100644 docker/ipfs/ipfs-config.sh diff --git a/Makefile b/Makefile index 09cb37a..c6c92e1 100644 --- a/Makefile +++ b/Makefile @@ -3,7 +3,7 @@ include make/include.mk ## # APP -app-bootstrap: setup-binfmt setup-nfsd setup-sysctl +app-bootstrap: bootstrap-docker bootstrap-host bootstrap-user app-build: user install-build-config $(call make,docker-compose-build docker-compose-up) @@ -15,3 +15,21 @@ app-install: ansible-run app-tests: ansible-tests app-start: ssh-add + +## +# BOOTSTRAP + +# target bootstrap-docker: Install and configure docker +# on local host +.PHONY: bootstrap-docker +bootstrap-docker: install-bin-docker setup-docker-group setup-binfmt setup-nfsd setup-sysctl + +# target bootstrap-host: Fire node target +# on local host +.PHONY: bootstrap-host +bootstrap-host: node + +# target bootstrap-user: Fire User target +# on local host +.PHONY: bootstrap-user +bootstrap-user: User diff --git a/docker/ipfs/Dockerfile b/docker/ipfs/Dockerfile new file mode 100644 index 0000000..35c0ac1 --- /dev/null +++ b/docker/ipfs/Dockerfile @@ -0,0 +1,9 @@ +FROM ipfs/go-ipfs:v0.13.0-rc1 as dist +LABEL maintainer aynic.os +ARG DOCKER_BUILD_DIR + +COPY ${DOCKER_BUILD_DIR}/*.sh /container-init.d/ +RUN chmod +rx /container-init.d/*.sh + +FROM dist as master +ARG DOCKER_BUILD_DIR diff --git a/docker/ipfs/ipfs-config.sh b/docker/ipfs/ipfs-config.sh new file mode 100644 index 0000000..0effb7a --- /dev/null +++ b/docker/ipfs/ipfs-config.sh @@ -0,0 +1,11 @@ +#!/bin/sh + +## fix following error on arm64/linux with 2Gb RAM +# ERROR p2pnode libp2p/rcmgr_defaults.go:107 ===> OOF! go-libp2p changed DefaultServiceLimits +# => changes ('test' represents the old value): +# {"op":"test","path":"/SystemLimits/Memory","value":1073741824} +# {"op":"replace","path":"/SystemLimits/Memory","value":256560128} +# => go-libp2p SetDefaultServiceLimits update needs a review: +# Please inspect if changes impact go-ipfs users, and update expectedDefaultServiceLimits in rcmgr_defaults.go to remove this message +# FATAL p2pnode libp2p/rcmgr_defaults.go:115 daemon will refuse to run with the resource manager until this is resolved +ipfs config --json Swarm.ResourceMgr.Enabled false diff --git a/make/apps/common.mk b/make/apps/common.mk index 9ffacb2..7610a59 100644 --- a/make/apps/common.mk +++ b/make/apps/common.mk @@ -3,28 +3,13 @@ # target bootstrap: Update application files and start dockers # on local host -.PHONY: bootstrap -bootstrap: bootstrap-app bootstrap-host bootstrap-user app-bootstrap ## Update application files and start dockers +.PHONY: bootstrap app-bootstrap +bootstrap: bootstrap-app app-bootstrap ## Update application files and start dockers # target bootstrap-app: Fire install-bin-git .PHONY: bootstrap-app bootstrap-app: install-bin-git -# target bootstrap-docker: Install and configure docker -# on local host -.PHONY: bootstrap-docker -bootstrap-docker: install-bin-docker setup-docker-group setup-sysctl - -# target bootstrap-host: Fire node target -# on local host -.PHONY: bootstrap-host -bootstrap-host: node - -# target bootstrap-user: Fire User target -# on local host -.PHONY: bootstrap-user -bootstrap-user: User - # target build: Build application docker images to run # on local host .PHONY: build @@ -180,7 +165,7 @@ stack: # target stack-%: Call docker-compose-% target on STACK ## it splits % on dashes and extracts stack from the beginning and command from ## the last part of % -## ex: stack-User-up will fire the docker-compose-up target in the User stack +## ex: stack-node-up will fire the docker-compose-up target in the node stack .PHONY: stack-% stack-%: $(eval stack := $(subst -$(lastword $(subst -, ,$*)),,$*)) diff --git a/make/apps/myos/def.setup.mk b/make/apps/myos/def.setup.mk index 81c39bc..b1749b3 100644 --- a/make/apps/myos/def.setup.mk +++ b/make/apps/myos/def.setup.mk @@ -1,5 +1,5 @@ ENV_VARS += SETUP_SYSCTL_CONFIG -SETUP_BINFMT ?= false +SETUP_BINFMT ?= $(if $(filter-out amd64 x86_64,$(PROCESSOR_ARCHITECTURE)),true,false) SETUP_BINFMT_ARCH ?= all SETUP_NFSD ?= false SETUP_NFSD_OSX_CONFIG ?= nfs.server.bonjour=0 nfs.server.mount.regular_files=1 nfs.server.mount.require_resv_port=0 nfs.server.nfsd_threads=16 nfs.server.async=1 diff --git a/make/apps/myos/setup.mk b/make/apps/myos/setup.mk index 9bc0304..a706e76 100644 --- a/make/apps/myos/setup.mk +++ b/make/apps/myos/setup.mk @@ -27,7 +27,7 @@ endif .PHONY: setup-sysctl setup-sysctl: ifeq ($(SETUP_SYSCTL),true) - $(SUDO) sysctl -q -w $(SETUP_SYSCTL_CONFIG) + $(RUN) $(SUDO) sysctl -q -w $(SETUP_SYSCTL_CONFIG) endif # target setup-binfmt: Install binfmt abstraction layer diff --git a/make/def.mk b/make/def.mk index 8e7c35e..0932ba8 100644 --- a/make/def.mk +++ b/make/def.mk @@ -69,7 +69,7 @@ GIT_VERSION ?= $(shell git describe --tags $(BRANCH) 2>/dev/ HOSTNAME ?= $(shell hostname 2>/dev/null |sed 's/\..*//') IGNORE_DRYRUN ?= false IGNORE_VERBOSE ?= false -INSTALL ?= $(SUDO) $(subst &&,&& $(SUDO),$(INSTALL_CMD)) +INSTALL ?= $(RUN) $(SUDO) $(subst &&,&& $(RUN) $(SUDO),$(INSTALL_CMD)) INSTALL_CMDS ?= APK_INSTALL APT_INSTALL $(foreach cmd,$(INSTALL_CMDS),$(if $(CMD_$(cmd)),$(eval INSTALL_CMD ?= $(CMD_$(cmd))))) LOG_LEVEL ?= $(if $(DEBUG),debug,$(if $(VERBOSE),info,error)) @@ -126,13 +126,8 @@ OPERATING_SYSTEM := cygwin else ifeq ($(OS),Windows_NT) OPERATING_SYSTEM := Windows_NT else -UNAME_S := $(shell uname -s 2>/dev/null) -ifeq ($(UNAME_S),Linux) -OPERATING_SYSTEM := Linux -endif -ifeq ($(UNAME_S),Darwin) -OPERATING_SYSTEM := Darwin -endif +PROCESSOR_ARCHITECTURE := $(shell uname -m 2>/dev/null) +OPERATING_SYSTEM := $(shell uname -s 2>/dev/null) endif ifeq ($(OPERATING_SYSTEM),Darwin) diff --git a/stack/node.mk b/stack/node.mk index 325a4ab..26b1132 100644 --- a/stack/node.mk +++ b/stack/node.mk @@ -1,4 +1,6 @@ -ENV_VARS += DOCKER_HOST_IFACE DOCKER_HOST_INET +ENV_VARS += DOCKER_HOST_IFACE DOCKER_HOST_INET IPFS_PROFILE + +IPFS_PROFILE ?= $(if $(filter-out amd64 x86_64,$(PROCESSOR_ARCHITECTURE)),lowpower,server) # target node: Fire docker-network-create-% for DOCKER_NETWORK_PUBLIC node-ssl-certs stack-node-up .PHONY: node diff --git a/stack/node/node.yml b/stack/node/node.yml index a8574ca..83aa626 100644 --- a/stack/node/node.yml +++ b/stack/node/node.yml @@ -65,7 +65,14 @@ services: volumes: - ssl-certs:/certs ipfs: - image: ipfs/go-ipfs:latest + build: + args: + - DOCKER_BUILD_DIR=docker/ipfs + context: ../.. + dockerfile: docker/ipfs/Dockerfile + image: ${DOCKER_REPOSITORY_NODE}/ipfs:${DOCKER_IMAGE_TAG} + environment: + - IPFS_PROFILE=${IPFS_PROFILE} labels: - SERVICE_4001_NAME=${COMPOSE_SERVICE_NAME}-ipfs-4001 - SERVICE_5001_NAME=${COMPOSE_SERVICE_NAME}-ipfs-5001