Skip to content

Commit

Permalink
ci(containerization): build all container images via the CI suite #942
Browse files Browse the repository at this point in the history
This will get us closer to the desired state of affairs where any
source code change that breaks the build can be detected prior
to the pull request getting merged.

Before this, the issue was that DockerHub would not integrate
properly with the GitHub PR Checks mechanism and so we were
unable to have the checks executed properly.

Also: Fixes the missing publish config section of the carbon accounting
example's back-end package.

Fixes #942

Signed-off-by: Peter Somogyvari <peter.somogyvari@accenture.com>
  • Loading branch information
petermetz committed Sep 27, 2021
1 parent 3fbd2fc commit 9082bfa
Show file tree
Hide file tree
Showing 6 changed files with 135 additions and 63 deletions.
114 changes: 114 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,117 @@ jobs:
- uses: actions/checkout@v2.3.4

- run: ./tools/ci.sh

build-containers:
runs-on: ubuntu-20.04
continue-on-error: true

steps:

- uses: actions/checkout@v2.3.4
name: Check out code

- name: Print Disk Usage Reports
run: df ; echo "" ; docker system df

- name: ghcr.io/hyperledger/cactus-dev-container-vscode
run: DOCKER_BUILDKIT=1 docker build ./.devcontainer/ -f ./.devcontainer/Dockerfile

- name: Print Disk Usage Reports
run: df ; echo "" ; docker system df

- name: ghcr.io/hyperledger/cactus-example-supply-chain-app
run: DOCKER_BUILDKIT=1 docker build . -f ./examples/supply-chain-app/Dockerfile

- name: Print Disk Usage Reports
run: df ; echo "" ; docker system df

- name: ghcr.io/hyperledger/cactus-example-carbon-accounting
run: DOCKER_BUILDKIT=1 docker build . -f ./examples/carbon-accounting/Dockerfile

- name: Print Disk Usage Reports
run: df ; echo "" ; docker system df

- name: ghcr.io/hyperledger/cactus-cmd-api-server
run: DOCKER_BUILDKIT=1 docker build . -f ./packages/cactus-cmd-api-server/Dockerfile

- name: Print Disk Usage Reports
run: df ; echo "" ; docker system df

- name: ghcr.io/hyperledger/cactus-keychain-vault-server
run: DOCKER_BUILDKIT=1 docker build ./packages/cactus-plugin-keychain-vault/src/cactus-keychain-vault-server/ -f ./packages/cactus-plugin-keychain-vault/src/cactus-keychain-vault-server/Dockerfile

- name: Print Disk Usage Reports
run: df ; echo "" ; docker system df

- name: ghcr.io/hyperledger/cactus-connector-corda-server
run: DOCKER_BUILDKIT=1 docker build ./packages/cactus-plugin-ledger-connector-corda/src/main-server/ -f ./packages/cactus-plugin-ledger-connector-corda/src/main-server/Dockerfile

- name: Print Disk Usage Reports
run: df ; echo "" ; docker system df

- name: ghcr.io/hyperledger/cactus-connector-fabric
run: DOCKER_BUILDKIT=1 docker build ./packages/cactus-plugin-ledger-connector-fabric/ -f ./packages/cactus-plugin-ledger-connector-fabric/Dockerfile

- name: Print Disk Usage Reports
run: df ; echo "" ; docker system df

- name: ghcr.io/hyperledger/cactus-connector-besu
run: DOCKER_BUILDKIT=1 docker build ./packages/cactus-plugin-ledger-connector-besu/ -f ./packages/cactus-plugin-ledger-connector-besu/Dockerfile

- name: Print Disk Usage Reports
run: df ; echo "" ; docker system df

- name: ghcr.io/hyperledger/cactus-besu-all-in-one
run: DOCKER_BUILDKIT=1 docker build ./tools/docker/besu-all-in-one/ -f ./tools/docker/besu-all-in-one/Dockerfile

- name: Print Disk Usage Reports
run: df ; echo "" ; docker system df

- name: ghcr.io/hyperledger/cactus-corda-all-in-one
run: DOCKER_BUILDKIT=1 docker build ./tools/docker/corda-all-in-one/ -f ./tools/docker/corda-all-in-one/Dockerfile

- name: Print Disk Usage Reports
run: df ; echo "" ; docker system df

- name: ghcr.io/hyperledger/cactus-fabric2-all-in-one
run: DOCKER_BUILDKIT=1 docker build ./tools/docker/fabric-all-in-one/ -f ./tools/docker/fabric-all-in-one/Dockerfile_v2.x

- name: Print Disk Usage Reports
run: df ; echo "" ; docker system df

- name: ghcr.io/hyperledger/cactus-fabric-all-in-one
run: DOCKER_BUILDKIT=1 docker build ./tools/docker/fabric-all-in-one/ -f ./tools/docker/fabric-all-in-one/Dockerfile_v1.4.x

- name: Print Disk Usage Reports
run: df ; echo "" ; docker system df

- name: ghcr.io/hyperledger/cactus-iroha-all-in-one
run: DOCKER_BUILDKIT=1 docker build ./tools/docker/iroha-all-in-one/ -f ./tools/docker/iroha-all-in-one/Dockerfile

- name: Print Disk Usage Reports
run: df ; echo "" ; docker system df

- name: ghcr.io/hyperledger/cactus-quorum-all-in-one
run: DOCKER_BUILDKIT=1 docker build ./tools/docker/quorum-all-in-one/ -f ./tools/docker/quorum-all-in-one/Dockerfile

- name: Print Disk Usage Reports
run: df ; echo "" ; docker system df

- name: ghcr.io/hyperledger/cactus-rust-compiler
run: DOCKER_BUILDKIT=1 docker build ./tools/docker/rust-compiler/ -f ./tools/docker/rust-compiler/Dockerfile

- name: Print Disk Usage Reports
run: df ; echo "" ; docker system df

- name: ghcr.io/hyperledger/cactus-rust-compiler
run: DOCKER_BUILDKIT=1 docker build ./tools/docker/test-npm-registry/ -f ./tools/docker/test-npm-registry/Dockerfile

- name: Print Disk Usage Reports
run: df ; echo "" ; docker system df

- name: ghcr.io/hyperledger/cactus-whitepaper
run: DOCKER_BUILDKIT=1 docker build ./whitepaper/ -f ./whitepaper/Dockerfile

- name: Print Disk Usage Reports
run: df ; echo "" ; docker system df
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@
"extensions": "sol"
}
},
"publishConfig": {
"access": "public"
},
"engines": {
"node": ">=10",
"npm": ">=6"
Expand Down
68 changes: 9 additions & 59 deletions examples/carbon-accounting/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,55 +1,3 @@
FROM node:16.3.0-buster-slim as builder

RUN apt-get update
RUN apt-get -y upgrade

# Generic dependencies that are usually needed by other software
RUN apt-get install -y build-essential libssl-dev libffi-dev python3-dev

# Need git because some of our npm depedencies might be coming
# straight from github instead of being an npm package on npmjs.com.
RUN apt-get install -y git

# Need OpenJDK for the OpenAPI generator tool
ENV DEBIAN_FRONTEND=noninteractive

WORKDIR /opt
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
ca-certificates \
curl \
&& curl \
-L \
-o openjdk.tar.gz \
https://download.java.net/java/GA/jdk11/13/GPL/openjdk-11.0.1_linux-x64_bin.tar.gz \
&& mkdir jdk \
&& tar zxf openjdk.tar.gz -C jdk --strip-components=1 \
&& rm -rf openjdk.tar.gz \
&& ln -sf /opt/jdk/bin/* /usr/local/bin/ \
&& java --version \
&& javac --version \
&& jlink --version

# Some install scripts of the npm package fabric-network need python/pip
RUN apt-get install -y python3-pip

WORKDIR /
RUN mkdir /app/
WORKDIR /app/
COPY ./ ./
RUN npm ci
RUN ./node_modules/.bin/lerna clean --yes
RUN ./node_modules/.bin/lerna bootstrap
RUN npm rebuild
RUN npm run build:dev:backend
RUN npm run webpack:dev:web
RUN npm run build:dev:frontend -- --scope='@hyperledger/cactus-example-carbon-accounting-frontend'

RUN rm -rf ./packages/cactus-test-plugin*
RUN rm -rf ./packages/cactus-test-cmd*
RUN rm -rf ./packages/cactus-test-api*
RUN rm -rf ./node_modules/

FROM cruizba/ubuntu-dind:19.03.11 as runner

USER root
Expand All @@ -76,22 +24,23 @@ RUN useradd -m ${APP_USER}
RUN usermod -a -G ${APP_USER} ${APP_USER}
RUN mkdir -p ${APP}

COPY --chown=$APP_USER:$APP_USER --from=builder /app/ ${APP}

RUN mkdir -p "${APP}/log/"
RUN chown -R $APP_USER:$APP_USER "${APP}/log/"
RUN chown -R $APP_USER:$APP_USER "${APP}/"

# TODO: Can we hack it together so that the whole thing works rootless?
USER ${APP_USER}
WORKDIR ${APP}

SHELL ["/bin/bash", "--login", "-i", "-c"]

# Installing Node Version Manager (nvm)
RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/install.sh | bash
RUN source ~/.bashrc && nvm install 16.3.0
RUN source ~/.bashrc && \
nvm install 16.8.0 && \
npm install -g yarn && \
yarn add @hyperledger/cactus-example-carbon-accounting-backend@0.9.1-ci-942.cbb849c6.35 --ignore-engines --production

SHELL ["/bin/bash", "--login", "-c"]

WORKDIR ${APP}

COPY --chown=${APP_USER}:${APP_USER} ./examples/carbon-accounting/healthcheck.sh /

Expand All @@ -100,7 +49,7 @@ ENV AUTHORIZATION_PROTOCOL=NONE
ENV CACTUS_NODE_ID=-
ENV CONSORTIUM_ID=-
ENV KEY_PAIR_PEM=-
ENV COCKPIT_WWW_ROOT=examples/cactus-example-carbon-accounting-frontend/www/
ENV COCKPIT_WWW_ROOT=/usr/src/app/node_modules/@hyperledger/cactus-example-carbon-accounting-frontend/www/
ENV COCKPIT_TLS_ENABLED=false
ENV COCKPIT_CORS_DOMAIN_CSV=\*
ENV COCKPIT_MTLS_ENABLED=false
Expand All @@ -117,6 +66,7 @@ ENV API_TLS_CLIENT_CA_PEM=-
ENV API_TLS_KEY_PEM=-
ENV API_HOST=0.0.0.0
ENV API_PORT=4000
ENV GRPC_TLS_ENABLED=false
ENV LOG_LEVEL=TRACE

COPY examples/carbon-accounting/supervisord.conf /etc/supervisord.conf
Expand Down
1 change: 1 addition & 0 deletions packages/cactus-cmd-api-server/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ RUN curl https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/install.sh | bash
&& nvm use default \
&& npm install -g npm@7.19.1

RUN npm install -g yarn@1.18.0
RUN yarn add @hyperledger/cactus-cmd-api-server@${NPM_PKG_VERSION} --production

COPY ./packages/cactus-cmd-api-server/docker-entrypoint.sh /usr/local/bin/
Expand Down
6 changes: 4 additions & 2 deletions packages/cactus-plugin-ledger-connector-besu/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
FROM cactus-api-server:latest
FROM ghcr.io/hyperledger/cactus-cmd-api-server:2021-08-15--refactor-1222

RUN npm install -g yarn@1.18.0

ENV NODE_ENV=production
ARG NPM_PKG_VERSION=latest

RUN yarn add @hyperledger/cactus-plugin-ledger-connector-besu@${NPM_PKG_VERSION} --production
RUN yarn add @hyperledger/cactus-plugin-ledger-connector-besu@${NPM_PKG_VERSION} --production --ignore-engines
6 changes: 4 additions & 2 deletions packages/cactus-plugin-ledger-connector-fabric/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
FROM cactus-api-server:latest
FROM ghcr.io/hyperledger/cactus-cmd-api-server:2021-08-15--refactor-1222

RUN npm install -g yarn@1.18.0

ARG NPM_PKG_VERSION=latest

RUN yarn add @hyperledger/cactus-plugin-ledger-connector-fabric@${NPM_PKG_VERSION} --production
RUN yarn add @hyperledger/cactus-plugin-ledger-connector-fabric@${NPM_PKG_VERSION} --production --ignore-engines

0 comments on commit 9082bfa

Please sign in to comment.