Skip to content

Commit

Permalink
add python to dockerfile
Browse files Browse the repository at this point in the history
  • Loading branch information
this-pama committed Feb 19, 2024
1 parent 7aac405 commit 2fcea33
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 208 deletions.
30 changes: 18 additions & 12 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,21 @@
# Use the official Node.js image as a base
FROM node:16-slim

RUN apt-get update && apt-get -y upgrade && apt-get install -y ca-certificates curl apt-transport-https lsb-release gnupg
# Install essential packages
RUN apt-get update \
&& apt-get install -y \
python3 \
python3-pip \
&& rm -rf /var/lib/apt/lists/*

# Set up a working directory
WORKDIR /usr/src/app

# Continue with existing setup
RUN apt-get update && apt-get -y upgrade && apt-get install -y ca-certificates curl apt-transport-https lsb-release gnupg
ENV DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=1

ARG DEBIAN_FRONTEND=noninteractive
# 0. Install essential packages
RUN apt-get update \
&& apt-get install -y \
build-essential \
Expand All @@ -23,8 +32,6 @@ RUN apt-get update \
&& curl -L https://github.com/mozilla/geckodriver/releases/download/v0.30.0/geckodriver-v0.30.0-linux64.tar.gz | tar xz -C /usr/local/bin \
&& rm -rf /var/lib/apt/lists/*

# 2) Install latest stable Chrome
# https://gerg.dev/2021/06/making-chromedriver-and-chrome-versions-match-in-a-docker-image/
RUN echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" | \
tee -a /etc/apt/sources.list.d/google.list

Expand All @@ -34,10 +41,6 @@ RUN wget -q -O - https://dl.google.com/linux/linux_signing_key.pub | \
RUN wget -q https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
RUN apt-get install ./google-chrome-stable_current_amd64.deb

# 3) Install the Chromedriver version that corresponds to the installed major Chrome version
# https://blogs.sap.com/2020/12/01/ui5-testing-how-to-handle-chromedriver-update-in-docker-image/
# For some reason, there is a breaking change with Chrome driver and the latest google chrome browser. Hence, the reason for default Chrome driver to the last know working version
# TODO=> Find fix for breaking change =:)
RUN google-chrome --version | grep -oE "[0-9]{1,10}.[0-9]{1,10}.[0-9]{1,10}" > /tmp/chromebrowser-main-version.txt
RUN wget --no-verbose -O /tmp/latest_chromedriver_version.txt https://chromedriver.storage.googleapis.com/LATEST_RELEASE_114.0.5735
RUN wget --no-verbose -O /tmp/chromedriver_linux64.zip https://chromedriver.storage.googleapis.com/114.0.5735.90/chromedriver_linux64.zip \
Expand All @@ -47,17 +50,20 @@ RUN wget --no-verbose -O /tmp/chromedriver_linux64.zip https://chromedriver.stor
&& chmod 755 /opt/selenium/chromedriver-$(cat /tmp/latest_chromedriver_version.txt) \
&& ln -fs /opt/selenium/chromedriver-$(cat /tmp/latest_chromedriver_version.txt) /usr/bin/chromedriver


WORKDIR /app

# Install Node.js dependencies
RUN npm config set unsafe-perm true
RUN npm i selenium-webdriver
COPY package*.json ./

RUN npm i

# Copy the application code
COPY . .

# Install Python dependencies
RUN pip3 freeze > requirements.txt
# RUN pip3 install --no-cache-dir -r requirements.txt

# Expose port
EXPOSE 3000

# Start the application
Expand Down
196 changes: 0 additions & 196 deletions scripts/requirements.txt

This file was deleted.

0 comments on commit 2fcea33

Please sign in to comment.