Fix temp directory permissions, move logs path to environment variable

This commit is contained in:
Alex Root Junior 2020-11-10 00:36:53 +02:00
parent 27c62e65dd
commit 6ca4fe98b5
4 changed files with 15 additions and 14 deletions

View File

@ -1,9 +1,9 @@
name: Docker Image name: Docker Image
on: on: []
push: # push:
branches: # branches:
- master # - master
jobs: jobs:
multi: multi:

View File

@ -13,8 +13,7 @@ RUN mkdir -p build \
FROM alpine:3.12 FROM alpine:3.12
ENV TELEGRAM_LOGS_DIR="/var/log/telegram-bot-api" \ ENV TELEGRAM_WORK_DIR="/var/lib/telegram-bot-api" \
TELEGRAM_WORK_DIR="/var/lib/telegram-bot-api" \
TELEGRAM_TEMP_DIR="/tmp/telegram-bot-api" TELEGRAM_TEMP_DIR="/tmp/telegram-bot-api"
RUN apk add --no-cache --update openssl libstdc++ RUN apk add --no-cache --update openssl libstdc++
@ -23,9 +22,8 @@ COPY docker-entrypoint.sh /docker-entrypoint.sh
RUN addgroup -g 101 -S telegram-bot-api \ RUN addgroup -g 101 -S telegram-bot-api \
&& adduser -S -D -H -u 101 -h ${TELEGRAM_WORK_DIR} -s /sbin/nologin -G telegram-bot-api -g telegram-bot-api telegram-bot-api \ && adduser -S -D -H -u 101 -h ${TELEGRAM_WORK_DIR} -s /sbin/nologin -G telegram-bot-api -g telegram-bot-api telegram-bot-api \
&& chmod +x /docker-entrypoint.sh \ && chmod +x /docker-entrypoint.sh \
&& mkdir -p ${TELEGRAM_LOGS_DIR} ${TELEGRAM_WORK_DIR} ${TELEGRAM_TEMP_DIR} \ && mkdir -p ${TELEGRAM_WORK_DIR} ${TELEGRAM_TEMP_DIR} \
&& chown telegram-bot-api:telegram-bot-api ${TELEGRAM_LOGS_DIR} ${TELEGRAM_WORK_DIR} \ && chown telegram-bot-api:telegram-bot-api ${TELEGRAM_WORK_DIR} ${TELEGRAM_TEMP_DIR}
&& chown nobody:nobody /tmp/telegram-bot-api
EXPOSE 8081/tcp 8082/tcp EXPOSE 8081/tcp 8082/tcp
ENTRYPOINT ["/docker-entrypoint.sh"] ENTRYPOINT ["/docker-entrypoint.sh"]

View File

@ -41,7 +41,9 @@ default value of the maximum webhook connections per bot
log verbosity level log verbosity level
Logs will be stored to `/var/log/telegram-bot-server` directory inside container ### `TELEGRAM_LOG_FILE`
Filename where logs will be redirected (By default logs will be written to stdout/stderr streams)
### `TELEGRAM_MAX_CONNECTIONS` ### `TELEGRAM_MAX_CONNECTIONS`

View File

@ -1,20 +1,21 @@
#!/bin/sh #!/bin/sh
set -e set -e
LOG_FILENAME="telegram-bot-api.log"
USERNAME=telegram-bot-api USERNAME=telegram-bot-api
GROUPNAME=telegram-bot-api GROUPNAME=telegram-bot-api
chown ${USERNAME}:${GROUPNAME} "${TELEGRAM_LOGS_DIR}" "${TELEGRAM_WORK_DIR}" chown ${USERNAME}:${GROUPNAME} "${TELEGRAM_WORK_DIR}"
if [ -n "${1}" ]; then if [ -n "${1}" ]; then
exec "${*}" exec "${*}"
fi fi
DEFAULT_ARGS="--http-port 8081 --dir=${TELEGRAM_WORK_DIR} --temp-dir=${TELEGRAM_TEMP_DIR} --log=${TELEGRAM_LOGS_DIR}/${LOG_FILENAME} --username=${USERNAME} --groupname=${GROUPNAME}" DEFAULT_ARGS="--http-port 8081 --dir=${TELEGRAM_WORK_DIR} --temp-dir=${TELEGRAM_TEMP_DIR} --username=${USERNAME} --groupname=${GROUPNAME}"
CUSTOM_ARGS="" CUSTOM_ARGS=""
if [ -n "$TELEGRAM_LOG_FILE" ]; then
CUSTOM_ARGS="--log=${TELEGRAM_LOG_FILE}"
fi
if [ -n "$TELEGRAM_STAT" ]; then if [ -n "$TELEGRAM_STAT" ]; then
CUSTOM_ARGS="${CUSTOM_ARGS} --http-stat-port=8082" CUSTOM_ARGS="${CUSTOM_ARGS} --http-stat-port=8082"
fi fi