Skip to content

Commit

Permalink
Merge branch 'master' into release/cardano-services/0.28.x
Browse files Browse the repository at this point in the history
  • Loading branch information
gytis-ivaskevicius committed Jul 17, 2024
2 parents 5c00b86 + 5a7146b commit 0d8f188
Show file tree
Hide file tree
Showing 81 changed files with 654 additions and 274 deletions.
7 changes: 1 addition & 6 deletions .envrc
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
#! /bin/sh

# shellcheck disable=SC1090
source "$(
fetchurl "https://raw.githubusercontent.com/paisano-nix/direnv/main/lib" "sha256-IgQhKK7UHL1AfCUntJO2KCaIDJQotRnK2qC4Daxk+wI="
)"

export K8S_USER=eks-devs

use envreload //local/envs/main
use flake

source_env_if_exists .envrc.local
3 changes: 2 additions & 1 deletion .envrc.local.example
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@

# Should be `eks-devs` for developers/QA
export K8S_USER=eks-devs

export AWS_ACCESS_KEY_ID=xxxxxxxxxxxxxxxxxxxx
export AWS_SECRET_ACCESS_KEY=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

Expand Down
5 changes: 4 additions & 1 deletion .github/workflows/continuous-integration-e2e.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,10 @@ jobs:
- name: 🔨 Build
run: |
yarn install --immutable --inline-builds --mode=skip-build
yarn build:cjs
yarn workspace @cardano-sdk/cardano-services-client build:cjs
yarn workspace @cardano-sdk/cardano-services build:cjs
yarn workspace @cardano-sdk/e2e build:cjs
yarn workspace @cardano-sdk/util-dev build:cjs
docker build --no-cache .
env:
NODE_OPTIONS: '--max_old_space_size=8192'
Expand Down
11 changes: 11 additions & 0 deletions .github/workflows/k6-web-socket.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
name: K6 WebSocket server load tests

on:
workflow_dispatch:

jobs:
web-socket:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
4 changes: 2 additions & 2 deletions .github/workflows/std.yml
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ jobs:
run: |
echo 'export K8S_USER=eks-devs' >.envrc.local
nix develop .#x86_64-linux.local.envs.main -L --command bash -c '
nix develop -L --command bash -c '
set -euo pipefail
export AWS_PROFILE="lw"
Expand Down Expand Up @@ -323,7 +323,7 @@ jobs:
run: |
echo 'export K8S_USER=eks-devs' >.envrc.local
nix develop .#x86_64-linux.local.envs.main -L --command bash -c '
nix develop -L --command bash -c '
set -euo pipefail
export AWS_PROFILE="lw"
Expand Down
54 changes: 11 additions & 43 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,16 @@ RUN \
apt-get install nodejs -y &&\
apt-get install -y --no-install-recommends ca-certificates jq postgresql-client

FROM ubuntu-nodejs as nodejs-builder
FROM ubuntu-nodejs as cardano-services

ARG NETWORK=mainnet
ENV NETWORK=${NETWORK}

RUN \
curl --proto '=https' --tlsv1.2 -sSf -L https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - &&\
echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list &&\
apt-get update && apt-get install yarn -y
COPY packages/cardano-services/config/network/${NETWORK} /config/
WORKDIR /app
COPY build build
COPY packages/cardano-services/package.json packages/cardano-services/package.json
Expand All @@ -47,53 +52,16 @@ COPY packages/web-extension/package.json packages/web-extension/package.json
COPY scripts scripts
COPY .yarn .yarn
COPY .eslintrc.js .prettierrc .yarnrc.yml complete.eslintrc.js eslint.tsconfig.json package.json tsconfig.json yarn.lock yarn-project.nix ./

FROM nodejs-builder as cardano-services-builder
# NOTE: Pay attention to --mode=skip-build
# For details: https://github.com/input-output-hk/cardano-js-sdk/pull/1024
RUN yarn --immutable --inline-builds --mode=skip-build
COPY packages packages
RUN \
yarn workspace @cardano-sdk/cardano-services build &&\
yarn workspace @cardano-sdk/cardano-services-client build

FROM nodejs-builder as cardano-services
RUN yarn workspaces focus --all --production
COPY --from=cardano-services-builder /app/scripts /app/scripts
COPY --from=cardano-services-builder /app/packages/cardano-services/dist /app/packages/cardano-services/dist
COPY --from=cardano-services-builder /app/packages/cardano-services/package.json /app/packages/cardano-services/package.json
COPY --from=cardano-services-builder /app/packages/cardano-services-client/dist /app/packages/cardano-services-client/dist
COPY --from=cardano-services-builder /app/packages/cardano-services-client/package.json /app/packages/cardano-services-client/package.json
COPY --from=cardano-services-builder /app/packages/core/dist /app/packages/core/dist
COPY --from=cardano-services-builder /app/packages/core/package.json /app/packages/core/package.json
COPY --from=cardano-services-builder /app/packages/crypto/dist /app/packages/crypto/dist
COPY --from=cardano-services-builder /app/packages/crypto/package.json /app/packages/crypto/package.json
COPY --from=cardano-services-builder /app/packages/ogmios/dist /app/packages/ogmios/dist
COPY --from=cardano-services-builder /app/packages/ogmios/package.json /app/packages/ogmios/package.json
COPY --from=cardano-services-builder /app/packages/projection/dist /app/packages/projection/dist
COPY --from=cardano-services-builder /app/packages/projection/package.json /app/packages/projection/package.json
COPY --from=cardano-services-builder /app/packages/projection-typeorm/dist /app/packages/projection-typeorm/dist
COPY --from=cardano-services-builder /app/packages/projection-typeorm/package.json /app/packages/projection-typeorm/package.json
COPY --from=cardano-services-builder /app/packages/util/dist /app/packages/util/dist
COPY --from=cardano-services-builder /app/packages/util/package.json /app/packages/util/package.json
COPY --from=cardano-services-builder /app/packages/util-rxjs/dist /app/packages/util-rxjs/dist
COPY --from=cardano-services-builder /app/packages/util-rxjs/package.json /app/packages/util-rxjs/package.json

FROM cardano-services as provider-server
ARG NETWORK=mainnet
ENV \
CARDANO_NODE_CONFIG_PATH=/config/cardano-node/config.json \
NETWORK=${NETWORK}
WORKDIR /app/packages/cardano-services
COPY packages/cardano-services/config/network/${NETWORK} /config/
EXPOSE 3000
HEALTHCHECK --interval=15s --timeout=15s \
CMD curl --fail --silent -H 'Origin: http://0.0.0.0:3000' http://0.0.0.0:3000/v1.0.0/health | jq '.ok' | awk '{ if ($0 == "true") exit 0; else exit 1}' || exit 1
CMD ["node", "dist/cjs/cli.js", "start-provider-server"]
HEALTHCHECK --interval=15s --timeout=15s CMD curl --fail --silent http://0.0.0.0:3000/health | jq '.ok' | awk '{ if ($0 == "true") exit 0; else exit 1}' || exit 1
CMD ["bash", "-c", "../../node_modules/.bin/tsx watch --clear-screen=false --conditions=development src/cli start-provider-server"]

FROM cardano-services as worker
WORKDIR /app/packages/cardano-services
CMD ["node", "dist/cjs/cli.js", "start-worker"]
CMD ["bash", "-c", "../../node_modules/.bin/tsx watch --clear-screen=false --conditions=development src/cli start-worker"]

FROM cardano-services as blockfrost-worker
ENV \
Expand All @@ -105,15 +73,15 @@ ENV \
POSTGRES_PORT_DB_SYNC=5432 \
POSTGRES_USER_FILE_DB_SYNC=/run/secrets/postgres_user
WORKDIR /app/packages/cardano-services
CMD ["node", "dist/cjs/cli.js", "start-blockfrost-worker"]
CMD ["bash", "-c", "../../node_modules/.bin/tsx watch --clear-screen=false --conditions=development src/cli start-blockfrost-worker"]

FROM cardano-services as pg-boss-worker
WORKDIR /config
COPY compose/schedules.json .
ENV SCHEDULES=/config/schedules.json
WORKDIR /app/packages/cardano-services
HEALTHCHECK CMD curl --fail --silent http://localhost:3003/v1.0.0/health
CMD ["node", "dist/cjs/cli.js", "start-pg-boss-worker"]
CMD ["bash", "-c", "../../node_modules/.bin/tsx watch --clear-screen=false --conditions=development src/cli start-pg-boss-worker"]

FROM cardano-services as projector
WORKDIR /
Expand Down
23 changes: 22 additions & 1 deletion compose/common.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ x-from-sdk: &from-sdk
timeout: 5s
retries: 10
restart: on-failure
volumes:
- ../..:/app

x-logging: &logging
logging:
Expand Down Expand Up @@ -56,6 +58,7 @@ x-projector-environment: &projector-environment

x-provider-server-environment: &provider-server-environment
API_URL: http://0.0.0.0:3000
CARDANO_NODE_CONFIG_PATH: /config/cardano-node/config.json
DB_CACHE_TTL: ${DB_CACHE_TTL:-120}
DISABLE_DB_CACHE: ${DISABLE_DB_CACHE:-false}
DISABLE_STAKE_POOL_METRIC_APY: ${DISABLE_STAKE_POOL_METRIC_APY:-false}
Expand Down Expand Up @@ -165,7 +168,16 @@ services:
<<: *logging
image: cardanosolutions/ogmios:v${OGMIOS_VERSION:-6.3.0}
command:
['--host', '0.0.0.0', '--node-socket', '/ipc/node.socket', '--node-config', '/config/cardano-node/config.json']
[
'--host',
'0.0.0.0',
'--node-socket',
'/ipc/node.socket',
'--node-config',
'/config/cardano-node/config.json',
'--log-level-websocket',
'Warning'
]
depends_on:
cardano-node:
condition: service_started
Expand Down Expand Up @@ -298,6 +310,9 @@ services:
- *logging
- *provider-server
- *with-postgres
depends_on:
stake-pool-projector:
condition: service_healthy
environment:
<<:
- *sdk-environment
Expand All @@ -313,6 +328,9 @@ services:
- *logging
- *provider-server
- *with-postgres
depends_on:
asset-projector:
condition: service_healthy
environment:
<<:
- *sdk-environment
Expand All @@ -328,6 +346,9 @@ services:
- *logging
- *provider-server
- *with-postgres
depends_on:
handle-projector:
condition: service_healthy
environment:
<<:
- *sdk-environment
Expand Down
34 changes: 0 additions & 34 deletions compose/dev.yml

This file was deleted.

2 changes: 1 addition & 1 deletion compose/projector/init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ _term() {
trap _term SIGTERM

cd /app/packages/cardano-services
node dist/cjs/cli.js start-projector &
../../node_modules/.bin/tsx watch --clear-screen=false --conditions=development src/cli start-projector &

CHILD=$!
wait "$CHILD"
45 changes: 33 additions & 12 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
{
description = "Cardano JS SDK";

inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
flake-parts.url = "github:hercules-ci/flake-parts";
Expand All @@ -19,31 +21,36 @@
};
};

# --- Flake Local Nix Configuration ----------------------------
nixConfig = {
# still used by single-user-mode (e.g. ci)
extra-substituters = [
"https://cache.iog.io"
"s3://lace-nix-cache?region=us-east-1"
];
allow-import-from-derivation = "true";
};
# --------------------------------------------------------------

outputs = {
std,
self,
nix-helm,
devshell,
...
} @ inputs:
inputs.flake-parts.lib.mkFlake {inherit inputs;} {
imports = with inputs; [
imports = [
std.flakeModule
devshell.flakeModule
./nix/local/envs.nix
];
systems = ["x86_64-linux"];

perSystem = {
pkgs,
system,
...
}: {
legacyPackages.cardano-services = import ./nix/cardano-services/deployments {inherit pkgs nix-helm inputs;};
};
systems = ["x86_64-linux" "aarch64-linux" "aarch64-darwin"];

std.grow = {
std.grow = with inputs; {
cellsFrom = ./nix;
cellBlocks = with std.blockTypes; [
# Software Delivery Lifecycle (Local Development Environment)
(devshells "envs")
(runnables "jobs")
# Software Delivery Lifecycle (Packaging Layers)
# For deeper context, please consult:
Expand All @@ -53,5 +60,19 @@
(containers "oci-images" {ci.publish = true;})
];
};

std.harvest = {
packages = [["local" "packages"] ["local" "jobs"]];
devShells = [["local" "envs"] ["desktop" "envs"]];
hydraJobs = ["desktop" "hydraJobs"];
};

perSystem = {
pkgs,
system,
...
}: {
legacyPackages.cardano-services = import ./nix/cardano-services/deployments {inherit pkgs nix-helm inputs;};
};
};
}
4 changes: 2 additions & 2 deletions nix/cardano-services/deployments/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ in
projectors = {
handle.enabled = true;
stake-pool.enabled = true;
# asset.enabled = true;
asset.enabled = true;
};

values = {
Expand Down Expand Up @@ -479,7 +479,7 @@ in
projectors = {
handle.enabled = true;
stake-pool.enabled = true;
# asset.enabled = true;
asset.enabled = true;
};

values = {
Expand Down
2 changes: 1 addition & 1 deletion nix/cardano-services/oci-images.nix
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ let
}
] ''
mkdir -p $out/config
cp ${builtins.path { path = self + "/compose/schedules.json"; }} $out/config/schedules.json;
cp ${builtins.path {path = self + "/compose/schedules.json";}} $out/config/schedules.json;
'';
in {
cardano-services = std.lib.ops.mkStandardOCI {
Expand Down
Loading

0 comments on commit 0d8f188

Please sign in to comment.