Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/add-workspaces' into DEV-2584
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrew Nikitin committed May 16, 2023
2 parents 29f73a0 + 3bd6e24 commit 07a34ca
Show file tree
Hide file tree
Showing 34 changed files with 33,878 additions and 25,689 deletions.
59 changes: 21 additions & 38 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
###############################################################
### STAGE 1: Build credential-service app ###
###############################################################
######################################################
### Build credential-service app ###
######################################################

FROM node:18-alpine AS builder
FROM node:18-alpine AS runner

# Set working directory & bash defaults
WORKDIR /home/node/app
Expand All @@ -13,56 +13,39 @@ COPY . .
# Installing dependencies
RUN npm ci

# Build the app
RUN npm run build

###############################################################
### STAGE 2: Build Miniflare runner ###
###############################################################

FROM node:18-alpine AS runner

# Set working directory & bash defaults
WORKDIR /home/node/app

# Copy built application
COPY --from=builder /home/node/app/dist .

# Build-time arguments
ARG NODE_ENV=production
ARG NPM_CONFIG_LOGLEVEL=warn
ARG PORT=8787
ARG ISSUER_ID
ARG ISSUER_ID_PUBLIC_KEY_HEX
ARG ISSUER_ID_PRIVATE_KEY_HEX
ARG COSMOS_PAYER_MNEMONIC
ARG NETWORK_RPC_URL
ARG ISSUER_SECRET_KEY
ARG ISSUER_DATABASE_URL
ARG ISSUER_DATABASE_CERT
ARG MAINNET_RPC_URL
ARG TESTNET_RPC_URL
ARG RESOLVER_URL
ARG ALLOWED_ORIGINS

# Run-time environment variables
ENV NODE_ENV ${NODE_ENV}
ENV NPM_CONFIG_LOGLEVEL ${NPM_CONFIG_LOGLEVEL}
ENV PORT ${PORT}
ENV ISSUER_ID ISSUER_ID ${ISSUER_ID}
ENV ISSUER_ID_PUBLIC_KEY_HEX ${ISSUER_ID_PUBLIC_KEY_HEX}
ENV ISSUER_ID_PRIVATE_KEY_HEX ${ISSUER_ID_PRIVATE_KEY_HEX}
ENV COSMOS_PAYER_MNEMONIC ${COSMOS_PAYER_MNEMONIC}
ENV NETWORK_RPC_URL ${NETWORK_RPC_URL}
ENV ISSUER_SECRET_KEY ${ISSUER_SECRET_KEY}
ENV ISSUER_DATABASE_URL ${ISSUER_DATABASE_URL}
ENV ISSUER_DATABASE_CERT ${ISSUER_DATABASE_CERT}
ENV MAINNET_RPC_URL ${MAINNET_RPC_URL}
ENV TESTNET_RPC_URL ${TESTNET_RPC_URL}
ENV RESOLVER_URL ${RESOLVER_URL}
ENV ALLOWED_ORIGINS ${ALLOWED_ORIGINS}

# We don't have the node_modules directory
# this image only has the output worker.js file.
# Install pre-requisites
RUN npm install swagger-ui-express@4.5.0 && \
chown -R node:node /home/node/app && \
apk update && \
apk add --no-cache bash ca-certificates
# Build the app
RUN npm run build

# Specify default port
EXPOSE ${PORT}

# Set user and shell
USER node
SHELL ["/bin/bash", "-euo", "pipefail", "-c"]
SHELL ["/bin/sh", "-euo", "pipefail", "-c"]

# Run the application
CMD [ "node", "index.js" ]
CMD npm run migration; node dist/index.js
22 changes: 17 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,26 @@ npm run build

The application expects the following environment variables to be defined for the app to function:

1. `ISSUER_ID_PRIVATE_KEY_HEX`: Hex-encoded private key to be used by the identity credential issuer
2. `ISSUER_ID_PUBLIC_KEY_HEX`: Hex-encoded public key to be used by the identity credential issuer
3. `ISSUER_ID`: Fully-qualified DID for the issuer, e.g., `did:cheqd:mainnet:zAXwwqZzhCZA1L77ZBa8fhVNjL9MQCHX`
4. `COSMOS_PAYER_MNEMONIC`: Mnemonic for the issuer's Cosmos account. This currently doesn't require any balances at the moment, but it required for the library to function.
5. `NETWORK_RPC_URL`: Optional RPC URL for a node on cheqd network, e.g., `rpc.cheqd.net`
1. `ISSUER_DATABASE_URL`: The postgres database url e.g. `postgres://<user>:<password>@<host>:<port>/<database>?<query>`
2. `ISSUER_SECRET_KEY`: A secret key for the veramo wallet
3. `PORT`: Port number for the credential service (optional)
4. `FEE_PAYER_MNENONIC_TESTNET`: Mnemonic for the issuer's Cosmos account to be used for testnet.
5. `FEE_PAYER_MNENONIC_MAINNET`: Mnemonic for the issuer's Cosmos account to be used for mainnet.
6. `MAINNET_RPC_URL`: Optional RPC URL for a node on cheqd mainnet, e.g., `https://rpc.cheqd.net`
7. `TESTNET_RPC_URL`: Optional RPC URL for a node on cheqd testnet, e.g., `https://rpc.cheqd.network`
8. `ISSUER_DATABASE_CERT`: Optional ca certificate parameter of the database

### Run

Run a postgres instance

```bash
docker pull postgres
docker run --name some-postgres -e POSTGRES_PASSWORD=mysecretpassword -d postgres
```

Construct the postgres url and configure the env variables mentioned above

Once configured, the app can be run using NPM:

```bash
Expand Down
14 changes: 14 additions & 0 deletions lerna.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"packages": ["packages/*"],
"version": "2.0.0-develop.2",
"useWorkspaces": true,
"npmClient": "npm",
"command": {
"version": {
"allowBranch": "main"
},
"publish": {
"graphType": "all"
}
}
}
Loading

0 comments on commit 07a34ca

Please sign in to comment.