Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support debug-embed of rust_embed #268

Closed
cemoktra opened this issue Sep 2, 2022 · 13 comments
Closed

support debug-embed of rust_embed #268

cemoktra opened this issue Sep 2, 2022 · 13 comments

Comments

@cemoktra
Copy link

cemoktra commented Sep 2, 2022

Hey,

it would be nice to allow to select the debug-embed feature from utoipa-swagger-ui. It's either this or a problem with running the swagger-ui in distroless.

@cemoktra cemoktra changed the title swagger-ui is not working in distroless support debug-embed of rust_embed Sep 2, 2022
@juhaku
Copy link
Owner

juhaku commented Sep 2, 2022

Hello,

This is a good question indeed, I haven't tried with distroless image before, but my rough guess points to how the rust_embed which is the create used underneath handles the embedded files. And it seems like in distroless case it does not find the files or they will never get included.

Snippet from the utoipa-swagger-ui/src/lib.rs

#[derive(RustEmbed)]

#[derive(RustEmbed)]
#[folder = "$UTOIPA_SWAGGER_DIR/$UTOIPA_SWAGGER_UI_VERSION/dist/"]
struct SwaggerUiDist;

And the build.rs file is the bulid script that suppose to set the variables in place where the files will be located.
https://github.com/juhaku/utoipa/blob/59c9c1275f0e07b632c33767cbf38508570b024b/utoipa-swagger-ui/build.rs

The build script is bit tricky to debug since its run at background and does not really give any user output. But it might be that the distroless case is not correctly handled by this build.rs. Where is the distroless image build? Is the configuration somehow special compared to the regular image.

Another thing that comes to my mind is that the rust_embed is being used with feature flag interpolate-folder-path not sure whether the distroless is able to handle the interpolated folder path from environment varialbes like the reqular distroful images are?

@cemoktra
Copy link
Author

cemoktra commented Sep 2, 2022

Oh as you typed i changed the description cause i think we were using debug builds, meaning it wont be embedded at all

@juhaku
Copy link
Owner

juhaku commented Sep 2, 2022

Right, I could add this feature flag available for such a case like this, but will not enable it by default for everyone. So then the utoipa-swagger-ui could be defined with feature features = ["debug-embed"].

@cemoktra
Copy link
Author

cemoktra commented Sep 2, 2022

Yes that would be nice

@cemoktra
Copy link
Author

cemoktra commented Sep 2, 2022

Despite this being a good idea. Likely it'ss not the problem as we do not specify --release but the build has debug = false which should make rust_embed, embed the file. So maybe it's its about interpolate-folder-path, but i don't see any deps that might cause problems

@juhaku
Copy link
Owner

juhaku commented Sep 2, 2022

Yeah, maybe it's worth debugging the rust_embed itself whether it is able to embed files in distroless environment with or without interpolate-folder-path flag to narrow down the possible source of issue if the feature flag is not helping on this one.

@juhaku
Copy link
Owner

juhaku commented Sep 2, 2022

I added the feature and it can be found from master: ab7efd2

@cemoktra
Copy link
Author

cemoktra commented Sep 2, 2022

Great. I will try this latest next week

@cemoktra
Copy link
Author

cemoktra commented Sep 2, 2022

Ok I found a minute to check. The 'debug-embed' feature solved the issue. Any plan on doing the next release?

@juhaku
Copy link
Owner

juhaku commented Sep 2, 2022

Okay nice, 👍 I could create a new release from utoipa-swagger-ui latest tomorrow with the additional feature flag.

@juhaku
Copy link
Owner

juhaku commented Sep 2, 2022

Actually just released it 🙂

@cemoktra
Copy link
Author

cemoktra commented Sep 3, 2022

awesome, thx

@juhaku
Copy link
Owner

juhaku commented Mar 21, 2023

Relates to #527

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants