Skip to content

Commit

Permalink
replace entry-point script
Browse files Browse the repository at this point in the history
  • Loading branch information
tschaffter committed Sep 25, 2024
1 parent 04ef96f commit 7465dd4
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 1 deletion.
4 changes: 3 additions & 1 deletion apps/openchallenges/thumbor/Dockerfile
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
FROM beeyev/thumbor-s3:7.7-slim-alpine
FROM beeyev/thumbor-s3:7.7-slim-alpine

COPY --chmod=0755 ./docker-entrypoint.sh /docker-entrypoint.sh
58 changes: 58 additions & 0 deletions apps/openchallenges/thumbor/docker-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
#!/bin/bash
# Alexander Tebiev - https://github.com/beeyev

#String Colors
NC='\033[0;m' # Default Color
GRN='\033[32;1m'
RED='\033[31;1m'
BLK='\033[30;1m'
GRY='\033[90;1m'

# Set the number of cpu cores
export NUM_CPUS=`nproc`

if [ ! -f /app/thumbor.conf ]; then
envtpl /usr/local/etc/thumbor.conf.tpl --allow-missing --keep-template
sed -i "s/'None'/None/g" /usr/local/etc/thumbor.conf
else
sed -i "s/'None'/None/g" /app/thumbor.conf
fi

# If log level is defined we configure it, else use default log_level = info
if [[ -n "${LOG_LEVEL}" ]]
then
LOG_PARAMETER="--log-level=${LOG_LEVEL}"
fi

# Check if thumbor port is defined -> (default port 8888)
if [[ -n "${PORT}" ]]
then
PORT_PARAMETER="--port=${PORT}"
fi

# Set number of processes
if [[ -n "${NUM_PROCESSES}" ]]
then
NUM_PROCESSES_PARAMETER="--processes=${NUM_PROCESSES}"
fi

# Run custom script before the main docker process gets started
for f in /docker-entrypoint.init.d/*; do
case "$f" in
*.sh) # this should match the set of files we check for below
echo "⚙ Executing entrypoint.init file: ${f}"
. $f
break
;;
esac
done

THUMBOR_EXEC="thumbor ${PORT_PARAMETER} --conf=/usr/local/etc/thumbor.conf ${LOG_PARAMETER} ${NUM_PROCESSES_PARAMETER}"

printf "\n\n${GRN}--->${NC} $($(which thumbor) --version)"
printf "\n${GRN}--->${NC} Starting Thumbor on port: ${GRN}${PORT}${NC}, log level: ${GRN}${LOG_LEVEL}${NC}, CPU cores available: ${GRN}${NUM_CPUS}${NC}"
printf "\n${GRN}--->${NC} Exec command: ${GRY}${THUMBOR_EXEC}${NC}"
printf "\n${GRN}--->${NC} Docker image build date: ${GRY}${BUILD_DATE}${NC}, fingerprint: ${GRY}${BUILD_FINGERPRINT}${NC}"
printf "\n${GRN}--->${NC} Docker image project url: ${GRY}https://github.com/beeyev/thumbor-s3-docker${NC}\n\n"
exec ${THUMBOR_EXEC}

0 comments on commit 7465dd4

Please sign in to comment.