Skip to content

Commit 507b9e3

Browse files
committed
improved Dockerfile and scripts to build image
Signed-off-by: pco <pasquale.convertini@ibm.com>
1 parent eba5d35 commit 507b9e3

7 files changed

Lines changed: 59 additions & 24 deletions

File tree

.github/workflows/docker-release.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,10 @@ jobs:
8888
BIN=committer
8989
ARCHBIN_PATH=archbin
9090
PORTS=4001 2114 9001 2119 5001 2115 6001 2116 7001 2117
91+
VERSION=${{ env.VERSION }}
9192
cache-from: type=registry,ref=docker.io/${{ env.IMAGE_PREFIX }}/fabric-x-committer:buildcache
9293
cache-to: type=registry,ref=docker.io/${{ env.IMAGE_PREFIX }}/fabric-x-committer:buildcache,mode=max
93-
94+
9495
- name: Build and Push Multi-Platform Docker Image for Loadgen
9596
uses: docker/build-push-action@v6
9697
with:
@@ -107,6 +108,7 @@ jobs:
107108
BIN=loadgen
108109
ARCHBIN_PATH=archbin
109110
PORTS=8001 2118
111+
VERSION=${{ env.VERSION }}
110112
cache-from: type=registry,ref=docker.io/${{ env.IMAGE_PREFIX }}/fabric-x-loadgen:buildcache
111113
cache-to: type=registry,ref=docker.io/${{ env.IMAGE_PREFIX }}/fabric-x-loadgen:buildcache,mode=max
112114

@@ -124,5 +126,6 @@ jobs:
124126
ghcr.io/${{ env.GHCR_PREFIX }}/fabric-x-committer-test-node:latest
125127
build-args: |
126128
ARCHBIN_PATH=archbin
129+
VERSION=${{ env.VERSION }}
127130
cache-from: type=registry,ref=docker.io/${{ env.IMAGE_PREFIX }}/fabric-x-committer-test-node:buildcache
128131
cache-to: type=registry,ref=docker.io/${{ env.IMAGE_PREFIX }}/fabric-x-committer-test-node:buildcache,mode=max

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
#########################
2222

2323
go_cmd ?= go
24-
version := 0.0.2
24+
version := latest
2525
project_dir := $(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))
2626
output_dir ?= $(project_dir)/bin
2727
arch_output_dir ?= $(project_dir)/archbin
@@ -43,7 +43,7 @@ cmd ?=
4343
# An error will occur if neither container engine is installed.
4444
docker_cmd ?= $(shell command -v docker >/dev/null 2>&1 && echo docker || \
4545
echo podman || { echo "Error: Neither Docker nor Podman is installed." >&2; exit 1; })
46-
image_namespace=icr.io/cbdc
46+
image_namespace=docker.io/hyperledger
4747

4848
# Set these parameters to compile to a specific os/arch
4949
# E.g., make build-local os=linux arch=amd64

docker/images/release/Dockerfile

Lines changed: 32 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,48 @@
1+
#
12
# Copyright IBM Corp. All Rights Reserved.
23
#
34
# SPDX-License-Identifier: Apache-2.0
45
#
5-
FROM registry.access.redhat.com/ubi9/ubi-micro:9.4 AS prod
6+
7+
###########################################
8+
# Stage 1: Production runtime image
9+
###########################################
10+
FROM registry.access.redhat.com/ubi9/ubi-minimal:9.6 AS prod
11+
612
ARG BIN
713
ARG ARCHBIN_PATH
814
ARG TARGETOS
915
ARG TARGETARCH
1016
ARG PORTS
17+
ARG VERSION=1.0
1118

12-
# --- Create a non-root user (UBI-micro does not include useradd) ---
13-
USER 10001
14-
15-
# --- Create working directory ---
16-
WORKDIR /app
19+
# Add non-root user (10001) using BIN argument
20+
RUN /usr/sbin/useradd -u 10001 -r -g root -s /sbin/nologin -c "Hyperledger Fabric-X ${BIN} user" ${BIN} && \
21+
mkdir -p /home/${BIN} && \
22+
chown -R 10001:0 /home/${BIN} && \
23+
chmod 0755 /home/${BIN}
1724

18-
# --- Copy the architecture-specific binary ---
25+
# Copy binaries
1926
COPY ${ARCHBIN_PATH}/${TARGETOS}-${TARGETARCH}/${BIN} /bin/${BIN}
2027

21-
# --- Expose ports for Kubernetes/OpenShift ---
28+
# Create fixed entrypoint since args are not replaced
29+
# within ENTRYPOINT or CMD
30+
RUN ln -s /bin/${BIN} /bin/entrypoint
31+
32+
# Expose ports
2233
EXPOSE ${PORTS}
2334

24-
# --- Container metadata (OCI labels) ---
35+
# OCI metadata labels
2536
LABEL name="${BIN}" \
26-
vendor="IBM" \
27-
maintainer="ZRL Decentralized Trust Group" \
28-
description="Production-grade ${BIN} microservice running on UBI-micro" \
29-
summary="Minimal, secure UBI-micro image for ${BIN}" \
30-
license="Apache-2.0"
31-
32-
# --- Set runtime entrypoint ---
33-
ENTRYPOINT /bin/${BIN}
37+
maintainer="IBM Research ZRL Decentralized Trust Group" \
38+
version="${VERSION}" \
39+
description="Hyperledger Fabric-X ${BIN} packaged in a UBI image" \
40+
license="Apache-2.0" \
41+
vendor="IBM"
42+
43+
# Use non-root user and set workdir using BIN argument
44+
USER 10001
45+
WORKDIR /home/${BIN}
46+
47+
# Default Entrypoint
48+
ENTRYPOINT ["/bin/entrypoint"]

docker/images/test_node/Dockerfile

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,18 @@
1+
#
12
# Copyright IBM Corp. All Rights Reserved.
23
#
34
# SPDX-License-Identifier: Apache-2.0
45
#
6+
7+
###########################################
8+
# Stage 1: Production runtime image
9+
###########################################
510
FROM postgres:16.9-alpine3.21 AS node
611

712
ARG ARCHBIN_PATH
813
ARG TARGETOS
914
ARG TARGETARCH
15+
ARG VERSION
1016

1117
ENV CONFIGS_PATH=/root/config
1218
ENV BINS_PATH=/root/bin
@@ -48,6 +54,16 @@ COPY ./cmd/config/samples $CONFIGS_PATH
4854
COPY ./bin/sc-genesis-block.proto.bin $CONFIGS_PATH/
4955
RUN chmod a+x ${BINS_PATH}/*
5056

57+
# Expose ports
5158
EXPOSE 7050 4001 2114 7001 2117 2110
5259

60+
# OCI metadata labels
61+
LABEL name="fabric-x-committer-test-node" \
62+
maintainer="IBM Research ZRL Decentralized Trust Group" \
63+
version="${VERSION}" \
64+
description="Preconfigured Hyperledger Fabric-X Committer Node" \
65+
license="Apache-2.0" \
66+
vendor="IBM"
67+
68+
# Default CMD
5369
CMD ["run"]

docker/test/common.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ type createAndStartContainerParameters struct {
3232
}
3333

3434
const (
35-
testNodeImage = "icr.io/cbdc/committer-test-node:0.0.2"
35+
testNodeImage = "docker.io/hyperledger/committer-test-node:0.0.2"
3636
channelName = "mychannel"
3737
monitoredMetric = "loadgen_transaction_committed_total"
3838
)

docker/test/container_release_image_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ func (p *startNodeParameters) asNode(node string) startNodeParameters {
4444
}
4545

4646
const (
47-
committerReleaseImage = "icr.io/cbdc/committer:0.0.2"
48-
loadgenReleaseImage = "icr.io/cbdc/loadgen:0.0.2"
47+
committerReleaseImage = "docker.io/hyperledger/committer:0.0.2"
48+
loadgenReleaseImage = "docker.io/hyperledger/loadgen:0.0.2"
4949
containerPrefixName = "sc_test"
5050
networkPrefixName = containerPrefixName + "_network"
5151
genBlockFile = "sc-genesis-block.proto.bin"

scripts/build-release-image.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,14 @@ function build_image() {
1818
local image_name=$1
1919
local bin=$2
2020
local service_ports=$3
21-
local manifest_name=${namespace}/${image_name}:${version}
21+
local manifest_name=${namespace}/fabric-x-${image_name}:${version}
2222
local cmd=(
2323
"${docker_cmd}" build
2424
-f "${dockerfile_release_dir}/Dockerfile"
2525
--build-arg BIN="${bin}"
2626
--build-arg PORTS="${service_ports}"
2727
--build-arg ARCHBIN_PATH="${arch_bin_dir}"
28+
--build-arg VERSION="${version}"
2829
)
2930

3031
if [ "${multiplatform}" = true ]; then

0 commit comments

Comments
 (0)