-
Notifications
You must be signed in to change notification settings - Fork 8.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Switch base docker image from golang-alpine to ubuntu:20.04
Signed-off-by: Josh Kneubuhl <jkneubuh@us.ibm.com>
- Loading branch information
Showing
7 changed files
with
257 additions
and
125 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,30 @@ | ||
# Copyright IBM Corp. All Rights Reserved. | ||
# | ||
# Copyright contributors to the Hyperledger Fabric project | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at: | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
|
||
ARG GO_VER | ||
ARG ALPINE_VER | ||
ARG UBUNTU_VER | ||
|
||
FROM ubuntu:${UBUNTU_VER} as base | ||
|
||
RUN apt update | ||
RUN apt install -y tzdata | ||
|
||
RUN addgroup --gid 500 chaincode | ||
RUN adduser --disabled-password --gecos "" --uid 500 --gid 500 --home /home/chaincode chaincode | ||
|
||
FROM alpine:${ALPINE_VER} as base | ||
RUN apk add --no-cache tzdata | ||
RUN addgroup -g 500 chaincode && adduser -u 500 -D -h /home/chaincode -G chaincode chaincode | ||
USER chaincode | ||
USER chaincode |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,44 @@ | ||
# Copyright IBM Corp. All Rights Reserved. | ||
# | ||
# Copyright contributors to the Hyperledger Fabric project | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at: | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
|
||
ARG UBUNTU_VER | ||
FROM ubuntu:${UBUNTU_VER} | ||
|
||
ARG TARGETARCH | ||
ARG TARGETOS | ||
ARG GO_VER | ||
ARG ALPINE_VER | ||
FROM golang:${GO_VER}-alpine${ALPINE_VER} | ||
RUN apk add --no-cache \ | ||
binutils-gold \ | ||
g++ \ | ||
gcc \ | ||
git \ | ||
musl-dev | ||
|
||
RUN mkdir -p /chaincode/output /chaincode/input | ||
RUN addgroup -g 500 chaincode && adduser -u 500 -D -h /home/chaincode -G chaincode chaincode | ||
RUN chown -R chaincode:chaincode /chaincode | ||
|
||
RUN apt update | ||
RUN apt install -y binutils-gold | ||
RUN apt install -y curl | ||
RUN apt install -y g++ | ||
RUN apt install -y gcc | ||
RUN apt install -y git | ||
|
||
RUN curl -sL https://go.dev/dl/go${GO_VER}.${TARGETOS}-${TARGETARCH}.tar.gz | tar zxvf - -C /usr/local | ||
ENV PATH="/usr/local/go/bin:$PATH" | ||
|
||
RUN addgroup --gid 500 chaincode | ||
RUN adduser --disabled-password --gecos "" --uid 500 --gid 500 --home /home/chaincode chaincode | ||
|
||
RUN mkdir -p /chaincode/output /chaincode/input | ||
RUN chown -R chaincode:chaincode /chaincode | ||
|
||
USER chaincode | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,46 +1,71 @@ | ||
# Copyright IBM Corp. All Rights Reserved. | ||
# | ||
# Copyright contributors to the Hyperledger Fabric project | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at: | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
|
||
############################################################################### | ||
# Build image | ||
############################################################################### | ||
|
||
ARG UBUNTU_VER | ||
FROM ubuntu:${UBUNTU_VER} as builder | ||
|
||
ARG TARGETARCH | ||
ARG TARGETOS | ||
ARG GO_VER | ||
ARG ALPINE_VER | ||
ARG GO_TAGS | ||
|
||
RUN apt update | ||
RUN apt install -y git | ||
RUN apt install -y gcc | ||
RUN apt install -y curl | ||
RUN apt install -y make | ||
RUN curl -sL https://go.dev/dl/go${GO_VER}.${TARGETOS}-${TARGETARCH}.tar.gz | tar zxvf - -C /usr/local | ||
ENV PATH="/usr/local/go/bin:$PATH" | ||
|
||
ADD . . | ||
|
||
RUN make orderer GO_TAGS=${GO_TAGS} | ||
|
||
|
||
############################################################################### | ||
# Runtime image | ||
############################################################################### | ||
|
||
ARG UBUNTU_VER | ||
FROM ubuntu:${UBUNTU_VER} | ||
|
||
ARG FABRIC_VER | ||
|
||
FROM alpine:${ALPINE_VER} as base | ||
RUN apk add --no-cache tzdata | ||
# set up nsswitch.conf for Go's "netgo" implementation | ||
# - https://github.com/golang/go/blob/go1.9.1/src/net/conf.go#L194-L275 | ||
# - docker run --rm debian:stretch grep '^hosts:' /etc/nsswitch.conf | ||
RUN echo 'hosts: files dns' > /etc/nsswitch.conf | ||
|
||
FROM golang:${GO_VER}-alpine${ALPINE_VER} as golang | ||
RUN apk add --no-cache \ | ||
bash \ | ||
binutils-gold \ | ||
gcc \ | ||
git \ | ||
make \ | ||
musl-dev | ||
ADD . $GOPATH/src/github.com/hyperledger/fabric | ||
WORKDIR $GOPATH/src/github.com/hyperledger/fabric | ||
|
||
FROM golang as orderer | ||
ARG GO_TAGS | ||
ARG FABRIC_VER | ||
ENV FABRIC_VER ${FABRIC_VER} | ||
ENV FABRIC_CFG_PATH /var/hyperledger/fabric/config | ||
ENV FABRIC_VER ${FABRIC_VER} | ||
|
||
# Disable cgo when building in the container. This will create a static binary, which can be | ||
# copied and run in the base alpine container without the libc/musl runtime. | ||
ENV CGO_ENABLED 0 | ||
COPY --from=builder build/bin/orderer /usr/local/bin | ||
COPY --from=builder sampleconfig/msp ${FABRIC_CFG_PATH}/msp | ||
COPY --from=builder sampleconfig/orderer.yaml ${FABRIC_CFG_PATH} | ||
COPY --from=builder sampleconfig/configtx.yaml ${FABRIC_CFG_PATH} | ||
|
||
RUN make orderer GO_TAGS=${GO_TAGS} | ||
VOLUME /etc/hyperledger/fabric | ||
VOLUME /var/hyperledger | ||
EXPOSE 7050 | ||
|
||
FROM base | ||
ENV FABRIC_CFG_PATH /etc/hyperledger/fabric | ||
VOLUME /etc/hyperledger/fabric | ||
VOLUME /var/hyperledger | ||
COPY --from=orderer /go/src/github.com/hyperledger/fabric/build/bin /usr/local/bin | ||
COPY --from=orderer /go/src/github.com/hyperledger/fabric/sampleconfig/msp ${FABRIC_CFG_PATH}/msp | ||
COPY --from=orderer /go/src/github.com/hyperledger/fabric/sampleconfig/orderer.yaml ${FABRIC_CFG_PATH} | ||
COPY --from=orderer /go/src/github.com/hyperledger/fabric/sampleconfig/configtx.yaml ${FABRIC_CFG_PATH} | ||
EXPOSE 7050 | ||
CMD ["orderer"] | ||
ENTRYPOINT [ "orderer" ] | ||
CMD [ "start" ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,48 +1,76 @@ | ||
# Copyright IBM Corp. All Rights Reserved. | ||
# | ||
# Copyright contributors to the Hyperledger Fabric project | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at: | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
|
||
############################################################################### | ||
# Build image | ||
############################################################################### | ||
|
||
ARG UBUNTU_VER | ||
FROM ubuntu:${UBUNTU_VER} as builder | ||
|
||
ARG TARGETARCH | ||
ARG TARGETOS | ||
ARG GO_VER | ||
ARG ALPINE_VER | ||
FROM alpine:${ALPINE_VER} as peer-base | ||
RUN apk add --no-cache tzdata | ||
ARG GO_TAGS | ||
|
||
RUN apt update | ||
RUN apt install -y git | ||
RUN apt install -y gcc | ||
RUN apt install -y curl | ||
RUN apt install -y make | ||
RUN curl -sL https://go.dev/dl/go${GO_VER}.${TARGETOS}-${TARGETARCH}.tar.gz | tar zxvf - -C /usr/local | ||
ENV PATH="/usr/local/go/bin:$PATH" | ||
|
||
ADD . . | ||
|
||
RUN make peer GO_TAGS=${GO_TAGS} | ||
RUN make ccaasbuilder | ||
|
||
|
||
############################################################################### | ||
# Runtime image | ||
############################################################################### | ||
|
||
ARG UBUNTU_VER | ||
FROM ubuntu:${UBUNTU_VER} | ||
|
||
ARG TARGETOS | ||
ARG TARGETARCH | ||
ARG FABRIC_VER | ||
|
||
# set up nsswitch.conf for Go's "netgo" implementation | ||
# - https://github.com/golang/go/blob/go1.9.1/src/net/conf.go#L194-L275 | ||
# - docker run --rm debian:stretch grep '^hosts:' /etc/nsswitch.conf | ||
RUN echo 'hosts: files dns' > /etc/nsswitch.conf | ||
|
||
FROM golang:${GO_VER}-alpine${ALPINE_VER} as golang | ||
RUN apk add --no-cache \ | ||
bash \ | ||
binutils-gold \ | ||
gcc \ | ||
git \ | ||
make \ | ||
musl-dev | ||
ADD . $GOPATH/src/github.com/hyperledger/fabric | ||
WORKDIR $GOPATH/src/github.com/hyperledger/fabric | ||
|
||
FROM golang as peer | ||
ARG GO_TAGS | ||
ARG FABRIC_VER | ||
ENV FABRIC_VER ${FABRIC_VER} | ||
ENV FABRIC_CFG_PATH /var/hyperledger/fabric/config | ||
ENV FABRIC_VER ${FABRIC_VER} | ||
|
||
# Disable cgo when building in the container. This will create a static binary, which can be | ||
# copied and run in the base alpine container without the libc/musl runtime. | ||
ENV CGO_ENABLED 0 | ||
COPY --from=builder build/bin/peer /usr/local/bin | ||
COPY --from=builder sampleconfig/msp ${FABRIC_CFG_PATH}/msp | ||
COPY --from=builder sampleconfig/core.yaml ${FABRIC_CFG_PATH}/core.yaml | ||
|
||
RUN make peer GO_TAGS=${GO_TAGS} | ||
RUN make ccaasbuilder | ||
COPY --from=builder release/${TARGETOS}-${TARGETARCH}/builders/ccaas/bin /opt/hyperledger/ccaas_builder/bin | ||
|
||
FROM peer-base | ||
ARG TARGETARCH | ||
ARG TARGETOS | ||
ENV FABRIC_CFG_PATH /etc/hyperledger/fabric | ||
VOLUME /etc/hyperledger/fabric | ||
VOLUME /var/hyperledger | ||
COPY --from=peer /go/src/github.com/hyperledger/fabric/build/bin /usr/local/bin | ||
COPY --from=peer /go/src/github.com/hyperledger/fabric/sampleconfig/msp ${FABRIC_CFG_PATH}/msp | ||
COPY --from=peer /go/src/github.com/hyperledger/fabric/sampleconfig/core.yaml ${FABRIC_CFG_PATH}/core.yaml | ||
COPY --from=peer /go/src/github.com/hyperledger/fabric/release/${TARGETOS}-${TARGETARCH}/builders/ccaas/bin/ /opt/hyperledger/ccaas_builder/bin/ | ||
EXPOSE 7051 | ||
CMD ["peer","node","start"] | ||
VOLUME /etc/hyperledger/fabric | ||
VOLUME /var/hyperledger | ||
|
||
EXPOSE 7051 | ||
|
||
ENTRYPOINT [ "peer" ] | ||
CMD [ "node", "start" ] |
Oops, something went wrong.