Skip to content

Commit

Permalink
Update dependency and runtime versions
Browse files Browse the repository at this point in the history
Signed-off-by: Mark S. Lewis <[email protected]>
  • Loading branch information
bestbeforetoday authored and denyeart committed Nov 22, 2024
1 parent dfe8148 commit 9e7119b
Show file tree
Hide file tree
Showing 10 changed files with 282 additions and 601 deletions.
36 changes: 14 additions & 22 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

#
# SPDX-License-Identifier: Apache-2.0
#
Expand All @@ -9,37 +8,33 @@ on:
workflow_dispatch: {}

jobs:

# Lint, Compile and Core Function Tests
build:
name: Build and test
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Use Go 1.18
uses: actions/setup-go@v3
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: 1.18
go-version: stable
- name: Run Go formatters and linters
run: make lint
- uses: actions/setup-java@v3
- uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '11'
- name: Use Node.js 20
uses: actions/setup-node@v2
distribution: temurin
java-version: 17
- uses: actions/setup-node@v4
with:
node-version: 20
node-version: 22
- name: Install Fabric dependencies
run: |
sudo mkdir -p /opt/fabric
pushd /opt/fabric
curl -sSL https://raw.githubusercontent.com/hyperledger/fabric/main/scripts/install-fabric.sh | bash -s -- binary --fabric-version 2.5.0-alpha3 --ca-version 1.5.6-beta3
curl -sSL https://raw.githubusercontent.com/hyperledger/fabric/main/scripts/install-fabric.sh | bash -s -- binary --fabric-version 2.5.10 --ca-version 1.5.13
popd
cd builders/java
sudo mvn -q dependency:copy-dependencies -DoutputDirectory=/opt/fabric-chaincode-java/lib
npm install -g [email protected].1
npm install -g [email protected].7
- name: Run Go formatters and linters
run: make lint
- name: Run Go unit tests
Expand All @@ -58,34 +53,31 @@ jobs:
needs: [build]
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
uses: docker/setup-buildx-action@v3
- name: Setup Fabric
run: |
curl -sSL https://raw.githubusercontent.com/hyperledger/fabric/main/scripts/install-fabric.sh | bash -s -- binary
# set the path and cfg env var for the rest of the step
echo "FABRIC_CFG_PATH=$GITHUB_WORKSPACE/config" >> $GITHUB_ENV
echo "$GITHUB_WORKSPACE/bin" >> $GITHUB_PATH
- name: Build Docker image
id: dockerbuild
uses: docker/build-push-action@v3
uses: docker/build-push-action@v6
with:
context: .
file: Dockerfile2
platforms: linux/amd64
push: false
load: true
tags: dev-microfab


- name: Run against image
run: |
docker images
./scripts/test-container.sh
env:
MICROFAB_IMAGE: dev-microfab

91 changes: 42 additions & 49 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@

#
# SPDX-License-Identifier: Apache-2.0
#
---
name: Publish Image
on:
create:
push:
tags:
- "v*"
workflow_dispatch: {}

jobs:

# Build the daemon binary and if a release publish if a 'tag' build
# amd64/arm64
binary_build:
Expand All @@ -23,24 +21,22 @@ jobs:
env:
GOARCH: ${{ matrix.goarch }}
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Use Go 1.18
uses: actions/setup-go@v2
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: 1.18
go-version: stable
- name: Build Binary
run: go build -v -o bin/microfabd cmd/microfabd/main.go
- name: Package Binary
run: |
export GOOS=$(go env GOOS)
tar -C bin -czvf microfab-${GOOS}-${GOARCH}.tgz microfabd
- name: Publish Binary to GitHub Release
uses: softprops/action-gh-release@v1
uses: softprops/action-gh-release@v2
if: startsWith(github.ref, 'refs/tags/')
with:
files: microfab-*.tgz

# Build the cli binary and if a release publish if a 'tag' build
# amd64/arm64
binary_cli_build:
Expand All @@ -52,16 +48,14 @@ jobs:
env:
GOARCH: ${{ matrix.goarch }}
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Use Go 1.18
uses: actions/setup-go@v2
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: 1.18
go-version: stable
- name: Build Binary
run: go build -v -o bin/microfab-${GOARCH} cmd/microfab/main.go
- name: Publish Binary to GitHub Release
uses: softprops/action-gh-release@v1
uses: softprops/action-gh-release@v2
if: startsWith(github.ref, 'refs/tags/')
with:
files: bin/microfab-*
Expand All @@ -74,36 +68,35 @@ jobs:
image_digest: ${{ steps.push.outputs.digest }}

steps:
- name: Checkout
uses: actions/checkout@v3
- name: Docker meta
id: meta
uses: docker/metadata-action@v4
with:
images: |
ghcr.io/hyperledger-labs/microfab
tags: |
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=sha,format=long
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push
id: push
uses: docker/build-push-action@v3
with:
context: .
file: Dockerfile2
platforms: linux/amd64,linux/arm64
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
- uses: actions/checkout@v4
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: |
ghcr.io/hyperledger-labs/microfab
tags: |
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=sha,format=long
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push
id: push
uses: docker/build-push-action@v6
with:
context: .
file: Dockerfile2
platforms: linux/amd64,linux/arm64
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
61 changes: 25 additions & 36 deletions Dockerfile2
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
# SPDX-License-Identifier: Apache-2.0
#

FROM debian:bullseye-slim AS builder
ENV DEBIAN_FRONTEND=noninteractive
FROM debian:bookworm-slim AS builder
ENV DEBIAN_FRONTEND=noninteractive

ARG TARGETARCH
ARG TARGETOS
Expand All @@ -14,15 +14,15 @@ RUN apt-get update \
&& apt-get -y install python3 python3-distutils libpython3-dev software-properties-common \
&& apt-get -y install curl git jq unzip moreutils

RUN curl -sL https://go.dev/dl/go1.22.3.${TARGETOS}-${TARGETARCH}.tar.gz | tar zxf - -C /usr/local
ENV PATH="/usr/local/go/bin:$PATH"
RUN curl -sL https://go.dev/dl/go1.23.3.${TARGETOS}-${TARGETARCH}.tar.gz | tar zxf - -C /usr/local
ENV PATH="/usr/local/go/bin:$PATH"

ENV GOROOT=/usr/local/go
ENV GOPATH=/tmp/go

WORKDIR $GOPATH/src/github.com/hyperledger
RUN git clone --depth 1 --branch release-2.5 https://github.com/hyperledger/fabric.git \
&& git clone --depth 1 --branch v1.5.5 https://github.com/hyperledger/fabric-ca.git
&& git clone --depth 1 --branch v1.5.13 https://github.com/hyperledger/fabric-ca.git
WORKDIR $GOPATH/src/github.com/hyperledger/fabric
ENV CGO_ENABLED=0
RUN make orderer \
Expand All @@ -33,15 +33,15 @@ ENV CGO_ENABLED=1
RUN make release/build/bin/fabric-ca-client \
&& make release/build/bin/fabric-ca-server

WORKDIR $GOPATH/src/github.com/IBM/microfab
WORKDIR $GOPATH/src/github.com/hyperledger-labs/microfab
ENV CGO_ENABLED=0
ADD . $GOPATH/src/github.com/IBM/microfab
ADD . $GOPATH/src/github.com/hyperledger-labs/microfab
RUN go build -o microfabd cmd/microfabd/main.go

WORKDIR /fabric
RUN curl -sSL https://github.com/hyperledger/fabric/releases/download/v2.5.7/hyperledger-fabric-linux-amd64-2.5.7.tar.gz | tar xzf - config
RUN curl -sSL https://github.com/hyperledger/fabric/releases/download/v2.5.10/hyperledger-fabric-linux-amd64-2.5.10.tar.gz | tar xzf - config

FROM couchdb:3.3.3
FROM couchdb:3.4

# Though they are populated by docker buildx, the ARG reference is required to make them available for use
ARG TARGETARCH
Expand All @@ -57,31 +57,24 @@ RUN groupadd -g 7051 microfab \
&& chown -R microfab:microfab /home/microfab

RUN mkdir -p /opt/go /opt/node /opt/java \
&& curl -sSL https://dl.google.com/go/go1.22.3.$TARGETOS-$TARGETARCH.tar.gz | tar xzf - -C /opt/go --strip-components=1

# OpenJDK11U-jdk_x64_linux_hotspot_11.0.17_8.tar.gz
# node-v18.12.1-linux-x64.tar.xz
RUN if [ "${TARGETARCH}" = "amd64" ]; then ARCH=x64 \
&& curl -sSL https://github.com/adoptium/temurin11-binaries/releases/download/jdk-11.0.17%2B8/OpenJDK11U-jdk_${ARCH}_${TARGETOS}_hotspot_11.0.17_8.tar.gz | tar xzf - -C /opt/java --strip-components=1 \
&& curl -sSL https://nodejs.org/download/release/v20.14.0/node-v20.14.0-${TARGETOS}-${ARCH}.tar.xz | tar xJf - -C /opt/node --strip-components=1 \
&& curl -sSL https://dl.google.com/go/go1.23.3.$TARGETOS-$TARGETARCH.tar.gz | tar xzf - -C /opt/go --strip-components=1

RUN if [ "${TARGETARCH}" = "amd64" ]; then ARCH=x64 \
&& curl -sSL https://github.com/adoptium/temurin17-binaries/releases/download/jdk-17.0.9%2B9/OpenJDK17U-jdk_${ARCH}_${TARGETOS}_hotspot_17.0.9_9.tar.gz | tar xzf - -C /opt/java --strip-components=1 \
&& curl -sSL https://nodejs.org/download/release/v22.11.0/node-v22.11.0-${TARGETOS}-${ARCH}.tar.xz | tar xJf - -C /opt/node --strip-components=1 \
; elif [ "${TARGETARCH}" = "arm64" ]; then ARCH=aarch64 \
&& curl -sSL https://github.com/adoptium/temurin17-binaries/releases/download/jdk-17.0.9%2B9/OpenJDK17U-jdk_${ARCH}_${TARGETOS}_hotspot_17.0.9_9.tar.gz | tar xzf - -C /opt/java --strip-components=1 \
&& curl -sSL https://nodejs.org/download/release/v22.11.0/node-v22.11.0-${TARGETOS}-${TARGETARCH}.tar.xz | tar xJf - -C /opt/node --strip-components=1 \
; fi

# node-v18.12.1-linux-arm64.tar.xz
# OpenJDK11U-jdk_aarch64_linux_hotspot_11.0.17_8.tar.gz
RUN if [ "${TARGETARCH}" = "arm64" ]; then ARCH=aarch64 \
&& curl -sSL https://github.com/adoptium/temurin11-binaries/releases/download/jdk-11.0.17%2B8/OpenJDK11U-jdk_${ARCH}_${TARGETOS}_hotspot_11.0.17_8.tar.gz | tar xzf - -C /opt/java --strip-components=1 \
&& curl -sSL https://nodejs.org/download/release/v20.14.0/node-v20.14.0-${TARGETOS}-${TARGETARCH}.tar.xz | tar xJf - -C /opt/node --strip-components=1 \
; fi


COPY docker/local.ini /opt/couchdb/etc/local.d/local.ini
COPY docker/docker-entrypoint.sh /usr/local/bin
COPY --from=builder /tmp/go/src/github.com/hyperledger/fabric/build/bin/* /usr/local/bin/
COPY --from=builder /tmp/go/src/github.com/hyperledger/fabric-ca/release/build/bin/* /usr/local/bin/
COPY --from=builder /fabric/config /etc/hyperledger/fabric
COPY --from=builder /tmp/go/src/github.com/IBM/microfab/microfabd /usr/local/bin/
COPY --from=builder /tmp/go/src/github.com/hyperledger-labs/microfab/microfabd /usr/local/bin/

COPY --from=builder --chown=microfab:microfab /tmp/go/src/github.com/IBM/microfab/builders/ /home/microfab/builders/
COPY --from=builder --chown=microfab:microfab /tmp/go/src/github.com/hyperledger-labs/microfab/builders/ /home/microfab/builders/
COPY --from=builder --chown=microfab:microfab /tmp/go/src/github.com/hyperledger/fabric/release/*/builders/ccaas /home/microfab/builders/ccaas

RUN sed -i 's/opt/home/g' /opt/couchdb/etc/local.d/local.ini
Expand All @@ -91,22 +84,18 @@ ENV MICROFAB_HOME=/home/microfab
ENV PATH=/opt/go/bin:/opt/node/bin:/opt/java/bin:/opt/couchdb/bin:${PATH}


RUN curl -sSL -o /tmp/gradle.zip https://services.gradle.org/distributions/gradle-5.6.4-bin.zip \
RUN curl -sSL -o /tmp/gradle.zip https://services.gradle.org/distributions/gradle-8.11.1-bin.zip \
&& unzip -qq /tmp/gradle.zip -d /opt \
&& mkdir -p /opt/gradle/bin \
&& cd /opt/gradle/bin \
&& /opt/gradle-5.6.4/bin/gradle wrapper \
&& mv /opt/gradle-8.11.1 /opt/gradle \
&& rm -f /tmp/gradle.zip \
&& rm -rf /opt/gradle-5.6.4 \
&& cd - \
&& curl -sSL https://dlcdn.apache.org/maven/maven-3/3.9.7/binaries/apache-maven-3.9.7-bin.tar.gz | tar xzf - -C /opt \
&& mv /opt/apache-maven-3.9.7 /opt/maven
&& curl -sSL https://dlcdn.apache.org/maven/maven-3/3.9.9/binaries/apache-maven-3.9.9-bin.tar.gz | tar xzf - -C /opt \
&& mv /opt/apache-maven-3.9.9 /opt/maven
ENV PATH=/opt/gradle/bin:/opt/maven/bin:${PATH}
ADD builders/java/pom.xml /opt/fabric-chaincode-java/

RUN cd /opt/fabric-chaincode-java \
&& mvn -q dependency:copy-dependencies -DoutputDirectory=/opt/fabric-chaincode-java/lib \
&& npm install --unsafe-perm -g fabric-shim@2.4.2 \
&& npm install --unsafe-perm -g fabric-shim@2.5.7 \
&& rm -rf /tmp/gocache /tmp/goenv /tmp/go /tmp/maven /tmp/npm-cache /tmp/npm-devdir

RUN chmod 666 /etc/passwd
Expand All @@ -120,4 +109,4 @@ ENV GOENV=/tmp/goenv
ENV GOPATH=/tmp/go

VOLUME /home/microfab/data
ENTRYPOINT [ "tini", "--", "/usr/local/bin/docker-entrypoint.sh" ]
ENTRYPOINT [ "tini", "--", "/usr/local/bin/docker-entrypoint.sh" ]
4 changes: 2 additions & 2 deletions builders/java/bin/build
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ if [ -f build.gradle ] || [ -f build.gradle.kts ]; then
chmod +x ./gradlew
./gradlew build shadowJar -x test
else
/opt/gradle/bin/gradlew build shadowJar -x test
/opt/gradle/bin/gradle build shadowJar -x test
fi
cp build/libs/chaincode.jar "${BUILD_OUTPUT_DIR}/"
touch "${BUILD_OUTPUT_DIR}/.uberjar"
Expand All @@ -28,4 +28,4 @@ else
exit 1
fi
tar cf - . | (cd "${BUILD_OUTPUT_DIR}" && tar xf -)
fi
fi
Loading

0 comments on commit 9e7119b

Please sign in to comment.