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

Docker container for arm64 #5

Open
jairoxyz opened this issue Jun 9, 2024 · 4 comments
Open

Docker container for arm64 #5

jairoxyz opened this issue Jun 9, 2024 · 4 comments

Comments

@jairoxyz
Copy link

jairoxyz commented Jun 9, 2024

Thanks for the great work. Is it possible to create a docker image and run the container on arm64? The package google-chrome-stable would need to be replaced with chromium-browser which is available for ARM. Would that work?

Jx-

@zfcsoftware
Copy link
Owner

It should work without modification. Please let me know if you have problems. I will test and update.

@jairoxyz
Copy link
Author

jairoxyz commented Jun 9, 2024

Hi there, so far I managed to build on AMD using chromium install from debian repository. I believe wget, gnupg, ca-certs and apt-transport-https are not needed if we don't use the google repo, right? This is the dockerfile I use:

FROM node:22-slim

ARG TARGETPLATFORM
ARG BUILDPLATFORM
ARG TARGETARCH

RUN printf "I am running on ${BUILDPLATFORM}, building for ${TARGETPLATFORM}\n"

# Install necessary dependencies for running Chrome
RUN apt-get update && apt-get install -y \
    xvfb \
    chromium \
    && rm -rf /var/lib/apt/lists/*

# Set up the working directory in the container
WORKDIR /app

# Copy package.json and package-lock.json to the working directory
COPY package*.json ./

# Install Node.js dependencies
RUN npm install
RUN npm install -g pm2

# Copy the rest of the application code
COPY . .

# Expose the port your app runs on
EXPOSE 3001

# Command to run the application
CMD ["pm2-runtime", "index.js"]

Next I want to try if a smaller alpine base image works too :)

Jx-

@zfcsoftware
Copy link
Owner

Hi there, so far I managed to build on AMD using chromium install from debian repository. I believe wget, gnupg, ca-certs and apt-transport-https are not needed if we don't use the google repo, right? This is the dockerfile I use:

FROM --platform=${BUILDPLATFORM} node:22.2-slim

ARG TARGETPLATFORM
ARG BUILDPLATFORM
ARG TARGETARCH

RUN printf "I am running on ${BUILDPLATFORM}, building for ${TARGETPLATFORM}\n"

# Install necessary dependencies for running Chrome
RUN apt-get update && apt-get install -y \
    xvfb \
    chromium \
    && rm -rf /var/lib/apt/lists/*

# Set up the working directory in the container
WORKDIR /app

# Copy package.json and package-lock.json to the working directory
COPY package*.json ./

# Install Node.js dependencies
RUN npm install
RUN npm install -g pm2

# Copy the rest of the application code
COPY . .

# Expose the port your app runs on
EXPOSE 3001

# Command to run the application
CMD ["pm2-runtime", "index.js"]

Next I want to try if a smaller alpine base image works too :)

Jx-

Honestly, I didn't care much about the Dockerfile, copilot filled it automatically. I did some tests and started using it. You can test it by deleting dependencies one by one.

@jairoxyz
Copy link
Author

jairoxyz commented Jun 9, 2024

My build with buildx for arm64 completed and container runs fine on my Rpi but there is an error with Chrome:

Failed to launch the browser process!
/home/admin/.cache/puppeteer/chrome/linux-124.0.6367.201/chrome-linux64/chrome: 3: Syntax error: Unterminated quoted string

I also tried locally with node and installed xvfb and chromium with apt-get but same error.

Maybe I have to tell puppeteer where chromium is:

const browser: puppeteer.Browser = await puppeteer.launch({
  executablePath: '/usr/bin/chromium', <-------
  }); 

Yes, that works. So, strange it would not be able to launch the chrome browser packaged with puppeteer but it works with chromium installed with apt-get.

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

No branches or pull requests

2 participants