From 1ff3136380653d0ffff487ceb31b72c6d656dd31 Mon Sep 17 00:00:00 2001 From: Giuseppe Marino Date: Fri, 6 Nov 2020 23:29:55 +0100 Subject: [PATCH] fix dockerfile --- Dockerfile | 5 +++-- docker-entrypoint.sh | 43 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+), 2 deletions(-) create mode 100755 docker-entrypoint.sh diff --git a/Dockerfile b/Dockerfile index d3db905..63e1e44 100644 --- a/Dockerfile +++ b/Dockerfile @@ -17,10 +17,11 @@ RUN cmake --build . --target install -- FROM alpine:3.12.1 -RUN apk --no-cache add libstdc++ +RUN apk --no-cache add libstdc++ curl COPY --from=builder /usr/local/bin/telegram-bot-api /usr/local/bin/telegram-bot-api +COPY docker-entrypoint.sh /docker-entrypoint.sh HEALTHCHECK CMD curl -f http://localhost:8082/ || exit 1 -ENTRYPOINT ["/usr/local/bin/telegram-bot-api -s 8082"] +ENTRYPOINT ["/docker-entrypoint.sh"] diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh new file mode 100755 index 0000000..9b647d6 --- /dev/null +++ b/docker-entrypoint.sh @@ -0,0 +1,43 @@ +#!/bin/sh +set -e + +LOGS_DIR="/var/log/telegram-bot-api" +LOG_FILENAME="telegram-bot-api.log" +WORK_DIR="/etc/telegram-bot-api" +TEMP_DIR="/tmp/telegram-bot-api" + +if [ -n "${1}" ]; then + exec "${*}" +fi + +mkdir -p "${LOGS_DIR}" +mkdir -p "${WORK_DIR}" +mkdir -p "${TEMP_DIR}" + +DEFAULT_ARGS="--http-port 8081 --http-stat-port=8082 --dir=${WORK_DIR} --temp-dir=${TEMP_DIR} --log=${LOGS_DIR}/${LOG_FILENAME}" +CUSTOM_ARGS="" + +if [ -n "$TELEGRAM_FILTER" ]; then + CUSTOM_ARGS="${CUSTOM_ARGS} --filter=$TELEGRAM_FILTER" +fi +if [ -n "$TELEGRAM_MAX_WEBHOOK_CONNECTIONS" ]; then + CUSTOM_ARGS="${CUSTOM_ARGS} --max-webhook-connections=$TELEGRAM_MAX_WEBHOOK_CONNECTIONS" +fi +if [ -n "$TELEGRAM_VERBOSITY" ]; then + CUSTOM_ARGS="${CUSTOM_ARGS} --verbosity=$TELEGRAM_VERBOSITY" +fi +if [ -n "$TELEGRAM_MAX_CONNECTIONS" ]; then + CUSTOM_ARGS="${CUSTOM_ARGS} --max-connections=$TELEGRAM_MAX_CONNECTIONS" +fi +if [ -n "$TELEGRAM_PROXY" ]; then + CUSTOM_ARGS="${CUSTOM_ARGS} --proxy=$TELEGRAM_PROXY" +fi +if [ -n "$TELEGRAM_LOCAL" ]; then + CUSTOM_ARGS="${CUSTOM_ARGS} --local" +fi + +COMMAND="telegram-bot-api ${DEFAULT_ARGS}${CUSTOM_ARGS}" + +echo "$COMMAND" +# shellcheck disable=SC2086 +exec $COMMAND