using google chrome for automation in SAP BTP using CAP

Below are the steps to use google chrome in SAP BTP using SAP CAP. We will be using docker to install google chrome and use the build as docker instead of nodejs in MTA.YAML

Dockerfile

# Base image
FROM node:20.18.0

# Install required dependencies for Google Chrome and Puppeteer
RUN apt-get update && apt-get install gnupg wget -y &&
wget –quiet –output-document=- https://dl-ssl.google.com/linux/linux_signing_key.pub | gpg –dearmor > /etc/apt/trusted.gpg.d/google-archive.gpg &&
sh -c ‘echo “deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main” >> /etc/apt/sources.list.d/google.list’ &&
apt-get update &&
apt-get install google-chrome-stable -y –no-install-recommends &&
rm -rf /var/lib/apt/lists/*

# Copy the current directory to /app in the Docker container
WORKDIR /app
# # Copy package.json and package-lock.json to install dependencies
COPY gen/srv/package.json gen/srv/package-lock.json ./

# Install dependencies
RUN npm ci
COPY gen/srv /app

# Set environment variable for production
ENV NODE_ENV=production

# # Expose the port your app runs on (adjust if necessary)
EXPOSE 4004

# # Start the application in watch mode
CMD [“npx”, “cds”, “serve”]

make sure build parameters no-source: true as this will ensure it uses docker for build. Once deployed you can use ssh to verify docker is installed

modules:
– name: <app>-srv
type: application
parameters:
docker:
image: <docker-user-name>/<app>-dev:latest
memory: 1G
disk-quota: 3G
requires:
– name: <app>-uaa
provides:
– name: srv-api
properties:
srv-url: ${default-url} # Ensure this is set correctly
build-parameters:
no-source: true

 

 

 

​ Below are the steps to use google chrome in SAP BTP using SAP CAP. We will be using docker to install google chrome and use the build as docker instead of nodejs in MTA.YAMLDockerfile# Base image
FROM node:20.18.0

# Install required dependencies for Google Chrome and Puppeteer
RUN apt-get update && apt-get install gnupg wget -y &&
wget –quiet –output-document=- https://dl-ssl.google.com/linux/linux_signing_key.pub | gpg –dearmor > /etc/apt/trusted.gpg.d/google-archive.gpg &&
sh -c ‘echo “deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main” >> /etc/apt/sources.list.d/google.list’ &&
apt-get update &&
apt-get install google-chrome-stable -y –no-install-recommends &&
rm -rf /var/lib/apt/lists/*

# Copy the current directory to /app in the Docker container
WORKDIR /app
# # Copy package.json and package-lock.json to install dependencies
COPY gen/srv/package.json gen/srv/package-lock.json ./

# Install dependencies
RUN npm ci
COPY gen/srv /app

# Set environment variable for production
ENV NODE_ENV=production

# # Expose the port your app runs on (adjust if necessary)
EXPOSE 4004

# # Start the application in watch mode
CMD [“npx”, “cds”, “serve”]make sure build parameters no-source: true as this will ensure it uses docker for build. Once deployed you can use ssh to verify docker is installedmodules:
– name: <app>-srv
type: application
parameters:
docker:
image: <docker-user-name>/<app>-dev:latest
memory: 1G
disk-quota: 3G
requires:
– name: <app>-uaa
provides:
– name: srv-api
properties:
srv-url: ${default-url} # Ensure this is set correctly
build-parameters:
no-source: true     Read More Technology Blogs by Members articles 

#SAP

#SAPTechnologyblog

You May Also Like

More From Author