From e7b51d05ba74cb769ed65d520c79c31b99abe920 Mon Sep 17 00:00:00 2001 From: incubator4 Date: Thu, 4 Jul 2024 15:01:48 +0800 Subject: [PATCH] init --- .github/workflows/docker.yaml | 16 ++++++++++++ Dockerfile | 32 ++++++++++++++++++++++++ fundamentals.sh | 47 +++++++++++++++++++++++++++++++++++ 3 files changed, 95 insertions(+) create mode 100644 .github/workflows/docker.yaml create mode 100644 Dockerfile create mode 100644 fundamentals.sh diff --git a/.github/workflows/docker.yaml b/.github/workflows/docker.yaml new file mode 100644 index 0000000..f75d4c6 --- /dev/null +++ b/.github/workflows/docker.yaml @@ -0,0 +1,16 @@ +name: Docker Build + +on: + push: + branches: + - main + tags: + - v* +jobs: + build: + uses: NaturalSelectionLabs/Daedalus/.github/workflows/docker-tpl.yaml@main + with: + images: rss3/thumbor + context: . + dockerfile: ./Dockerfile + secrets: inherit diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..b929e5e --- /dev/null +++ b/Dockerfile @@ -0,0 +1,32 @@ +FROM debian:bullseye-slim as mozjpeg +ENV VERSION 3.3.1 + +RUN apt-get update && \ + apt-get install -y --no-install-recommends autoconf automake checkinstall libpng-dev libtool make nasm pkg-config && \ + rm -rf /var/lib/apt/lists/* + +ADD https://github.com/mozilla/mozjpeg/archive/v$VERSION.tar.gz /usr/local/share + +WORKDIR /usr/local/share +RUN mkdir mozjpeg && \ + tar --strip-components=1 --extract --file v$VERSION.tar.gz -C mozjpeg mozjpeg-$VERSION/ + +WORKDIR /usr/local/share/mozjpeg +RUN autoreconf -fiv && \ + mkdir build + +WORKDIR /usr/local/share/mozjpeg/build +RUN ../configure && make + +FROM mvhirsch/thumbor:7.5.2 + +RUN pip install --user --no-cache-dir thumbor-gcs thumbor-plugins + +COPY --from=mozjpeg /usr/local/share/mozjpeg/build /usr/local/share/mozjpeg/build +RUN ln -s /usr/local/share/mozjpeg/build/cjpeg /usr/local/bin/mozjpeg + +RUN apt-get update && \ + apt-get install -y --no-install-recommends pngquant && \ + rm -rf /var/lib/apt/lists/* + +COPY fundamentals.sh /docker-entrypoint.init.d/ \ No newline at end of file diff --git a/fundamentals.sh b/fundamentals.sh new file mode 100644 index 0000000..afe9c98 --- /dev/null +++ b/fundamentals.sh @@ -0,0 +1,47 @@ +#!/bin/sh + +# mozjpeg +echo "MOZJPEG_PATH = '/usr/local/bin/mozjpeg'" >> /usr/local/thumbor/thumbor.conf +echo "MOZJPEG_QUALITY = 80" >> /usr/local/thumbor/thumbor.conf + +# pngquant +echo "PNGQUANT_PATH = '/usr/bin/pngquant'" >> /usr/local/thumbor/thumbor.conf +echo "PNGQUANT_SPEED = 3" >> /usr/local/thumbor/thumbor.conf + +# set OPTIMIZERS +echo "OPTIMIZERS = ['thumbor_plugins.optimizers.mozjpeg', 'thumbor_plugins.optimizers.pngquant']" >> /usr/local/thumbor/thumbor.conf + +# configure gcs +GCS=$(cat <> /usr/local/thumbor/thumbor.conf \ No newline at end of file