From 3f3c6a99833dde3ec8d8b76734b46cd4a99ca22f Mon Sep 17 00:00:00 2001 From: Joanne Koch Date: Mon, 28 Oct 2024 15:03:30 -0400 Subject: [PATCH] Improve Dockerfile caching --- compose/local/tests/Dockerfile | 88 +++++++++++++--------------------- docker-compose-testing.yml | 2 - tests/UploadCsv.js | 1 - 3 files changed, 34 insertions(+), 57 deletions(-) diff --git a/compose/local/tests/Dockerfile b/compose/local/tests/Dockerfile index 5010e1ff..2ffb878b 100644 --- a/compose/local/tests/Dockerfile +++ b/compose/local/tests/Dockerfile @@ -5,63 +5,43 @@ WORKDIR /tests ARG DEBIAN_FRONTEND=noninteractive -RUN apt-get update && apt-get install -y --no-install-recommends apt-utils -RUN apt-get update +RUN apt-get update && \ + apt-get install -y --no-install-recommends \ + apt-utils \ + wget \ + unzip \ + curl \ + npm \ + jq \ + default-jre \ + libxkbcommon0 \ + libpangocairo-1.0 \ + libxdamage1 \ + libgbm1 && \ + apt-get clean && \ + rm -rf /var/lib/apt/lists/* -RUN apt-get install -y wget && apt install -y unzip - -# At root dir COPY ./tests/*.bat /tests/ COPY ./tests/*.js /tests/ COPY ./tests/*.csv /tests/ COPY ./tests/*.ext /tests/ -RUN apt-get update -RUN apt-get install curl -y -RUN apt-get install npm -y - -# npm WARN EBADENGINE package: 'jsdom@20.0.0' with Node 12.x -RUN npm install jsdom@19.0.0 -RUN npm install jquery -RUN npm install jquery-csv -RUN npm install unzipper -# node-fetch v3 errors with require(), needs import -RUN npm install node-fetch@2.6.1 -# Needed for "Chrome for Testing" -RUN apt-get -y install jq -RUN apt-get -y install default-jre -RUN apt-get -f install -RUN apt-get update && apt-get install -y libxkbcommon0 libpangocairo-1.0 libxdamage1 libgbm1 - -RUN npm install selenium-webdriver - -#RUN wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb && apt install -y ./google-chrome-stable_current_amd64.deb -# Get Chrome for Testing - Chrome stable version number does not match the Chrome for Testing stable version -RUN CHROME_URL=$(curl -s https://googlechromelabs.github.io/chrome-for-testing/last-known-good-versions-with-downloads.json | jq -r '.channels.Stable.downloads.chrome[] | select(.platform == "linux64") | .url') \ - && curl -sSLf --retry 3 --output /tmp/chrome-linux64.zip "$CHROME_URL" \ - && unzip /tmp/chrome-linux64.zip -d /opt \ - && ln -s /opt/chrome-linux64/chrome /usr/local/bin/chrome \ - && rm /tmp/chrome-linux64.zip - -# Get Chromedriver for Testing - this is the only supported version going forward -#RUN CHROME_VERSION=$(google-chrome --version | sed -n 's/Google Chrome \([0-9.]*\).*/\1/p; s/[^0-9.]//g') \ -# && wget https://edgedl.me.gvt1.com/edgedl/chrome/chrome-for-testing/$CHROME_VERSION/linux64/chromedriver-linux64.zip \ -# && unzip -o chromedriver-linux64.zip -d /usr/local/bin -RUN CHROMEDRIVER_URL=$(curl -s https://googlechromelabs.github.io/chrome-for-testing/last-known-good-versions-with-downloads.json | jq -r '.channels.Stable.downloads.chromedriver[] | select(.platform == "linux64") | .url') \ - && curl -sSLf --retry 3 --output /tmp/chromedriver-linux64.zip "$CHROMEDRIVER_URL" \ - && unzip -o /tmp/chromedriver-linux64.zip -d /tmp \ - && rm -rf /tmp/chromedriver-linux64.zip \ - && mv -f /tmp/chromedriver-linux64/chromedriver "/usr/local/bin/chromedriver" \ - && chmod +x "/usr/local/bin/chromedriver" - -RUN chmod +x /tests/RunAllTests-Chrome-Linux.bat -RUN sed -i 's/\r//' /tests/RunAllTests-Chrome-Linux.bat - -RUN chmod +x /tests/Cleanup-Docker.bat -RUN sed -i 's/\r//' /tests/Cleanup-Docker.bat - -RUN chmod +x /tests/Buildup-Docker.bat -RUN sed -i 's/\r//' /tests/Buildup-Docker.bat - - - +RUN npm install jsdom@19.0.0 jquery jquery-csv unzipper node-fetch@2.6.1 selenium-webdriver + +# Get Chrome for Testing - Chrome stable version +RUN CHROME_URL=$(curl -s https://googlechromelabs.github.io/chrome-for-testing/last-known-good-versions-with-downloads.json | jq -r '.channels.Stable.downloads.chrome[] | select(.platform == "linux64") | .url') && \ + curl -sSLf --retry 3 --output /tmp/chrome-linux64.zip "$CHROME_URL" && \ + unzip /tmp/chrome-linux64.zip -d /opt && \ + ln -s /opt/chrome-linux64/chrome /usr/local/bin/chrome && \ + rm /tmp/chrome-linux64.zip + +# Get Chromedriver for Testing - matching Chrome version +RUN CHROMEDRIVER_URL=$(curl -s https://googlechromelabs.github.io/chrome-for-testing/last-known-good-versions-with-downloads.json | jq -r '.channels.Stable.downloads.chromedriver[] | select(.platform == "linux64") | .url') && \ + curl -sSLf --retry 3 --output /tmp/chromedriver-linux64.zip "$CHROMEDRIVER_URL" && \ + unzip -o /tmp/chromedriver-linux64.zip -d /tmp && \ + rm -rf /tmp/chromedriver-linux64.zip && \ + mv -f /tmp/chromedriver-linux64/chromedriver "/usr/local/bin/chromedriver" && \ + chmod +x "/usr/local/bin/chromedriver" + +RUN chmod +x /tests/RunAllTests-Chrome-Linux.bat /tests/Cleanup-Docker.bat /tests/Buildup-Docker.bat && \ + sed -i 's/\r//' /tests/*.bat diff --git a/docker-compose-testing.yml b/docker-compose-testing.yml index 039b8e69..14a2ada8 100644 --- a/docker-compose-testing.yml +++ b/docker-compose-testing.yml @@ -19,8 +19,6 @@ # If not, see . # -version: "3.7" - volumes: local_postgres_data: {} local_postgres_data_backups: {} diff --git a/tests/UploadCsv.js b/tests/UploadCsv.js index 5ca06605..fb18ca61 100644 --- a/tests/UploadCsv.js +++ b/tests/UploadCsv.js @@ -52,7 +52,6 @@ var filename, filename_ext; password = "admin"; } else { - // await driver.get("https://ooi-cgrdb-staging.whoi.net/"); await driver.get("https://rdb-testing.whoi.edu/"); user = "jkoch"; password = "Automatedtests";