-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy pathDockerfile2
112 lines (87 loc) · 4.73 KB
/
Dockerfile2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
#
# SPDX-License-Identifier: Apache-2.0
#
FROM debian:bookworm-slim AS builder
ENV DEBIAN_FRONTEND=noninteractive
ARG TARGETARCH
ARG TARGETOS
# Build tools
RUN apt-get update \
&& apt-get -y install build-essential gcc gzip \
&& 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.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.13 https://github.com/hyperledger/fabric-ca.git
WORKDIR $GOPATH/src/github.com/hyperledger/fabric
ENV CGO_ENABLED=0
RUN make orderer \
&& make tools \
&& make ccaasbuilder
WORKDIR $GOPATH/src/github.com/hyperledger/fabric-ca
ENV CGO_ENABLED=1
RUN make release/build/bin/fabric-ca-client \
&& make release/build/bin/fabric-ca-server
WORKDIR $GOPATH/src/github.com/hyperledger-labs/microfab
ENV CGO_ENABLED=0
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.10/hyperledger-fabric-linux-amd64-2.5.10.tar.gz | tar xzf - config
FROM couchdb:3.4
# Though they are populated by docker buildx, the ARG reference is required to make them available for use
ARG TARGETARCH
ARG TARGETOS
RUN apt-get update && apt-get install -y \
jq xz-utils unzip vim \
&& rm -rf /var/lib/apt/lists/*
RUN groupadd -g 7051 microfab \
&& useradd -u 7051 -g microfab -G root -s /bin/bash -m microfab \
&& mkdir -p /home/microfab/builders /home/microfab/data \
&& chown -R microfab:microfab /home/microfab
RUN mkdir -p /opt/go /opt/node /opt/java \
&& 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/temurin21-binaries/releases/download/jdk-21.0.5%2B11/OpenJDK21U-jdk_${ARCH}_${TARGETOS}_hotspot_21.0.5_11.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/temurin21-binaries/releases/download/jdk-21.0.5%2B11/OpenJDK21U-jdk_${ARCH}_${TARGETOS}_hotspot_21.0.5_11.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
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/hyperledger-labs/microfab/microfabd /usr/local/bin/
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
ENV FABRIC_CFG_PATH=/etc/hyperledger/fabric
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-8.11.1-bin.zip \
&& unzip -qq /tmp/gradle.zip -d /opt \
&& mv /opt/gradle-8.11.1 /opt/gradle \
&& rm -f /tmp/gradle.zip \
&& 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.5.7 \
&& rm -rf /tmp/gocache /tmp/goenv /tmp/go /tmp/maven /tmp/npm-cache /tmp/npm-devdir
RUN chmod 666 /etc/passwd
EXPOSE 8080
USER 7051
ENV GOROOT=/opt/go
ENV GOCACHE=/tmp/gocache
ENV GOENV=/tmp/goenv
ENV GOPATH=/tmp/go
VOLUME /home/microfab/data
ENTRYPOINT [ "tini", "--", "/usr/local/bin/docker-entrypoint.sh" ]