From 7e407fce75ee534393cf3510d620b3909a0f22ee Mon Sep 17 00:00:00 2001 From: Andrey Sobolev Date: Mon, 13 Jan 2025 14:51:06 +0700 Subject: [PATCH] Docker base images (#7651) Signed-off-by: Andrey Sobolev --- .github/workflows/baseimage.yaml | 59 ++++++++++++++++++++++++++++++++ dev/base-image/base.Dockerfile | 11 ++++++ dev/base-image/build.sh | 5 +++ dev/base-image/print.Dockerfile | 15 ++++++++ dev/base-image/push.sh | 5 +++ dev/base-image/rekoni.Dockerfile | 9 +++++ 6 files changed, 104 insertions(+) create mode 100644 .github/workflows/baseimage.yaml create mode 100644 dev/base-image/base.Dockerfile create mode 100755 dev/base-image/build.sh create mode 100644 dev/base-image/print.Dockerfile create mode 100755 dev/base-image/push.sh create mode 100644 dev/base-image/rekoni.Dockerfile diff --git a/.github/workflows/baseimage.yaml b/.github/workflows/baseimage.yaml new file mode 100644 index 0000000000..5dd83c10ed --- /dev/null +++ b/.github/workflows/baseimage.yaml @@ -0,0 +1,59 @@ +# This is a basic workflow to help you get started with Actions + +name: Docker base image + +concurrency: + group: 'service-base' + cancel-in-progress: true + +# Controls when the action will run. +on: + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + +# A workflow run is made up of one or more jobs that can run sequentially or in parallel +jobs: + docker-build: + runs-on: ubuntu-latest + timeout-minutes: 60 + steps: + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + - name: Configure docker + uses: crazy-max/ghaction-setup-docker@v3 + with: + daemon-config: | + { + "features": { + "containerd-snapshotter": true + } + } + - uses: actions/checkout@v4 + with: + fetch-depth: 1 + filter: tree:0 + + - uses: actions/setup-node@v4 + with: + node-version-file: '.nvmrc' + - uses: pnpm/action-setup@v4 + with: + version: latest + - name: Docker build + run: | + cd ./dev/base-image + ./build.sh + env: + DOCKER_CLI_HINTS: false + DOCKER_EXTRA: --platform=linux/amd64,linux/arm64 + - name: Login to Docker Hub + uses: docker/login-action@v3 + with: + username: hardcoreeng + password: ${{ secrets.DOCKER_ACCESS_TOKEN }} + - name: Publish base image + run: | + echo Pushing base image + cd ./dev/base-image + ./publish.sh + diff --git a/dev/base-image/base.Dockerfile b/dev/base-image/base.Dockerfile new file mode 100644 index 0000000000..2285dfdafe --- /dev/null +++ b/dev/base-image/base.Dockerfile @@ -0,0 +1,11 @@ +FROM node:22 + +RUN apt-get install libjemalloc2 dumb-init +RUN apt-get clean + +ENV LD_PRELOAD=libjemalloc.so.2 +ENV MALLOC_CONF=dirty_decay_ms:1000,narenas:2,background_thread:true + +WORKDIR /usr/src/app +ENV NODE_ENV=production +RUN npm install --ignore-scripts=false --verbose bufferutil utf-8-validate snappy msgpackr msgpackr-extract --unsafe-perm diff --git a/dev/base-image/build.sh b/dev/base-image/build.sh new file mode 100755 index 0000000000..e1068aeaf9 --- /dev/null +++ b/dev/base-image/build.sh @@ -0,0 +1,5 @@ +#!/usr/bin/env bash + +docker build -t hardcoreeng/base -f base.Dockerfile . +docker build -t hardcoreeng/rekoni-base -f rekoni.Dockerfile . +docker build -t hardcoreeng/print-base -f print.Dockerfile . \ No newline at end of file diff --git a/dev/base-image/print.Dockerfile b/dev/base-image/print.Dockerfile new file mode 100644 index 0000000000..d077652b13 --- /dev/null +++ b/dev/base-image/print.Dockerfile @@ -0,0 +1,15 @@ +FROM hardcoreeng/base + +# We don't need the standalone Chromium +ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true +# Set executable path for puppeteer +ENV PUPPETEER_EXECUTABLE_PATH=/usr/bin/chromium + +# Install Chromium and fonts +# https://github.com/puppeteer/puppeteer/blob/main/docs/troubleshooting.md?plain=1#L397 +RUN apt-get update --fix-missing +RUN apt-get install -y gnupg wget libxss1 +RUN apt-get install -y fonts-ipafont-gothic fonts-wqy-zenhei fonts-thai-tlwg fonts-kacst fonts-freefont-ttf +RUN apt-get install -y chromium-common/stable --no-install-recommends +RUN apt-get install -y chromium/stable --no-install-recommends +RUN apt-get clean diff --git a/dev/base-image/push.sh b/dev/base-image/push.sh new file mode 100755 index 0000000000..f82152cd26 --- /dev/null +++ b/dev/base-image/push.sh @@ -0,0 +1,5 @@ +#!/usr/bin/env bash + +docker push hardcoreeng/base +docker push hardcoreeng/rekoni-base +docker push hardcoreeng/print-base \ No newline at end of file diff --git a/dev/base-image/rekoni.Dockerfile b/dev/base-image/rekoni.Dockerfile new file mode 100644 index 0000000000..72ac676bb1 --- /dev/null +++ b/dev/base-image/rekoni.Dockerfile @@ -0,0 +1,9 @@ +FROM hardcoreeng/base + +RUN apt-get install -y \ + coreutils \ + antiword \ + poppler-utils \ + html2text \ + unrtf +RUN npm install --ignore-scripts=false --verbose sharp@v0.30.2 pdfjs-dist@v2.12.313 --unsafe-perm \ No newline at end of file