Skip to content

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

Open
@abalshakou

Description

@abalshakou

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

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingneeds-triageA pull request or issue that needs to be triaged prior to being synced to JIRA

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions