Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
incubator4 committed Jul 4, 2024
0 parents commit e7b51d0
Show file tree
Hide file tree
Showing 3 changed files with 95 additions and 0 deletions.
16 changes: 16 additions & 0 deletions .github/workflows/docker.yaml
Original file line number Diff line number Diff line change
@@ -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
32 changes: 32 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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/
47 changes: 47 additions & 0 deletions fundamentals.sh
Original file line number Diff line number Diff line change
@@ -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 <<EOF
################################# GCS Storage ##################################
## GCS Bucket where thumbor's loader will fetch images from.
LOADER = 'thumbor_gcs.loader.gcs_loader'
## GCS Bucket ID where thumbor's loader will fetch images from.
LOADER_GCS_BUCKET_ID = '{{ LOADER_GCS_BUCKET_ID | default('') }}'
## GCS Project ID where thumbor's loader will fetch images from.
LOADER_GCS_PROJECT_ID = '{{ LOADER_GCS_PROJECT_ID | default('') }}'
## GCS Root Path where thumbor's loader will fetch images from.
LOADER_GCS_ROOT_PATH = '{{ LOADER_GCS_ROOT_PATH | default('') }}'
## GCS Bucket ID where thumbor's result storage will store images.
RESULT_STORAGE = 'thumbor_gcs.result_storage.gcs_result_storage'
## GCS Bucket ID where thumbor's result storage will store images.
RESULT_STORAGE_GCS_BUCKET_ID = '{{ RESULT_STORAGE_GCS_BUCKET_ID | default('') }}'
## GCS Project ID where thumbor's result storage will store images.
RESULT_STORAGE_GCS_PROJECT_ID = '{{ RESULT_STORAGE_GCS_PROJECT_ID | default('') }}'
## GCS Root Path where thumbor's result storage will store images.
RESULT_STORAGE_GCS_ROOT_PATH = '{{ RESULT_STORAGE_GCS_ROOT_PATH | default('') }}'
################################################################################
EOF
)

echo -e "$GCS" | envtpl >> /usr/local/thumbor/thumbor.conf

0 comments on commit e7b51d0

Please sign in to comment.