diff --git a/.github/workflows/test_federation.yml b/.github/workflows/test_federation.yml index 1c31a7d5c..4236ddfbd 100644 --- a/.github/workflows/test_federation.yml +++ b/.github/workflows/test_federation.yml @@ -68,7 +68,7 @@ jobs: - name: Federation | Unit tests id: test run: | - cd out && turbo federation#lint federation#test + cd out && turbo federation#lint federation#test federation#build federation#typecheck echo "success=$([ $? -eq 0 ] && echo true || echo false)" >> $GITHUB_OUTPUT lint: diff --git a/federation/Dockerfile b/federation/Dockerfile index a586e2006..e22a98f67 100644 --- a/federation/Dockerfile +++ b/federation/Dockerfile @@ -75,7 +75,7 @@ RUN yarn install --frozen-lockfile --production=false \ # Build the project COPY --chown=app:app --from=builder /app/out/full/ . -RUN turbo build +RUN turbo build typecheck ################################################################################## # TEST ########################################################################### @@ -95,6 +95,12 @@ FROM base as production # Copy "binary"-files from build image COPY --chown=app:app --from=installer ${DOCKER_WORKDIR}/federation/build/src/index.js ./index.js +# We also install the native node_modules which cannot be bundled +# TODO: find a elegant way to use the right versions from yarn.lock +RUN yarn add sodium-native@4.0.0 \ + && rm -rf /tmp/* ~/.cache node_modules/.cache \ + && yarn cache clean + # Copy log4js-config.json to provide log configuration COPY --chown=app:app --from=installer ${DOCKER_WORKDIR}/federation/log4js-config.json ./log4js-config.json diff --git a/federation/esbuild.config.ts b/federation/esbuild.config.ts new file mode 100644 index 000000000..38ca5b58d --- /dev/null +++ b/federation/esbuild.config.ts @@ -0,0 +1,13 @@ +import { build } from 'esbuild' + +build({ + entryPoints: ['src/index.ts'], + outdir: 'build', + platform: 'node', + target: 'node18.20.7', + bundle: true, + keepNames: true, + // legalComments: 'inline', + external: ['sodium-native'], + minify: true, +}) diff --git a/federation/package.json b/federation/package.json index c9d84ac0b..848f005b5 100644 --- a/federation/package.json +++ b/federation/package.json @@ -8,11 +8,11 @@ "license": "Apache-2.0", "private": false, "scripts": { - "build": "tsc --build", - "clean": "tsc --build --clean", - "start": "cross-env TZ=UTC TS_NODE_BASEURL=./build node -r tsconfig-paths/register build/src/index.js", + "build": "tsx esbuild.config.ts", + "start": "cross-env TZ=UTC node build/index.js", + "dev": "cross-env TZ=UTC tsx watch src/index.ts", + "typecheck": "tsc --noEmit", "test": "cross-env TZ=UTC NODE_ENV=development DB_DATABASE=gradido_test_federation jest --runInBand --forceExit --detectOpenHandles", - "dev": "cross-env TZ=UTC nodemon -w src --ext ts --exec ts-node -r dotenv/config -r tsconfig-paths/register src/index.ts", "lint": "biome check --error-on-warnings .", "lint:fix": "biome check --error-on-warnings . --write" },