SciCatProject / frontend

SciCat open data catalogue web client
https://scicatproject.github.io
BSD 3-Clause "New" or "Revised" License
23 stars 26 forks source link

Error generating sdk package for local development #1643

Open nitrosx opened 2 hours ago

nitrosx commented 2 hours ago

Issue Name

Error generating sdk package for local development

Summary

I tried to run the sdk generation locally using the npm command, and I received the following output and error:

npm run generate:sdk:local

> scicat-frontend@4.5.0 generate:sdk:local
> node scripts/generate-nestjs-sdk

Cleanup old files...
Generating the new sdk...
Unable to find image 'openapitools/openapi-generator-cli:v7.9.0' locally
v7.9.0: Pulling from openapitools/openapi-generator-cli
521f275cc58b: Pulling fs layer
...
1a31074fb300: Pull complete
Digest: sha256:bb32f5f0c9f5bdbb7b00959e8009de0230aedc200662701f05fc244c36f967ba
Status: Downloaded newer image for openapitools/openapi-generator-cli:v7.9.0
docker: Error response from daemon: create %cd%: "%cd%" includes invalid characters for a local volume name, only "[a-zA-Z0-9][a-zA-Z0-9_.-]" are allowed. If you intended to pass a host directory, use absolute path.
See 'docker run --help'.
node:child_process:965
    throw err;
    ^

Error: Command failed: docker run --rm -v "%cd%:/local" openapitools/openapi-generator-cli:v7.9.0 generate -i http://host.docker.internal:3000/explorer-json -g typescript-angular -o local/@scicatproject/scicat-sdk-ts --additional-properties=ngVersion=16.2.12,npmName=@scicatproject/scicat-sdk-ts,supportsES6=true,npmVersion=10.8.2,withInterfaces=true
Unable to find image 'openapitools/openapi-generator-cli:v7.9.0' locally
v7.9.0: Pulling from openapitools/openapi-generator-cli
521f275cc58b: Pulling fs layer
...
1a31074fb300: Pull complete
Digest: sha256:bb32f5f0c9f5bdbb7b00959e8009de0230aedc200662701f05fc244c36f967ba
Status: Downloaded newer image for openapitools/openapi-generator-cli:v7.9.0
docker: Error response from daemon: create %cd%: "%cd%" includes invalid characters for a local volume name, only "[a-zA-Z0-9][a-zA-Z0-9_.-]" are allowed. If you intended to pass a host directory, use absolute path.
See 'docker run --help'.

    at checkExecSyncError (node:child_process:890:11)
    at execSync (node:child_process:962:15)
    at Object.<anonymous> (/home/nitrosx/repos/scicat-frontend/scripts/generate-nestjs-sdk.js:17:26)
    at Module._compile (node:internal/modules/cjs/loader:1364:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1422:10)
    at Module.load (node:internal/modules/cjs/loader:1203:32)
    at Module._load (node:internal/modules/cjs/loader:1019:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:128:12)
    at node:internal/main/run_main_module:28:49 {
  status: 125,
  signal: null,
  output: [
    null,
    '',
    "Unable to find image 'openapitools/openapi-generator-cli:v7.9.0' locally\n" +
      'v7.9.0: Pulling from openapitools/openapi-generator-cli\n' +
      '521f275cc58b: Pulling fs layer\n' +
      ...
      '1a31074fb300: Pull complete\n' +
      'Digest: sha256:bb32f5f0c9f5bdbb7b00959e8009de0230aedc200662701f05fc244c36f967ba\n' +
      'Status: Downloaded newer image for openapitools/openapi-generator-cli:v7.9.0\n' +
      'docker: Error response from daemon: create %cd%: "%cd%" includes invalid characters for a local volume name, only "[a-zA-Z0-9][a-zA-Z0-9_.-]" are allowed. If you intended to pass a host directory, use absolute path.\n' +
      "See 'docker run --help'.\n"
  ],
  pid: 30566,
  stdout: '',
  stderr: "Unable to find image 'openapitools/openapi-generator-cli:v7.9.0' locally\n" +
    'v7.9.0: Pulling from openapitools/openapi-generator-cli\n' +
    '521f275cc58b: Pulling fs layer\n' +
    ...
    '1a31074fb300: Pull complete\n' +
    'Digest: sha256:bb32f5f0c9f5bdbb7b00959e8009de0230aedc200662701f05fc244c36f967ba\n' +
    'Status: Downloaded newer image for openapitools/openapi-generator-cli:v7.9.0\n' +
    'docker: Error response from daemon: create %cd%: "%cd%" includes invalid characters for a local volume name, only "[a-zA-Z0-9][a-zA-Z0-9_.-]" are allowed. If you intended to pass a host directory, use absolute path.\n' +
    "See 'docker run --help'.\n"
}

Node.js v18.20.3

Steps to Reproduce

Cloned repo and pull new-sdk-release branch. Run command npm run generate:sdk:local

nitrosx commented 2 hours ago

The issue is that the docker command to generated the sdk is missing the following option --add-host host.docker.internal:host-gateway which is needed for linux environments:

The full command should be: ker run --rm --add-host host.docker.internal:host-gateway -v "cd:/local" openapitools/openapi-generator-cli:v7.9.0 generate -i http://host.docker.internal:3000/explorer-json -g typescript-angular -o local/@scicatproject/scicat-sdk-ts --additional-properties=ngVersion=16.2.12,npmName=@scicatproject/scicat-sdk-ts,supportsES6=true,npmVersion=10.8.2,withInterfaces=true

nitrosx commented 2 hours ago

I was finally able to generate the sdk locally with the following command:

docker run 
  --rm 
  --add-host host.docker.internal:host-gateway 
  -v "./node_modules:/local" 
  openapitools/openapi-generator-cli:v7.9.0 
   generate 
   -i http://host.docker.internal:3000/explorer-json 
   -g typescript-angular 
   -o local/@scicatproject/scicat-sdk-ts 
   --additional-properties=ngVersion=16.2.12,npmName=@scicatproject/scicat-sdk-ts,supportsES6=true,npmVersion=10.8.2,withInterfaces=true

My dev environment is linux: ubuntu base linuxmint