Skip to content

[BUG] useDocker is not passing the user and group when running through the passthrough service #716

Open
@devzeebo

Description

@devzeebo

⚠️ Important Notice

Please differentiate the bug

This repository is not responsible for the actual code generation. If you have problems with the code generation, please open the bug at OpenAPITools/openapi-generator.

Please also check if the bug is already known before you open a new bug.


🐛 Bug Report:

Describe the bug

#647 fixed the docker permissions for the generator.service. When executing the cli with options that use the passthrough.service instead, the docker user and group is not set, resulting in root:root permissions

Steps to Reproduce

Steps to reproduce the behavior:

  1. Run a generate command that invokes the passthrough service while using the useDocker option

Expected behavior

When using the passthrough service, the user and group flags are passed to docker

Screenshots

If applicable, add screenshots to help explain your problem.

Operation System (please complete the following information):

  • OS: Arch / WSL
  • Version: 2023-10-31

Package System (please complete the following information):

  • Version [e.g. 22]

Additional context

Add any other context about the problem here.

Activity

kasir-barati

kasir-barati commented on Apr 21, 2024

@kasir-barati

Having same issue...

anonysoul

anonysoul commented on May 23, 2024

@anonysoul

docker run --user preventing file writing

[[v3.0] ../xsec-portal/src/main/resources/openapi/protocol.yaml] [main] WARN  o.o.c.l.AbstractTypeScriptClientCodegen - Error (model name matches existing language type) cannot be used as a model name. Renamed to ModelError
[[v3.0] ../xsec-portal/src/main/resources/openapi/protocol.yaml] [main] INFO  o.o.codegen.TemplateManager - writing file /local/output/model/./audit.ts
[[v3.0] ../xsec-portal/src/main/resources/openapi/protocol.yaml] Exception in thread "main" java.lang.RuntimeException: Could not generate model 'Audit'
[[v3.0] ../xsec-portal/src/main/resources/openapi/protocol.yaml]        at org.openapitools.codegen.DefaultGenerator.generateModels(DefaultGenerator.java:596)
[[v3.0] ../xsec-portal/src/main/resources/openapi/protocol.yaml]        at org.openapitools.codegen.DefaultGenerator.generateModels(DefaultGenerator.java:451)
[[v3.0] ../xsec-portal/src/main/resources/openapi/protocol.yaml]        at org.openapitools.codegen.DefaultGenerator.generate(DefaultGenerator.java:1304)
[[v3.0] ../xsec-portal/src/main/resources/openapi/protocol.yaml]        at org.openapitools.codegen.cmd.Generate.execute(Generate.java:535)
[[v3.0] ../xsec-portal/src/main/resources/openapi/protocol.yaml]        at org.openapitools.codegen.cmd.OpenApiGeneratorCommand.run(OpenApiGeneratorCommand.java:32)
[[v3.0] ../xsec-portal/src/main/resources/openapi/protocol.yaml]        at org.openapitools.codegen.OpenAPIGenerator.main(OpenAPIGenerator.java:66)
[[v3.0] ../xsec-portal/src/main/resources/openapi/protocol.yaml] Caused by: java.nio.file.NoSuchFileException: /local/output/model/./audit.ts
[[v3.0] ../xsec-portal/src/main/resources/openapi/protocol.yaml]        at java.base/sun.nio.fs.UnixException.translateToIOException(UnixException.java:92)
[[v3.0] ../xsec-portal/src/main/resources/openapi/protocol.yaml]        at java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:106)
[[v3.0] ../xsec-portal/src/main/resources/openapi/protocol.yaml]        at java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:111)
[[v3.0] ../xsec-portal/src/main/resources/openapi/protocol.yaml]        at java.base/sun.nio.fs.UnixFileSystemProvider.newByteChannel(UnixFileSystemProvider.java:218)
[[v3.0] ../xsec-portal/src/main/resources/openapi/protocol.yaml]        at java.base/java.nio.file.spi.FileSystemProvider.newOutputStream(FileSystemProvider.java:484)
[[v3.0] ../xsec-portal/src/main/resources/openapi/protocol.yaml]        at java.base/java.nio.file.Files.newOutputStream(Files.java:228)
[[v3.0] ../xsec-portal/src/main/resources/openapi/protocol.yaml]        at java.base/java.nio.file.Files.write(Files.java:3512)
[[v3.0] ../xsec-portal/src/main/resources/openapi/protocol.yaml]        at org.openapitools.codegen.TemplateManager.writeToFileRaw(TemplateManager.java:255)
[[v3.0] ../xsec-portal/src/main/resources/openapi/protocol.yaml]        at org.openapitools.codegen.TemplateManager.writeToFile(TemplateManager.java:237)
[[v3.0] ../xsec-portal/src/main/resources/openapi/protocol.yaml]        at org.openapitools.codegen.TemplateManager.writeToFile(TemplateManager.java:198)
[[v3.0] ../xsec-portal/src/main/resources/openapi/protocol.yaml]        at org.openapitools.codegen.TemplateManager.write(TemplateManager.java:164)
[[v3.0] ../xsec-portal/src/main/resources/openapi/protocol.yaml]        at org.openapitools.codegen.DefaultGenerator.processTemplateToFile(DefaultGenerator.java:1455)
[[v3.0] ../xsec-portal/src/main/resources/openapi/protocol.yaml]        at org.openapitools.codegen.DefaultGenerator.processTemplateToFile(DefaultGenerator.java:1442)
[[v3.0] ../xsec-portal/src/main/resources/openapi/protocol.yaml]        at org.openapitools.codegen.DefaultGenerator.generateModel(DefaultGenerator.java:439)
[[v3.0] ../xsec-portal/src/main/resources/openapi/protocol.yaml]        at org.openapitools.codegen.DefaultGenerator.generateModels(DefaultGenerator.java:587)
[[v3.0] ../xsec-portal/src/main/resources/openapi/protocol.yaml]        ... 5 more
[[v3.0] ../xsec-portal/src/main/resources/openapi/protocol.yaml] docker run --rm --user 1000:1000 -v "/home/anonysoul/workspace/company/xsec-server/xsec-portal/src/main/resources/openapi/protocol.yaml:/local/input-spec" -v "/home/anonysoul/workspace/company/xsec-server/xsec-webapp/src/app/core/openapi:/local/output" anonysoul/openapi-generator-cli:v7.6.0 generate --input-spec="/local/input-spec" --generator-name="typescript-angular" --output="/local/output" --additional-properties="fileNaming=kebab-case,withInterfaces=true" --generate-alias-as-model exited with code 1
[v3.0] ../xsec-portal/src/main/resources/openapi/protocol.yaml
  docker run --rm --user 1000:1000 -v "/home/anonysoul/workspace/company/xsec-server/xsec-portal/src/main/resources/openapi/protocol.yaml:/local/input-spec" -v "/home/anonysoul/workspace/company/xsec-server/xsec-webapp/src/app/core/openapi:/local/output" anonysoul/openapi-generator-cli:v7.6.0 generate --input-spec="/local/input-spec" --generator-name="typescript-angular" --output="/local/output" --additional-properties="fileNaming=kebab-case,withInterfaces=true" --generate-alias-as-model

Code generation failed

❌ [openapi-generate] exited with exit code 1.
❌ 1 script failed.
joebb97

joebb97 commented on Dec 24, 2024

@joebb97

Hey I'm seeing the same issue and am having to write my own Dockerfile which adds my user to get around this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

    Participants

    @devzeebo@joebb97@kay-schecker@kasir-barati@anonysoul

    Issue actions

      [BUG] useDocker is not passing the user and group when running through the passthrough service · Issue #716 · OpenAPITools/openapi-generator-cli