Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 20 additions & 13 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,25 @@ YELLOW := $(shell tput -Txterm setaf 3)
RESET := $(shell tput -Txterm sgr0)
ARCH := $(shell uname -m)

# set the arm64 ARCH to amd64 for compatibility reason
# Handle architecture detection and platform settings
ifeq ($(ARCH), arm64)
ARCH := amd64
DOCKER_PLATFORM := linux/arm64
# Use ARM64 specific base images if available, fallback to multi-arch
DOCKER_BASE_arm64 := python:3.8-slim
else ifeq ($(ARCH), x86_64)
DOCKER_PLATFORM := linux/amd64
DOCKER_BASE_amd64 := python:3.8-slim
else
$(error "Architecture \"$(ARCH)\" is unsupported")
endif

# Set the base image based on architecture
DOCKER_BASE := $(DOCKER_BASE_$(ARCH))
BASE_VERSION ?= $(ARCH)-$(VERSION)

# Add platform-specific build args
DOCKER_BUILD_ARGS := --platform $(DOCKER_PLATFORM)

#Set the source of PIP in docker agent image
PIP=pip.conf.bak

Expand Down Expand Up @@ -72,10 +86,6 @@ COMMON_DOCKER_IMAGES = api-engine nginx dashboard
AGENT_DOCKER_IMAGES = ansible kubernetes
DUMMY = .$(IMG_TAG)

ifeq ($(DOCKER_BASE), )
$(error "Architecture \"$(ARCH)\" is unsupported")
endif

# Frontend needed
SLASH:=/
REPLACE_SLASH:=\/
Expand Down Expand Up @@ -216,19 +226,16 @@ stop-docker-compose:
images: api-engine docker-rest-agent fabric dashboard

api-engine:
docker build -t hyperledger/cello-api-engine:latest -f build_image/docker/common/api-engine/Dockerfile.in ./ --platform linux/$(ARCH)
docker build $(DOCKER_BUILD_ARGS) -t hyperledger/cello-api-engine:latest -f build_image/docker/common/api-engine/Dockerfile.in ./

docker-rest-agent:
docker build -t hyperledger/cello-agent-docker:latest -f build_image/docker/agent/docker-rest-agent/Dockerfile.in ./ --build-arg pip=$(PIP) --platform linux/$(ARCH)
docker build $(DOCKER_BUILD_ARGS) -t hyperledger/cello-agent-docker:latest -f build_image/docker/agent/docker-rest-agent/Dockerfile.in ./ --build-arg pip=$(PIP)

fabric:
docker build -t hyperledger/fabric:2.5.10 -f build_image/docker/cello-hlf/Dockerfile build_image/docker/cello-hlf/
docker build $(DOCKER_BUILD_ARGS) -t hyperledger/fabric:2.5.10 -f build_image/docker/cello-hlf/Dockerfile build_image/docker/cello-hlf/

dashboard:
docker build -t hyperledger/cello-dashboard:latest -f build_image/docker/common/dashboard/Dockerfile.in ./



docker build $(DOCKER_BUILD_ARGS) -t hyperledger/cello-dashboard:latest -f build_image/docker/common/dashboard/Dockerfile.in ./

.PHONY: \
all \
Expand Down
12 changes: 6 additions & 6 deletions bootup/docker-compose-files/docker-compose.dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ services:
image: hyperledger/cello-dashboard
container_name: cello-dashboard
ports:
- "${DASHBOARD_SERVICE_PORT}:8081"
- "${DASHBOARD_SERVICE_PORT:-8081}:8081"
networks:
- cello-net
depends_on:
Expand All @@ -32,7 +32,7 @@ services:
ports:
- "5432:5432"
volumes:
- ${CELLO_STORAGE_PATH:-/opt/cello}/pgdata:/var/lib/postgresql/data
- cello-postgres-data:/var/lib/postgresql/data
networks:
- cello-net

Expand All @@ -58,7 +58,7 @@ services:
ports:
- "8080:8080"
volumes:
- ${CELLO_STORAGE_PATH:-/opt/cello}:/opt/cello
- cello-api-engine-data:/opt/cello
networks:
- cello-net
depends_on:
Expand All @@ -77,7 +77,7 @@ services:
- /var/run/docker.sock:/var/run/docker.sock
environment:
- DOCKER_URL=unix://var/run/docker.sock
- STORAGE_PATH=${CELLO_STORAGE_PATH:-/opt/cello}/hyperledger
- STORAGE_PATH=/opt/cello/hyperledger
networks:
- cello-net

Expand All @@ -86,7 +86,7 @@ networks:
name: cello-net

volumes:
cello-api-engine:
cello-postgres:
cello-postgres-data:
cello-api-engine-data:
cello-dashboard:
cello-docker-agent:
28 changes: 21 additions & 7 deletions build_image/docker/agent/docker-rest-agent/Dockerfile.in
Original file line number Diff line number Diff line change
@@ -1,14 +1,28 @@
FROM python:3.8
FROM python:3.8-slim

# Install build dependencies
RUN apt-get update && apt-get install -y \
build-essential \
python3-dev \
libev-dev \
&& rm -rf /var/lib/apt/lists/*

# Copy requirements and pip config
COPY src/agent/docker-rest-agent/requirements.txt /
ARG pip=pip.conf.bak
ARG pip=pip.conf
COPY src/agent/docker-rest-agent/pip.conf /root/.pip/$pip

RUN pip install -r /requirements.txt
RUN mkdir -p /var/www/server
# Install Python dependencies with pinned gevent version
RUN pip install --no-cache-dir --upgrade pip && \
pip install --no-cache-dir "gevent==22.10.2" && \
pip install --no-cache-dir -r /requirements.txt

COPY src/agent/docker-rest-agent/server.py /var/www/server
COPY src/agent/docker-rest-agent/gunicorn.conf.py /var/www/server
# Create server directory and copy files
RUN mkdir -p /var/www/server
COPY src/agent/docker-rest-agent/server.py /var/www/server/
COPY src/agent/docker-rest-agent/gunicorn.conf.py /var/www/server/

WORKDIR /var/www/server

CMD ["gunicorn", "server:app", "-c", "./gunicorn.conf.py"]
# Run the server
CMD ["gunicorn", "--config", "gunicorn.conf.py", "server:app"]
30 changes: 25 additions & 5 deletions build_image/docker/common/api-engine/Dockerfile.in
Original file line number Diff line number Diff line change
@@ -1,8 +1,19 @@
FROM python:3.8
FROM python:3.8-slim

# Install software
# Install software including PostgreSQL development packages and pkg-config for pygraphviz
RUN apt-get update \
&& apt-get install -y gettext-base graphviz libgraphviz-dev vim \
&& apt-get install -y \
gettext-base \
graphviz \
libgraphviz-dev \
pkg-config \
vim \
curl \
postgresql \
postgresql-client \
libpq-dev \
gcc \
python3-dev \
&& apt-get autoclean \
&& apt-get clean \
&& apt-get autoremove && rm -rf /var/cache/apt/
Expand All @@ -11,14 +22,23 @@ RUN apt-get update \
WORKDIR /var/www/server

# Install compiled code tools from Artifactory and copy it to opt folder.
RUN curl -L --retry 5 --retry-delay 3 "https://github.com/hyperledger/fabric/releases/download/v2.5.10/hyperledger-fabric-linux-amd64-2.5.10.tar.gz" | tar xz -C /opt/
# Use platform-specific Fabric binary
ARG TARGETARCH
RUN if [ "$TARGETARCH" = "arm64" ]; then \
curl -L --retry 5 --retry-delay 3 "https://github.com/hyperledger/fabric/releases/download/v2.5.10/hyperledger-fabric-linux-arm64-2.5.10.tar.gz" | tar xz -C /opt/; \
else \
curl -L --retry 5 --retry-delay 3 "https://github.com/hyperledger/fabric/releases/download/v2.5.10/hyperledger-fabric-linux-amd64-2.5.10.tar.gz" | tar xz -C /opt/; \
fi

# Copy source code to the working dir
COPY src/api-engine ./
COPY template/node /opt/node

# Install python dependencies
RUN pip3 install -r requirements.txt
# First upgrade pip to latest version
RUN pip3 install --no-cache-dir --upgrade pip && \
pip3 install --no-cache-dir psycopg2-binary==2.8.4 && \
pip3 install --no-cache-dir -r requirements.txt

# Add uwsgi configuration file
COPY build_image/docker/common/api-engine/server.ini /etc/uwsgi/apps-enabled/
Expand Down
6 changes: 3 additions & 3 deletions src/api-engine/api/lib/configtxgen/configtx.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,11 @@ def create(self, name, consensus, orderers, peers, orderer_cfg=None, application
for orderer in orderers:
OrdererMSP = "OrdererMSP"
OrdererOrg = dict(Name="Orderer",
ID= OrdererMSP,
ID=OrdererMSP,
MSPDir='{}/{}/crypto-config/ordererOrganizations/{}/msp'.format(self.filepath, orderer["name"], orderer['name'].split(".", 1)[1]),
Policies=dict(Readers=dict(Type="Signature", Rule="OR('{}.member')".format(OrdererMSP)),
Writers=dict(Type="Signature", Rule="OR('{}.member')".format(OrdererMSP)),
Admins=dict(Type="Signature", Rule="OR('{}.admin')".format(OrdererMSP)))
Writers=dict(Type="Signature", Rule="OR('{}.member')".format(OrdererMSP)),
Admins=dict(Type="Signature", Rule="OR('{}.admin')".format(OrdererMSP)))
)
for host in orderer['hosts']:
OrdererAddress.append('{}.{}:{}'.format(host['name'], orderer['name'].split(".", 1)[1], 7050))
Expand Down
4 changes: 2 additions & 2 deletions src/api-engine/api/lib/configtxgen/configtxgen.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def genesis(self, profile="", channelid="", outputblock="genesis.block"):

except subprocess.CalledProcessError as e:
err_msg = "configtxgen genesis fail! "
raise Exception(err_msg+str(e))
raise Exception(err_msg + str(e))

except Exception as e:
err_msg = "configtxgen genesis fail! "
Expand All @@ -62,4 +62,4 @@ def anchorpeer(self, profile, channelid, outputblock):
outputblock: outputblock
return:
"""
pass
pass
7 changes: 4 additions & 3 deletions src/api-engine/api/lib/configtxlator/configtxlator.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import logging
LOG = logging.getLogger(__name__)


class ConfigTxLator:
"""
Class represents configtxlator CLI.
Expand All @@ -32,7 +33,7 @@ def proto_encode(self, input, type, output):
"--type={}".format(type),
"--output={}".format(output),
]

LOG.info(" ".join(command))

call(command)
Expand All @@ -57,7 +58,7 @@ def proto_decode(self, input, type, output):
"--input={}".format(input),
"--output={}".format(output),
]

LOG.info(" ".join(command))

call(command)
Expand Down Expand Up @@ -85,7 +86,7 @@ def compute_update(self, original, updated, channel_id, output):
"--channel_id={}".format(channel_id),
"--output={}".format(output),
]

LOG.info(" ".join(command))

call(command)
Expand Down
7 changes: 4 additions & 3 deletions src/api-engine/api/lib/peer/chaincode.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

LOG = logging.getLogger(__name__)


class ChainCode(Command):
def __init__(self, version=FABRIC_VERSION, peer=FABRIC_TOOL, **kwargs):
self.peer = peer + "/peer"
Expand Down Expand Up @@ -71,7 +72,7 @@ def lifecycle_query_installed(self, timeout):
]
LOG.info(" ".join(command))
res = subprocess.Popen(command, shell=False,
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
stdout=subprocess.PIPE, stderr=subprocess.PIPE)

stdout, stderr = res.communicate()
return_code = res.returncode
Expand Down Expand Up @@ -164,7 +165,7 @@ def lifecycle_approve_for_my_org(self, orderer_url, channel_name, cc_name,
"--tls",
"--cafile", ORDERER_CA
]

if init_flag:
command.append("--init-required")
if policy:
Expand Down Expand Up @@ -455,4 +456,4 @@ def lifecycle_calculatepackageid(self, cc_path):
return return_code, stderr
except Exception as e:
err_msg = "calculated chaincode packageid failed for {}!".format(e)
raise Exception(err_msg)
raise Exception(err_msg)
4 changes: 2 additions & 2 deletions src/api-engine/api/lib/peer/channel.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,13 @@ def create(self, channel, orderer_admin_url, block_path, time_out="90s"):
]

LOG.info(" ".join(command))

res = subprocess.run(command, check=True)

except subprocess.CalledProcessError as e:
err_msg = "create channel failed for {}!".format(e)
raise Exception(err_msg+str(e))

except Exception as e:
err_msg = "create channel failed for {}!".format(e)
raise Exception(err_msg)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Generated by Django 4.2.16 on 2025-05-27 20:02

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('api', '0002_alter_agent_name_alter_network_name'),
]

operations = [
migrations.AlterField(
model_name='agent',
name='name',
field=models.CharField(default='agent-fbfa4c2afb5d4f649e63d694fa7815c5', help_text='Agent name, can be generated automatically.', max_length=64),
),
migrations.AlterField(
model_name='network',
name='name',
field=models.CharField(default='netowrk-f2b8908f8a074896985b01bde0a2cb0e', help_text='network name, can be generated automatically.', max_length=64),
),
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Generated by Django 4.2.16 on 2025-05-27 20:08

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('api', '0003_alter_agent_name_alter_network_name'),
]

operations = [
migrations.AlterField(
model_name='agent',
name='name',
field=models.CharField(default='agent-cecf0eedaed740a385aef90f256e51bf', help_text='Agent name, can be generated automatically.', max_length=64),
),
migrations.AlterField(
model_name='network',
name='name',
field=models.CharField(default='netowrk-bb67b507991f4bd1b5402414769d7274', help_text='network name, can be generated automatically.', max_length=64),
),
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Generated by Django 4.2.16 on 2025-05-31 10:51

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('api', '0004_alter_agent_name_alter_network_name'),
]

operations = [
migrations.AlterField(
model_name='agent',
name='name',
field=models.CharField(default='agent-e603b14257cf4c2ebe08ab2e7bc7380e', help_text='Agent name, can be generated automatically.', max_length=64),
),
migrations.AlterField(
model_name='network',
name='name',
field=models.CharField(default='netowrk-e468644f181d4a3181e6558a37672762', help_text='network name, can be generated automatically.', max_length=64),
),
]
Loading
Loading