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

[bug]: local-intercept doesnt work in docker container #4321

Open
1 of 8 tasks
abalshakou opened this issue Sep 16, 2024 · 3 comments
Open
1 of 8 tasks

[bug]: local-intercept doesnt work in docker container #4321

abalshakou opened this issue Sep 16, 2024 · 3 comments
Labels

Comments

@abalshakou
Copy link

abalshakou commented Sep 16, 2024

Describe the bug

My local-interept.js do nothing inside docker composer container. If i use same code on local build - it works as needed - on dev mode or on build

To reproduce

Steps to reproduce the behavior:

  1. Put my developer code to docker container with Dockerfile

`FROM node:18.17.0

ENV PATH /node_modules/.bin:$PATH

RUN apt-get update && apt-get install -y sudo openssl && apt-get clean

RUN usermod -u 1001 node
RUN groupmod -g 1001 node

RUN groupadd -g 1000 customuser
RUN useradd --no-log-init -d /home/customuser -s /bin/bash -u 1000 -g customuser customuser
RUN echo "customuser:customuser" | chpasswd && adduser customuser sudo

RUN mkdir -p /home/customuser
RUN chown -R customuser:customuser /home/customuser

ENV NODE_OPTIONS=--openssl-legacy-provider
ENV NODE_TLS_REJECT_UNAUTHORIZED=0
ENV MAGENTO_BACKEND_URL=https://staging.x.com/
ENV PORT=443
ENV CHECKOUT_BRAINTREE_TOKEN=xxx

COPY . .
RUN ls -la
RUN export NODE_TLS_REJECT_UNAUTHORIZED=0
RUN export NODE_OPTIONS=--openssl-legacy-provider
RUN export MAGENTO_BACKEND_URL=https://staging.x.com/
RUN export PORT=443
RUN export CHECKOUT_BRAINTREE_TOKEN=xxx
RUN yarn

RUN yarn build
USER customuser

CMD ["yarn", "start"]`

my local-intercept like this:

`const { Targetables } = require('@magento/pwa-buildpack');

function localIntercept(targets) {
const targetables = Targetables.using(targets);

const productComponent = targetables.reactComponent(
    '@magento/venia-ui/lib/RootComponents/Product/product.js'
);

productComponent.insertBeforeSource(
    "import { useProduct } from '@magento/peregrine/lib/talons/RootComponents/Product/useProduct';",
    '// Removed existing import\n'
);

productComponent.addImport(
    "import { useProduct as useCustomProduct } from 'src/talons/ProductFullDetail/useProduct';"
);

productComponent.spliceSource({
    before: 'useProduct({',
    insert: 'useCustomProduct({',
    remove: 'useProduct({'.length
});

}

module.exports = localIntercept;
`
2. docker-compose build
3. docker-compose up -d
4. go to localhost:443
5. see what local-intercept do nothing

Expected behavior

My pwa works as local-intercept.js has nothing inside
I have no errors in docker logs or console of browser or something else

Possible solutions

I need more info how local-intercept.js works, maybe it depends of not clean decision what i dont find in docs

Please complete the following device information:

  • Device [e.g. iPhone6, PC, Mac, Pixel3]: ASUSTeK COMPUTER INC. ASUS EXPERTBOOK B2502CBA_B2502CBA , Debian GNU/Linux 12 (bookworm) 64-bit 43.9 Wayland
  • Browser [e.g. Chrome, Safari]: Chrome , firefox
  • Browser Version [e.g. 22]: Version 128.0.6613.84 (Official Build) built on Debian GNU/Linux 12 (bookworm) (64-bit)
  • Magento Version [e.g Adobe Commerce 2.4]: PWA Studio Release 14.0.1

Please let us know what packages this bug is in regards to:

  • venia-concept
  • venia-ui
  • pwa-buildpack
  • peregrine
  • pwa-devdocs
  • upward-js
  • upward-spec
  • create-pwa
@abalshakou abalshakou added the bug Something isn't working label Sep 16, 2024
Copy link

m2-assistant bot commented Sep 16, 2024

Hi @abalshakou. Thank you for your report.
To speed up processing of this issue, make sure that you provided sufficient information.
Add a comment to assign the issue: @magento I am working on this


Join Magento Community Engineering Slack and ask your questions in #github channel.

@glo82145
Copy link
Collaborator

@adobe export issue to JIRA project PWA as Bug

@github-jira-sync-bot
Copy link

✅ Jira issue https://jira.corp.adobe.com/browse/PWA-3355 is successfully created for this GitHub issue.

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

No branches or pull requests

3 participants