From 19372814a35dea0bf91a8e60efa8c60e18b1a853 Mon Sep 17 00:00:00 2001 From: Tobias Ludwig Maier Date: Tue, 17 Jan 2023 22:22:53 +0100 Subject: [PATCH 1/5] Add docker image --- .github/workflows/docker.yml | 51 ++++++++++++++++++++++++++++++++++++ Dockerfile | 38 +++++++++++++++++++++++++++ 2 files changed, 89 insertions(+) create mode 100644 .github/workflows/docker.yml create mode 100644 Dockerfile diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml new file mode 100644 index 0000000..e5c1ef9 --- /dev/null +++ b/.github/workflows/docker.yml @@ -0,0 +1,51 @@ +# This workflow uses actions that are not certified by GitHub. +# They are provided by a third-party and are governed by +# separate terms of service, privacy policy, and support +# documentation. + +# GitHub recommends pinning actions to a commit SHA. +# To get a newer version, you will need to update the SHA. +# You can also reference a tag or branch, but the action may change without warning. + +name: Create and publish a Docker image + +on: + push: + branches: + - master + +env: + REGISTRY: ghcr.io + IMAGE_NAME: ${{ github.repository }} + +jobs: + build-and-push-image: + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Log in to the Container registry + uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + + - name: Build and push Docker image + uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc + with: + context: . + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..3b0f9fe --- /dev/null +++ b/Dockerfile @@ -0,0 +1,38 @@ +FROM node:lts-slim + +ARG CRITICAL_VERSION=5.0.4 + +ARG PACKAGES="\ + libx11-6\ + libx11-xcb1\ + libxcomposite1\ + libxcursor1\ + libxdamage1\ + libxext6\ + libxi6\ + libxtst6\ + libglib2.0-0\ + libnss3\ + libcups2\ + libxss1\ + libexpat1\ + libxrandr2\ + libasound2\ + libatk1.0-0\ + libatk-bridge2.0-0\ + libpangocairo-1.0-0\ + libgtk-3-0\ + " +RUN rm -f /etc/apt/apt.conf.d/docker-clean; echo 'Binary::apt::APT::Keep-Downloaded-Packages "true";' > /etc/apt/apt.conf.d/keep-cache +RUN --mount=type=cache,id=build-apt-cache,sharing=locked,target=/var/cache/apt \ + --mount=type=cache,id=build-apt-lib,sharing=locked,target=/var/lib/apt \ + apt-get update -qq \ + && apt-get install --no-install-recommends -y ${PACKAGES} \ + && rm -rf /var/lib/apt/lists /var/cache/apt/archives + +RUN --mount=type=cache,id=build-npm-cache,sharing=locked,target=/root/.npm \ + npm install -g critical@${CRITICAL_VERSION} + +WORKDIR /site + +CMD ["npm", "critical", "--help"] From 54174cd7770fd52dd0cdaa2ca9eebfd4a764d167 Mon Sep 17 00:00:00 2001 From: Tobias Ludwig Maier Date: Tue, 17 Jan 2023 22:35:25 +0100 Subject: [PATCH 2/5] Ignore hadolint warning Ref. https://github.com/hadolint/hadolint/wiki/DL3008 --- Dockerfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Dockerfile b/Dockerfile index 3b0f9fe..9538cb6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -24,6 +24,7 @@ ARG PACKAGES="\ libgtk-3-0\ " RUN rm -f /etc/apt/apt.conf.d/docker-clean; echo 'Binary::apt::APT::Keep-Downloaded-Packages "true";' > /etc/apt/apt.conf.d/keep-cache +# hadolint ignore=DL3008 RUN --mount=type=cache,id=build-apt-cache,sharing=locked,target=/var/cache/apt \ --mount=type=cache,id=build-apt-lib,sharing=locked,target=/var/lib/apt \ apt-get update -qq \ From 554ed67f630ab39baa238aaaea8e19e2ca1c89e9 Mon Sep 17 00:00:00 2001 From: "Tobias L. Maier" Date: Wed, 18 Jan 2023 08:16:50 +0100 Subject: [PATCH 3/5] Fix CMD --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 9538cb6..585ef39 100644 --- a/Dockerfile +++ b/Dockerfile @@ -36,4 +36,4 @@ RUN --mount=type=cache,id=build-npm-cache,sharing=locked,target=/root/.npm \ WORKDIR /site -CMD ["npm", "critical", "--help"] +CMD ["critical", "--help"] From c5b053c93711e14cf79d3fce7a640bf5fbe2099a Mon Sep 17 00:00:00 2001 From: "Tobias L. Maier" Date: Sat, 30 Mar 2024 23:40:51 +0100 Subject: [PATCH 4/5] Update .github/workflows/docker.yml Co-authored-by: Adonys Santos <58638286+adonyssantos@users.noreply.github.com> --- .github/workflows/docker.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index e5c1ef9..8fae174 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -28,6 +28,8 @@ jobs: steps: - name: Checkout repository uses: actions/checkout@v3 + with: + fetch-depth: 0 - name: Log in to the Container registry uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9 From d0a62c639384ea64e8d15bde797a0624500ad8e8 Mon Sep 17 00:00:00 2001 From: "Tobias L. Maier" Date: Sat, 30 Mar 2024 23:44:21 +0100 Subject: [PATCH 5/5] Set node version to 20 --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 585ef39..a95538a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM node:lts-slim +FROM node:20-slim ARG CRITICAL_VERSION=5.0.4