Skip to content

Commit e5c2779

Browse files
sangwaboiVishvendra
authored andcommitted
feat: add Apple Silicon (M1/M2/M3) support - Update Dockerfiles for ARM64, fix build dependencies, use named volumes
Signed-off-by: Vishvendra <[email protected]>
1 parent ae81505 commit e5c2779

File tree

4 files changed

+72
-31
lines changed

4 files changed

+72
-31
lines changed

Makefile

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,25 @@ YELLOW := $(shell tput -Txterm setaf 3)
2929
RESET := $(shell tput -Txterm sgr0)
3030
ARCH := $(shell uname -m)
3131

32-
# set the arm64 ARCH to amd64 for compatibility reason
32+
# Handle architecture detection and platform settings
3333
ifeq ($(ARCH), arm64)
34-
ARCH := amd64
34+
DOCKER_PLATFORM := linux/arm64
35+
# Use ARM64 specific base images if available, fallback to multi-arch
36+
DOCKER_BASE_arm64 := python:3.8-slim
37+
else ifeq ($(ARCH), x86_64)
38+
DOCKER_PLATFORM := linux/amd64
39+
DOCKER_BASE_amd64 := python:3.8-slim
40+
else
41+
$(error "Architecture \"$(ARCH)\" is unsupported")
3542
endif
3643

44+
# Set the base image based on architecture
45+
DOCKER_BASE := $(DOCKER_BASE_$(ARCH))
46+
BASE_VERSION ?= $(ARCH)-$(VERSION)
47+
48+
# Add platform-specific build args
49+
DOCKER_BUILD_ARGS := --platform $(DOCKER_PLATFORM)
50+
3751
#Set the source of PIP in docker agent image
3852
PIP=pip.conf.bak
3953

@@ -72,10 +86,6 @@ COMMON_DOCKER_IMAGES = api-engine nginx dashboard
7286
AGENT_DOCKER_IMAGES = ansible kubernetes
7387
DUMMY = .$(IMG_TAG)
7488

75-
ifeq ($(DOCKER_BASE), )
76-
$(error "Architecture \"$(ARCH)\" is unsupported")
77-
endif
78-
7989
# Frontend needed
8090
SLASH:=/
8191
REPLACE_SLASH:=\/
@@ -216,19 +226,16 @@ stop-docker-compose:
216226
images: api-engine docker-rest-agent fabric dashboard
217227

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

221231
docker-rest-agent:
222-
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)
232+
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)
223233

224234
fabric:
225-
docker build -t hyperledger/fabric:2.5.10 -f build_image/docker/cello-hlf/Dockerfile build_image/docker/cello-hlf/
235+
docker build $(DOCKER_BUILD_ARGS) -t hyperledger/fabric:2.5.10 -f build_image/docker/cello-hlf/Dockerfile build_image/docker/cello-hlf/
226236

227237
dashboard:
228-
docker build -t hyperledger/cello-dashboard:latest -f build_image/docker/common/dashboard/Dockerfile.in ./
229-
230-
231-
238+
docker build $(DOCKER_BUILD_ARGS) -t hyperledger/cello-dashboard:latest -f build_image/docker/common/dashboard/Dockerfile.in ./
232239

233240
.PHONY: \
234241
all \

bootup/docker-compose-files/docker-compose.dev.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ services:
1414
image: hyperledger/cello-dashboard
1515
container_name: cello-dashboard
1616
ports:
17-
- "${DASHBOARD_SERVICE_PORT}:8081"
17+
- "${DASHBOARD_SERVICE_PORT:-8081}:8081"
1818
networks:
1919
- cello-net
2020
depends_on:
@@ -32,7 +32,7 @@ services:
3232
ports:
3333
- "5432:5432"
3434
volumes:
35-
- ${CELLO_STORAGE_PATH:-/opt/cello}/pgdata:/var/lib/postgresql/data
35+
- cello-postgres-data:/var/lib/postgresql/data
3636
networks:
3737
- cello-net
3838

@@ -58,7 +58,7 @@ services:
5858
ports:
5959
- "8080:8080"
6060
volumes:
61-
- ${CELLO_STORAGE_PATH:-/opt/cello}:/opt/cello
61+
- cello-api-engine-data:/opt/cello
6262
networks:
6363
- cello-net
6464
depends_on:
@@ -77,7 +77,7 @@ services:
7777
- /var/run/docker.sock:/var/run/docker.sock
7878
environment:
7979
- DOCKER_URL=unix://var/run/docker.sock
80-
- STORAGE_PATH=${CELLO_STORAGE_PATH:-/opt/cello}/hyperledger
80+
- STORAGE_PATH=/opt/cello/hyperledger
8181
networks:
8282
- cello-net
8383

@@ -86,7 +86,7 @@ networks:
8686
name: cello-net
8787

8888
volumes:
89-
cello-api-engine:
90-
cello-postgres:
89+
cello-postgres-data:
90+
cello-api-engine-data:
9191
cello-dashboard:
9292
cello-docker-agent:
Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,28 @@
1-
FROM python:3.8
1+
FROM python:3.8-slim
2+
3+
# Install build dependencies
4+
RUN apt-get update && apt-get install -y \
5+
build-essential \
6+
python3-dev \
7+
libev-dev \
8+
&& rm -rf /var/lib/apt/lists/*
9+
10+
# Copy requirements and pip config
211
COPY src/agent/docker-rest-agent/requirements.txt /
3-
ARG pip=pip.conf.bak
12+
ARG pip=pip.conf
413
COPY src/agent/docker-rest-agent/pip.conf /root/.pip/$pip
514

6-
RUN pip install -r /requirements.txt
7-
RUN mkdir -p /var/www/server
15+
# Install Python dependencies with pinned gevent version
16+
RUN pip install --no-cache-dir --upgrade pip && \
17+
pip install --no-cache-dir "gevent==22.10.2" && \
18+
pip install --no-cache-dir -r /requirements.txt
819

9-
COPY src/agent/docker-rest-agent/server.py /var/www/server
10-
COPY src/agent/docker-rest-agent/gunicorn.conf.py /var/www/server
20+
# Create server directory and copy files
21+
RUN mkdir -p /var/www/server
22+
COPY src/agent/docker-rest-agent/server.py /var/www/server/
23+
COPY src/agent/docker-rest-agent/gunicorn.conf.py /var/www/server/
1124

1225
WORKDIR /var/www/server
1326

14-
CMD ["gunicorn", "server:app", "-c", "./gunicorn.conf.py"]
27+
# Run the server
28+
CMD ["gunicorn", "--config", "gunicorn.conf.py", "server:app"]

build_image/docker/common/api-engine/Dockerfile.in

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,19 @@
1-
FROM python:3.8
1+
FROM python:3.8-slim
22

3-
# Install software
3+
# Install software including PostgreSQL development packages and pkg-config for pygraphviz
44
RUN apt-get update \
5-
&& apt-get install -y gettext-base graphviz libgraphviz-dev vim \
5+
&& apt-get install -y \
6+
gettext-base \
7+
graphviz \
8+
libgraphviz-dev \
9+
pkg-config \
10+
vim \
11+
curl \
12+
postgresql \
13+
postgresql-client \
14+
libpq-dev \
15+
gcc \
16+
python3-dev \
617
&& apt-get autoclean \
718
&& apt-get clean \
819
&& apt-get autoremove && rm -rf /var/cache/apt/
@@ -11,14 +22,23 @@ RUN apt-get update \
1122
WORKDIR /var/www/server
1223

1324
# Install compiled code tools from Artifactory and copy it to opt folder.
14-
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/
25+
# Use platform-specific Fabric binary
26+
ARG TARGETARCH
27+
RUN if [ "$TARGETARCH" = "arm64" ]; then \
28+
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/; \
29+
else \
30+
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/; \
31+
fi
1532

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

2037
# Install python dependencies
21-
RUN pip3 install -r requirements.txt
38+
# First upgrade pip to latest version
39+
RUN pip3 install --no-cache-dir --upgrade pip && \
40+
pip3 install --no-cache-dir psycopg2-binary==2.8.4 && \
41+
pip3 install --no-cache-dir -r requirements.txt
2242

2343
# Add uwsgi configuration file
2444
COPY build_image/docker/common/api-engine/server.ini /etc/uwsgi/apps-enabled/

0 commit comments

Comments
 (0)