Closed tuananh closed 6 years ago
Hey,
Can you provide any more info on this to replicate? Is it within a Docker? Did you look and see which port was actually used?
Thanks!
Yes, it's within Docker container. download-chrome.sh
script is from chrome-launcher repo
The port looks random to me and it's different every build
FROM bitnami/node:10 as builder
ENV CHROME_PATH /myapp/chrome-linux/chrome
WORKDIR /myapp
# setup chrome headless so that we can run export
COPY scripts/download-chrome.sh /myapp
RUN ./download-chrome.sh
RUN npm i @pwa/cli --global
COPY package.json /myapp
RUN npm install --unsafe
COPY . /myapp
RUN pwa export
FROM nginx:1.15-alpine
COPY --from=builder /myapp/build /usr/share/nginx/html/
EXPOSE 80
this line launch({ chromeFlags }).then(proc => {
seems to be failing but when i catch it, i got nothing. so i don't know what's the actual error is
I will have to look into it over the weekend :) Off the top of my head, am not sure. If it's possible, I would export
the application locally and then have Docker start by copying over the built assets.
Thanks!
Docker start by copying over the built assets. That would work if i were to deploy from my local machine. however, i want to use ci/cd pipeline to build the docker images instead of doing it locally.
Yeah, understood 😃
I'll have time to look at this weekend!
Hey @tuananh,
Was swamped at the time, so coming back with more information:
1) Yes, the port
that chrome-launcher
uses is always random, as is the localhost
server that PWA uses. They're throwaways and aren't meant to be user-interactive, so they both use whatever port Node deems available.
2) The chrome-launcher
port is always different from the localhost
port (displayed) because CL is a separate process/server that PWA communicates with to programmatically scrape the pages. The address that PWA prints in your console is the HTTP file server (via sirv
).
So, this is a chrome-launcher
issue running in Docker. I'm not that great with Docker, but I feel like there's an answer somewhere in this Dockerfile.
A quick thing you can try for me:
Does it work if you change this line to this?
let chromeFlags = ['--headless', '--disable-gpu', '--no-sandbox'];
lemme give those a try later today
Sounds good, thank you 👏
@lukeed yes, the '--no-sandbox'
works for me. 🎇
Awesome!
Then that confirms another finding: Learned that you can't run headless Chrome without correct user permissions.
Search for "How do I create a Docker container that runs Headless Chrome?" in this article.
Here's the portion of a Docker file Google links to in order to set up the user properly: https://github.com/ebidel/lighthouse-ci/blob/master/builder/Dockerfile#L35-L40
I'm tempted just to add --no-sandbox
to the base flags but I'm reading that it's a really bad idea, which is what I figured... 🤔 Maybe it's not so bad since it's a 2 second instance?
@lukeed i tried adding chrome user like this https://github.com/ebidel/lighthouse-ci/blob/master/builder/Dockerfile#L35-L40
but the old error persists still until I add '--no-sandbox'
option.
Will take a look at this later.
Many thanks for your help
The next release with have pwa export --insecure
which adds the --no-sandbox
flag automatically.
I think that as long as sandboxing isn't disabled by default, that should be fine 😅
I'm not sure why the server started on port 36573 but somehow, it's connecting to 33435
I'm having this issue in container though, not on my local machine.