forked from hyperledger-cacti/cacti
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs(examples): add carbon-account-app hyperledger-cacti#540
WORK IN PROGRESS Fixes hyperledger-cacti#540 Signed-off-by: Peter Somogyvari <[email protected]>
- Loading branch information
Showing
17 changed files
with
3,788 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
.git | ||
*/*/node_modules | ||
*/*/dist | ||
*/*/build | ||
|
||
.config.json | ||
.nyc_output/ | ||
dist/ | ||
.DS_Store | ||
node_modules/ | ||
docs/main | ||
logs/ | ||
jspm_packages/ | ||
generated-sources/ | ||
coverage/ | ||
|
||
# Optional npm cache directory | ||
.npm | ||
|
||
# Optional eslint cache | ||
.eslintcache | ||
|
||
# Optional REPL history | ||
.node_repl_history | ||
|
||
# Output of 'npm pack' | ||
*.tgz | ||
|
||
# Yarn Integrity file | ||
.yarn-integrity | ||
|
||
# next.js build output | ||
.next | ||
|
||
# vscode files | ||
.vscode/* | ||
!.vscode/template.launch.json | ||
|
||
# Introperability App specifics | ||
examples/simple-asset-transfer/fabric/**/hfc-key-store/ | ||
|
||
bin/ | ||
.tmp/ | ||
lerna-debug.log | ||
cactus-openapi-spec.json | ||
cactus-openapi-spec-*.json | ||
.npmrc | ||
*.log |
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 |
---|---|---|
@@ -0,0 +1,143 @@ | ||
FROM node:12.20.1-alpine3.12 as builder | ||
|
||
RUN apk update | ||
|
||
# Need JDK for the openapi-generator that is part of the build process | ||
RUN apk add --no-cache openjdk8 | ||
|
||
# Need git because some of our npm depedencies might be coming | ||
# straight from github instead of being an npm package on npmjs.com. | ||
RUN apk add --no-cache git | ||
|
||
# Some install scripts of the npm package fabric-network need python | ||
RUN apk add --no-cache python3 py3-pip | ||
|
||
RUN npm install modclean -g | ||
|
||
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 run build:dev:backend | ||
RUN npm run webpack:dev:web | ||
RUN npm run build:dev:frontend -- --scope='@hyperledger/cactus-example-supply-chain-frontend' | ||
RUN ./node_modules/.bin/lerna clean --yes | ||
RUN ./node_modules/.bin/lerna bootstrap -- --production --no-optional | ||
|
||
# RUN modclean --run --patterns="default:*" --path ./examples/cactus-example-supply-chain-backend/ | ||
# RUN modclean --run --patterns="default:*" --path ./examples/cactus-example-supply-chain-business-logic-plugin/ | ||
# RUN modclean --run --patterns="default:*" --path ./examples/cactus-example-supply-chain-frontend/ | ||
# RUN modclean --run --patterns="default:*" --path ./packages/cactus-api-client/ | ||
# RUN modclean --run --patterns="default:*" --path ./packages/cactus-cmd-api-server/ | ||
# RUN modclean --run --patterns="default:*" --path ./packages/cactus-cockpit/ | ||
# RUN modclean --run --patterns="default:*" --path ./packages/cactus-common/ | ||
# RUN modclean --run --patterns="default:*" --path ./packages/cactus-core-api/ | ||
# RUN modclean --run --patterns="default:*" --path ./packages/cactus-core/ | ||
# RUN modclean --run --patterns="default:*" --path ./packages/cactus-plugin-consortium-manual/ | ||
# RUN modclean --run --patterns="default:*" --path ./packages/cactus-plugin-keychain-memory/ | ||
# RUN modclean --run --patterns="default:*" --path ./packages/cactus-plugin-keychain-vault/ | ||
# RUN modclean --run --patterns="default:*" --path ./packages/cactus-plugin-ledger-connector-besu/ | ||
# RUN modclean --run --patterns="default:*" --path ./packages/cactus-plugin-ledger-connector-fabric/ | ||
# RUN modclean --run --patterns="default:*" --path ./packages/cactus-plugin-ledger-connector-quorum/ | ||
# RUN modclean --run --patterns="default:*" --path ./packages/cactus-test-tooling/ | ||
|
||
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 docker:20.10.2-dind-rootless as runner | ||
|
||
USER root | ||
|
||
RUN apk update | ||
|
||
# Add bash for convenience, sh has less features | ||
RUN apk add --no-cache bash | ||
|
||
# Need curl for healthchecks | ||
RUN apk add --no-cache curl | ||
|
||
# The file binary is used to inspect exectubles when debugging container image issues | ||
RUN apk add --no-cache file | ||
|
||
RUN apk add --no-cache nodejs | ||
RUN apk add --no-cache npm | ||
|
||
RUN apk add --no-cache ca-certificates | ||
RUN apk add --no-cache tzdata | ||
|
||
# Install supervisord because we need to run the docker daemon and also the fabric network | ||
# meaning that we have multiple processes to run. | ||
RUN apk add --no-cache supervisor | ||
|
||
ARG APP=/usr/src/app/ | ||
|
||
ENV TZ=Etc/UTC | ||
ENV APP_USER=appuser | ||
|
||
RUN addgroup --system $APP_USER | ||
RUN adduser --system $APP_USER -G $APP_USER | ||
RUN addgroup $APP_USER rootless | ||
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/" | ||
|
||
# TODO: Can we hack it together so that the whole thing works rootless? | ||
# USER $APP_USER | ||
|
||
WORKDIR ${APP} | ||
|
||
COPY --chown=${APP_USER}:${APP_USER} ./examples/carbon-accounting/healthcheck.sh / | ||
|
||
ENV CACTUS_NODE_ID=- | ||
ENV CONSORTIUM_ID=- | ||
ENV KEY_PAIR_PEM=- | ||
ENV COCKPIT_WWW_ROOT=examples/cactus-example-supply-chain-frontend/www/ | ||
ENV COCKPIT_TLS_ENABLED=false | ||
ENV COCKPIT_CORS_DOMAIN_CSV=\* | ||
ENV COCKPIT_MTLS_ENABLED=false | ||
ENV COCKPIT_TLS_CERT_PEM=- | ||
ENV COCKPIT_TLS_KEY_PEM=- | ||
ENV COCKPIT_TLS_CLIENT_CA_PEM=- | ||
ENV COCKPIT_HOST=0.0.0.0 | ||
ENV COCKPIT_PORT=3000 | ||
ENV API_MTLS_ENABLED=false | ||
ENV API_TLS_ENABLED=false | ||
ENV API_CORS_DOMAIN_CSV=\* | ||
ENV API_TLS_CERT_PEM=- | ||
ENV API_TLS_CLIENT_CA_PEM=- | ||
ENV API_TLS_KEY_PEM=- | ||
ENV API_HOST=0.0.0.0 | ||
ENV API_PORT=4000 | ||
ENV LOG_LEVEL=TRACE | ||
|
||
COPY examples/supply-chain-app/supervisord.conf /etc/supervisord.conf | ||
|
||
# supervisord web ui/dashboard | ||
EXPOSE 9001 | ||
# API #1 | ||
EXPOSE 4000 | ||
# API #2 | ||
EXPOSE 4100 | ||
# GUI #1 | ||
EXPOSE 3000 | ||
# GUI #2 | ||
EXPOSE 3100 | ||
# API #3 | ||
EXPOSE 4200 | ||
# GUI #3 | ||
EXPOSE 3200 | ||
|
||
# Extend the parent image's entrypoint | ||
# https://superuser.com/questions/1459466/can-i-add-an-additional-docker-entrypoint-script | ||
ENTRYPOINT ["/usr/bin/supervisord"] | ||
CMD ["--configuration", "/etc/supervisord.conf", "--nodaemon"] | ||
HEALTHCHECK --interval=1s --timeout=5s --start-period=20s --retries=250 \ | ||
CMD /usr/src/app/examples/supply-chain-app/healthcheck.sh |
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 |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# Cactus Blockchain Carbon Accounting Example | ||
|
||
This is an implementation of the Hyperledger CA2 SIG's similarly named project | ||
(which has multiple different DLTs working together), | ||
but one that uses Hyperledger Cactus as its development framework instead of | ||
relying on the vanilla ledger SDKs. | ||
|
||
At the same time this is also a case study of how can a real world project be | ||
delivered with Hyperledger Cactus. | ||
|
||
## Usage | ||
|
||
Further details and documentation to be defined later. | ||
|
||
## Building and running the container locally | ||
|
||
```sh | ||
# Change directories to the project root | ||
|
||
# Build the dockar image and tag it as "caeb" for carbon accounting example backend | ||
DOCKER_BUILDKIT=1 docker build -f ./examples/carbon-accounting/Dockerfile . -t caeb | ||
|
||
# Run the built image with ports mapped to the host machine as you see fit | ||
# The --privileged flag is required because we use Docker-in-Docker for pulling | ||
# up ledger containers from within the container in order to have the example | ||
# be completely self-contained where you don't need to worry about running | ||
# multiple different ledgers just this one container. | ||
docker run --rm -it --privileged -p 3000:3000 -p 3100:3100 -p 3200:3200 -p 4000:4000 -p 4100:4100 -p 4200:4200 caeb | ||
``` |
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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/bin/bash | ||
|
||
curl -v -i -X OPTIONS http://127.0.0.1:${COCKPIT_PORT} |
Oops, something went wrong.