Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Signed-off-by: Peter Somogyvari <peter.somogyvari@accenture.com>
  • Loading branch information
petermetz committed Aug 14, 2021
1 parent a96ce68 commit 992858d
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 28 deletions.
55 changes: 30 additions & 25 deletions packages/cactus-cmd-api-server/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,27 +1,11 @@
FROM node:12.20.1-alpine3.12

ARG NPM_PKG_VERSION=latest

RUN apk update
RUN apk add --no-cache tini
FROM ubuntu:20.04

ARG APP=/usr/src/app/
ARG NPM_PKG_VERSION=latest

ENV TZ=Etc/UTC
ENV APP_USER=appuser

RUN addgroup --system $APP_USER
RUN adduser --system $APP_USER -G $APP_USER
RUN mkdir -p ${APP}

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

WORKDIR ${APP}

COPY --chown=${APP_USER}:${APP_USER} ./packages/cactus-cmd-api-server/healthcheck.sh /

RUN chown -R $APP_USER:$APP_USER ${APP}
ENV NODE_ENV=production

ENV CACTUS_NODE_ID=-
ENV CONSORTIUM_ID=-
Expand All @@ -43,15 +27,36 @@ 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
ENV LOG_LEVEL=INFO

# GUI: 3000, API: 4000
EXPOSE 3000 4000
# GUI: 3000, API: 4000, gRPC 5000
EXPOSE 3000 4000 5000

RUN groupadd --gid 1000 appuser \
&& useradd --uid 1000 --gid appuser --shell /bin/bash --create-home appuser

RUN apt update && apt install -y curl

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

WORKDIR ${APP}

COPY --chown=${APP_USER}:${APP_USER} ./packages/cactus-cmd-api-server/healthcheck.sh /
RUN chown -R $APP_USER:$APP_USER ${APP}

USER $APP_USER

RUN npm i @elenaizaguirre/cactus-cmd-api-server@${NPM_PKG_VERSION}
SHELL ["/bin/bash", "--login", "-i", "-c"]
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 npm install @hyperledger/cactus-cmd-api-server@${NPM_PKG_VERSION} --production

ENTRYPOINT ["/sbin/tini", "--"]
CMD ["node", "node_modules/@elenaizaguirre/cactus-cmd-api-server/dist/lib/main/typescript/cmd/cactus-api.js"]
HEALTHCHECK --interval=5s --timeout=5s --start-period=1s --retries=30 CMD /healthcheck.sh

COPY ./packages/cactus-cmd-api-server/docker-entrypoint.sh /usr/local/bin/
ENTRYPOINT ["docker-entrypoint.sh"]

# CMD ["/home/appuser/.nvm/versions/node/v16.3.0/bin/node", "node_modules/@hyperledger/cactus-cmd-api-server/dist/lib/main/typescript/cmd/cactus-api.js"]

CMD ["node_modules/@hyperledger/cactus-cmd-api-server/dist/lib/main/typescript/cmd/cactus-api.js"]
4 changes: 2 additions & 2 deletions packages/cactus-cmd-api-server/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ if (require.main === module) {
### Complete Example

For a complete example of how to use the API server, read all the code of the
supply chain exmaple's backend package:
supply chain example's backend package:

https://github.com/hyperledger/cactus/tree/main/examples/cactus-example-supply-chain-backend/src/main/typescript

Expand Down Expand Up @@ -239,7 +239,7 @@ Once you've built the container, the following commands should work:
cas
```

- Launch container with plugins of your choice (keychain, consortium connector, etc.)
- Launch container with plugins of your choice (keychain, consortium connector, etc.)

```sh
docker run \
Expand Down
8 changes: 8 additions & 0 deletions packages/cactus-cmd-api-server/docker-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash
set -e

if [ "${1#-}" != "${1}" ] || [ -z "$(command -v "${1}")" ]; then
set -- /home/appuser/.nvm/versions/node/v16.3.0/bin/node "$@"
fi

exec "$@"
3 changes: 2 additions & 1 deletion packages/cactus-plugin-ledger-connector-besu/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
FROM cactus-api-server:latest

ENV NODE_ENV=production
ARG NPM_PKG_VERSION=latest

RUN npm i @hyperledger/cactus-plugin-ledger-connector-besu@${NPM_PKG_VERSION} --production
RUN npm install @hyperledger/cactus-plugin-ledger-connector-besu@${NPM_PKG_VERSION} --production

0 comments on commit 992858d

Please sign in to comment.