Skip to content

Commit

Permalink
SK-1426: fix deployment (#1135)
Browse files Browse the repository at this point in the history
  • Loading branch information
arty-name authored Dec 6, 2022
1 parent c79e201 commit 306aa20
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 5 deletions.
15 changes: 10 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,15 @@ FROM base AS builder
# one of dependencies uses node-gyp which requires build tools
RUN apk add --update --no-cache python3 g++ make && ln -sf python3 /usr/bin/python

# get the dependencies and sources
# install build dependencies
# @parcel/css-linux-x64-musl is not optional but marked so
COPY package.json yarn.lock ./
RUN yarn install --frozen-lockfile --ignore-optional && yarn add --ignore-optional --dev @parcel/css-linux-x64-musl && yarn cache clean --all

# get the sources and build the app
COPY src ./src
COPY tsconfig.json ./

# install build dependencies, build the app
# @parcel/css-linux-x64-musl is not optional but marked so
RUN yarn install --frozen-lockfile --ignore-optional && yarn add --ignore-optional --dev @parcel/css-linux-x64-musl && yarn cache clean --all && yarn build
RUN yarn build

FROM base AS release

Expand All @@ -31,6 +32,10 @@ COPY package.json yarn.lock ./
# install the production dependencies only (depends on NODE_ENV)
RUN yarn install --frozen-lockfile --ignore-optional && yarn cache clean --all

# FIXME: a workaround for missing import type assertion
COPY scripts/patchVCExport.js .
RUN node /app/patchVCExport.js

# carry over the built code
COPY --from=builder /app/dist dist

Expand Down
32 changes: 32 additions & 0 deletions scripts/patchVCExport.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { readFile, writeFile } from 'node:fs/promises';

// This script patches the SDK
// * for the missing import type assertions when importing JSON inside
// * for the jsonld-signatures being CommonJS

{
const fileName =
'/app/node_modules/@kiltprotocol/vc-export/lib/esm/vc-js/context/index.js';
const text = await readFile(fileName, { encoding: 'utf-8' });
const patched = text.replace(
`import context from './context.json'`,
`import context from './context.json' assert { type: 'json' }`,
);
await writeFile(fileName, patched);
}

{
const fileName =
'/app/node_modules/@kiltprotocol/vc-export/lib/esm/vc-js/suites/KiltAbstractSuite.js';
const text = await readFile(fileName, { encoding: 'utf-8' });
const patched = text
.replace(
`import { suites, } from 'jsonld-signatures'`,
`import jsonldSignatures from 'jsonld-signatures'`,
)
.replace(
`extends suites.LinkedDataProof`,
`extends jsonldSignatures.suites.LinkedDataProof`,
);
await writeFile(fileName, patched);
}

0 comments on commit 306aa20

Please sign in to comment.