# syntax = docker/dockerfile:1
# Adjust NODE_VERSION as desired
ARG NODE_VERSION=20.11.1
FROM node:${NODE_VERSION}-slim as base
LABEL fly_launch_runtime="Node.js"
# Node.js app lives here
WORKDIR /app
# Set production environment
ENV NODE_ENV="production"
# Throw-away build stage to reduce size of final image
FROM base as build
# Install node modules
COPY --link package-lock.json package.json ./
RUN npm ci
# Copy application code
COPY --link . .
# Final stage for app image
FROM base
# Install packages needed to build node modules
RUN apt-get update -qq && \
apt-get install -y build-essential node-gyp pkg-config python-is-python3
RUN apt-get install -y chromium chromium-sandbox \
fonts-ipafont-gothic \
fonts-noto \
fonts-noto-cjk \
fonts-noto-color-emoji \
--no-install-recommends && \
apt-get clean && \
rm -rf /var/lib/apt/lists /var/cache/apt/archives
RUN apt-get install -y python-is-python3
RUN apt-get install -y python3-pip
# Copy built application
COPY --from=build /app /app
RUN pip install -r requirements.txt
# Start the server by default, this can be overwritten at runtime
EXPOSE 8080
CMD [ "node", "index.js" ]
(You don’t need to install python-is-python3 because you do install it in the previous RUN line, but I put it there for consistency. Up to you to decide which of the two installs to keep.)
thank you for your help it works, but when I run the python file this error appears, even though chromium can be used for puppeteer
2024-03-17T09:06:50.737 app[3d8d909fee4ed8] sin [info] Error executing Python script: Error: Command failed: python /app/command/scrap.py
2024-03-17T09:06:50.738 app[3d8d909fee4ed8] sin [info] Traceback (most recent call last):
2024-03-17T09:06:50.738 app[3d8d909fee4ed8] sin [info] File "/app/command/scrap.py", line 142, in <module>
2024-03-17T09:06:50.738 app[3d8d909fee4ed8] sin [info] dataframes = scrape_table_selenium(url)
2024-03-17T09:06:50.738 app[3d8d909fee4ed8] sin [info] ^^^^^^^^^^^^^^^^^^^^^^^^^^
2024-03-17T09:06:50.738 app[3d8d909fee4ed8] sin [info] File "/app/command/scrap.py", line 14, in scrape_table_selenium
2024-03-17T09:06:50.738 app[3d8d909fee4ed8] sin [info] driver = webdriver.Chrome(options=options)
2024-03-17T09:06:50.738 app[3d8d909fee4ed8] sin [info] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2024-03-17T09:06:50.738 app[3d8d909fee4ed8] sin [info] File "/venv/lib/python3.11/site-packages/selenium/webdriver/chrome/webdriver.py", line 45, in __init__
2024-03-17T09:06:50.738 app[3d8d909fee4ed8] sin [info] super().__init__(
2024-03-17T09:06:50.738 app[3d8d909fee4ed8] sin [info] File "/venv/lib/python3.11/site-packages/selenium/webdriver/chromium/webdriver.py", line 61, in __init__
2024-03-17T09:06:50.738 app[3d8d909fee4ed8] sin [info] super().__init__(command_executor=executor, options=options)
2024-03-17T09:06:50.738 app[3d8d909fee4ed8] sin [info] File "/venv/lib/python3.11/site-packages/selenium/webdriver/remote/webdriver.py", line 208, in __init__
2024-03-17T09:06:50.738 app[3d8d909fee4ed8] sin [info] self.start_session(capabilities)
2024-03-17T09:06:50.738 app[3d8d909fee4ed8] sin [info] File "/venv/lib/python3.11/site-packages/selenium/webdriver/remote/webdriver.py", line 292, in start_session
2024-03-17T09:06:50.738 app[3d8d909fee4ed8] sin [info] response = self.execute(Command.NEW_SESSION, caps)["value"]
2024-03-17T09:06:50.738 app[3d8d909fee4ed8] sin [info] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2024-03-17T09:06:50.738 app[3d8d909fee4ed8] sin [info] File "/venv/lib/python3.11/site-packages/selenium/webdriver/remote/webdriver.py", line 347, in execute
2024-03-17T09:06:50.738 app[3d8d909fee4ed8] sin [info] self.error_handler.check_response(response)
2024-03-17T09:06:50.738 app[3d8d909fee4ed8] sin [info] File "/venv/lib/python3.11/site-packages/selenium/webdriver/remote/errorhandler.py", line 229, in check_response
2024-03-17T09:06:50.738 app[3d8d909fee4ed8] sin [info] raise exception_class(message, screen, stacktrace)
2024-03-17T09:06:50.738 app[3d8d909fee4ed8] sin [info] selenium.common.exceptions.SessionNotCreatedException: Message: session not created: Chrome failed to start: exited normally.
2024-03-17T09:06:50.738 app[3d8d909fee4ed8] sin [info] (session not created: DevToolsActivePort file doesn't exist)
2024-03-17T09:06:50.738 app[3d8d909fee4ed8] sin [info] (The process started from chrome location /usr/bin/chromium is no longer running, so ChromeDriver is assuming that Chrome has crashed.)
2024-03-17T09:06:50.738 app[3d8d909fee4ed8] sin [info] Stacktrace:
2024-03-17T09:06:50.738 app[3d8d909fee4ed8] sin [info] #0 0x55f3e9d9af33 <unknown>
2024-03-17T09:06:50.738 app[3d8d909fee4ed8] sin [info] #1 0x55f3e9a92ce6 <unknown>
2024-03-17T09:06:50.738 app[3d8d909fee4ed8] sin [info] #2 0x55f3e9ac76fa <unknown>
2024-03-17T09:06:50.738 app[3d8d909fee4ed8] sin [info] #3 0x55f3e9ac36ed <unknown>
2024-03-17T09:06:50.738 app[3d8d909fee4ed8] sin [info] #4 0x55f3e9b0c71c <unknown>
2024-03-17T09:06:50.738 app[3d8d909fee4ed8] sin [info] #5 0x55f3e9affc53 <unknown>
2024-03-17T09:06:50.738 app[3d8d909fee4ed8] sin [info] #6 0x55f3e9ad0db3 <unknown>
2024-03-17T09:06:50.738 app[3d8d909fee4ed8] sin [info] #7 0x55f3e9ad177e <unknown>
2024-03-17T09:06:50.738 app[3d8d909fee4ed8] sin [info] #8 0x55f3e9d6086b <unknown>
2024-03-17T09:06:50.738 app[3d8d909fee4ed8] sin [info] #9 0x55f3e9d64885 <unknown>
2024-03-17T09:06:50.738 app[3d8d909fee4ed8] sin [info] #10 0x55f3e9d4e181 <unknown>
2024-03-17T09:06:50.738 app[3d8d909fee4ed8] sin [info] #11 0x55f3e9d65412 <unknown>
2024-03-17T09:06:50.738 app[3d8d909fee4ed8] sin [info] #12 0x55f3e9d3225f <unknown>
2024-03-17T09:06:50.738 app[3d8d909fee4ed8] sin [info] #13 0x55f3e9d89528 <unknown>
2024-03-17T09:06:50.738 app[3d8d909fee4ed8] sin [info] #14 0x55f3e9d89723 <unknown>
2024-03-17T09:06:50.738 app[3d8d909fee4ed8] sin [info] #15 0x55f3e9d9a0e4 <unknown>
2024-03-17T09:06:50.738 app[3d8d909fee4ed8] sin [info] #16 0x7fe5a81be134 <unknown>