From a6711aeb63e6ea0d18c34832ea183f80c1b2271e Mon Sep 17 00:00:00 2001 From: Alicia Sykes Date: Thu, 14 Sep 2023 20:59:09 +0100 Subject: [PATCH 1/3] Update Dockerfile (#43) Updates the Dockerfile with changes suggested by @GWnbsp in https://github.com/Lissy93/web-check/issues/43#issuecomment-1719212234 ### Summary of Changes 1. **ARG Statements:** Introduced `ARG` statements for Node.js and Debian versions, making the Dockerfile more customizable. 2. **SHELL Command:** Changed the default shell to Bash with certain options enabled, improving robustness. 3. **Chromium Installation:** Updated Chromium installation to use Google's signing keys and repositories, aiming for more secure and up-to-date packages. 4. **Chromium Version:** Added a step to save Chromium's version into `/etc/chromium-version` for reference. 5. **Directory Creation:** Added a new directory /app/data in the container's filesystem. 6. **CMD Change:** Changed the CMD to start Node.js server (server.js) instead of using yarn serve. 7. **General Cleanup and Comments:** Code has been refactored for better readability and detailed comments have been added for clarity. 8. **Dependency Installation:** Kept yarn install and the removal of the Yarn cache, but the command is more streamlined. 9. **Other Minor Changes:** - Added flags like `-qq` and `--no-install-recommends` for quieter and optimized installation. - Enhanced cleanup with `rm -rf /var/lib/apt/lists/*.` --- Dockerfile | 41 +++++++++++++++++++++++++++++++++-------- 1 file changed, 33 insertions(+), 8 deletions(-) diff --git a/Dockerfile b/Dockerfile index 3951f553..5b0e15d4 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,23 +1,48 @@ -FROM node:16-buster-slim +# Specify the Node.js version to use +ARG NODE_VERSION=16 -RUN apt-get update && \ - apt-get install -y chromium traceroute && \ - chmod 755 /usr/bin/chromium && \ - rm -rf /var/lib/apt/lists/* +# Specify the Debian version to use, the default is "bullseye" +ARG DEBIAN_VERSION=bullseye +# Use Node.js Docker image as the base image, with specific Node and Debian versions +FROM docker.io/library/node:${NODE_VERSION}-${DEBIAN_VERSION} + +# Set the container's default shell to Bash and enable some options +SHELL ["/bin/bash", "-euo", "pipefail", "-c"] + +# Install Chromium browser and Download and verify Google Chrome’s signing key +RUN apt-get update -qq --fix-missing && \ + apt-get -qqy install --allow-unauthenticated gnupg wget && \ + wget --quiet --output-document=- https://dl-ssl.google.com/linux/linux_signing_key.pub | gpg --dearmor > /etc/apt/trusted.gpg.d/google-archive.gpg && \ + echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" > /etc/apt/sources.list.d/google.list && \ + apt-get update -qq && \ + apt-get -qqy --no-install-recommends install chromium traceroute && \ + rm -rf /var/lib/apt/lists/* + +# Run the Chromium browser's version command and redirect its output to the /etc/chromium-version file +RUN /usr/bin/chromium --no-sandbox --version > /etc/chromium-version + +# Set the working directory to /app WORKDIR /app +# Copy package.json and yarn.lock to the working directory COPY package.json yarn.lock ./ -RUN yarn install && \ - rm -rf /app/node_modules/.cache +# Run yarn install to install dependencies and clear yarn cache +RUN yarn install && rm -rf /app/node_modules/.cache +# Copy all files to working directory COPY . . +RUN mkdir /app/data +# Run yarn build to build the application RUN yarn build +# Exposed container port, the default is 3000, which can be modified through the environment variable PORT EXPOSE ${PORT:-3000} +# Set the environment variable CHROME_PATH to specify the path to the Chromium binaries ENV CHROME_PATH='/usr/bin/chromium' -CMD ["yarn", "serve"] \ No newline at end of file +# Define the command executed when the container starts and start the server.js of the Node.js application +CMD [ "node", "server.js" ] From 2fb7dc9a2b2360720c3bb42bb249973385a9c95b Mon Sep 17 00:00:00 2001 From: ChrisCarini <6374067+ChrisCarini@users.noreply.github.com> Date: Thu, 29 Feb 2024 08:03:50 -0800 Subject: [PATCH 2/3] Add linux/arm64/v8 platform --- .github/workflows/docker.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index e591ee68..f335f595 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -67,7 +67,7 @@ jobs: context: . file: ./Dockerfile push: true - platforms: linux/amd64 + platforms: linux/amd64,linux/arm64/v8 tags: | ${{ env.GHCR_TAG }} ${{ env.DOCKERHUB_TAG }} From 761f9dab8119ba69028e1e04fd718bacfc701898 Mon Sep 17 00:00:00 2001 From: ChrisCarini <6374067+chriscarini@users.noreply.github.com> Date: Thu, 29 Feb 2024 08:10:07 -0800 Subject: [PATCH 3/3] Install python + increase yarn install timeout (cherry picked from commit 4e70e1621e7c44dc5e3c51edd0b5f3577b846eed) --- Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 3502f8db..7a954059 100644 --- a/Dockerfile +++ b/Dockerfile @@ -16,7 +16,7 @@ RUN apt-get update -qq --fix-missing && \ wget --quiet --output-document=- https://dl-ssl.google.com/linux/linux_signing_key.pub | gpg --dearmor > /etc/apt/trusted.gpg.d/google-archive.gpg && \ echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" > /etc/apt/sources.list.d/google.list && \ apt-get update -qq && \ - apt-get -qqy --no-install-recommends install chromium traceroute && \ + apt-get -qqy --no-install-recommends install chromium traceroute python make g++ && \ rm -rf /var/lib/apt/lists/* # Run the Chromium browser's version command and redirect its output to the /etc/chromium-version file @@ -30,7 +30,7 @@ COPY package.json yarn.lock ./ # Run yarn install to install dependencies and clear yarn cache RUN apt-get update && \ - yarn install --production && \ + yarn install --production --frozen-lockfile --network-timeout 100000 && \ rm -rf /app/node_modules/.cache # Copy all files to working directory