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

Rebranding issues when trying to change logos using environment variables #432

Closed
DominikZublasing opened this issue Oct 18, 2022 · 10 comments

Comments

@DominikZublasing
Copy link

Hello, i am trying to use the new rebranding feature, but I'm currently unable to proceed.
I tried specifying the brand logos and brand icons via environment variables in the docker-compose file, but the program won't recognize them.

Following is a partial view of the docker-compose.yml I'm using.

  environment:
        ....      
        PWP__BRAND__LIGHT_LOGO: 'media/img/test/light/Logo_LT_192x192.png'
        PWP__BRAND__DARK_LOGO: 'media/img/test/dark/Logo_DK_192x192.png'
  
  volumes:
        - /opt/pwpush/app/img/:/opt/PasswordPusher/public/packs/media/img/test

The image files on my host are located under /opt/pwpush/app/img/light and /opt/pwpush/app/img/dark.
I also tried giving the environment variable the absolute path to be on the safe side, but that didn't work.

I've come to notice that the log file keeps writing the following error, which seems to me like the program isn't aware of any new branding files.

  • relative Path:
    ActionController::RoutingError (No route matches [GET] "/media/img/test/light/Logo_LT_192x192.png"):

  • absolute Path:
    ActionController::RoutingError (No route matches [GET] "/opt/PasswordPusher/public/packs/media/img/test/light/Logo_LT_192x192.png"):

In addition to that, i've seen that there is a manifest.js file under public/packs/manifest.json which seems to have some kind of resource mapping, but with no entry of the newly added image files.

Lastly i tried using the documented method of http resources as the image path for the branding, which worked perfectly fine.

  environment:
        ....      
        PWP__BRAND__LIGHT_LOGO: 'https://images.ctfassets.net/lzny33ho1g45/password-security-p-img/72f3ab78724796a0990219ee8ed495c7/file.png?w=1520&fm=jpg&q=30&fit=thumb&h=760'
        PWP__BRAND__DARK_LOGO: 'https://images.ctfassets.net/lzny33ho1g45/password-security-p-img/72f3ab78724796a0990219ee8ed495c7/file.png?w=1520&fm=jpg&q=30&fit=thumb&h=760'
@pglombardo
Copy link
Owner

Hrm - could you try changing the mount path as follows:

volumes:
        - /opt/pwpush/app/img/:/opt/PasswordPusher/app/frontend/img/test

Assuming that you are using one of the Docker containers, the command in the Dockerfile bundle exec rails webpacker:compile will recompile assets from that directory and place them into /opt/PasswordPusher/public/packs/media/img/test automagically.

Try changing that path and relaunch the container. On Docker container boot, bundle exec rails webpacker:compile is automatically run so newly detected assets will get compiled/included in the asset pack.

@DominikZublasing
Copy link
Author

I changed the mounting path as suggested, but unfortunately nothing changed.
In addition to that, I've seen that no file has been copied to /opt/PasswordPusher/public/packs/media/img/test and no new entry was generated in the ~/public/packs/manifest.json file.

I'm currently using this image pglombardo/pwpush-postgres:latest.

@pglombardo
Copy link
Owner

Give me a bit and I'll test this out today.

@pglombardo
Copy link
Owner

Ok my bad that I missed this. Adding custom logos has to be done outside of the asset pack and instead directly in public.

Mount your images to /opt/PasswordPusher/public/custom_images (as an example) and then set your environment variables in this pattern PWP__BRAND__LIGHT_LOGO: '/custom_images/Logo_LT_192x192.png'.

I just tested this locally with this config (and result):

Screenshot 2022-10-18 at 12 14 07

Screenshot 2022-10-18 at 12 12 39

@DominikZublasing
Copy link
Author

I've followed your instructions and the logos seem to be working now.

Unfortunately, I have noticed that the brand symbols do not work in the same way as the logos.
Configuring the icons the same way as i did for the logos leads to this error message:

ActionView::Template::Error (Webpacker can't find /test/dark/Logo_DK_57x57.png in /opt/PasswordPusher/public/packs/manifest.json. Possible causes:
1. You want to set webpacker.yml value of compile to true for your environment
   unless you are using the `webpack -w` or the webpack-dev-server.
2. webpack has not yet re-run to reflect updates.
3. You have misconfigured Webpacker's config/webpacker.yml file.
4. Your webpack configuration is not creating a manifest.

Any idea why it behaves this way?

@pglombardo
Copy link
Owner

This is a bug - I'll put in a fix very soon. Once it's fixed, it'll work the same way as the main logo.

@DominikZublasing
Copy link
Author

Ok, thank you

@pglombardo
Copy link
Owner

Could you try your changes with the new docker image/tag: pglombardo/pwpush-postgres:1.17.8

Let me know how it goes. That image should fix the icon branding.

@DominikZublasing
Copy link
Author

DominikZublasing commented Oct 18, 2022

Works perfectly, no errors and the icon is getting displayed.
Thank you

@pglombardo
Copy link
Owner

Excellent. Thanks for pointing out the issue(s). I'll point the release tag to that image sometime soon.

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

No branches or pull requests

2 participants