Skip to content

Commit

Permalink
Improve Dockerfile caching
Browse files Browse the repository at this point in the history
  • Loading branch information
joannekoch committed Oct 28, 2024
1 parent ca89aaf commit 3f3c6a9
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 57 deletions.
88 changes: 34 additions & 54 deletions compose/local/tests/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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: '[email protected]' with Node 12.x
RUN npm install [email protected]
RUN npm install jquery
RUN npm install jquery-csv
RUN npm install unzipper
# node-fetch v3 errors with require(), needs import
RUN npm install [email protected]
# 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 [email protected] jquery jquery-csv unzipper [email protected] 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
2 changes: 0 additions & 2 deletions docker-compose-testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@
# If not, see <http://www.gnu.org/licenses/>.
#

version: "3.7"

volumes:
local_postgres_data: {}
local_postgres_data_backups: {}
Expand Down
1 change: 0 additions & 1 deletion tests/UploadCsv.js
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down

0 comments on commit 3f3c6a9

Please sign in to comment.