Various Dockerfile fixes and enhancements (#13)

* fix docker file and add in readme

* fix Readme
This commit is contained in:
matteo bocci aka matteob99 2020-11-25 08:32:01 +01:00 committed by GitHub
parent 8943f285a7
commit 19c38c61b3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 18 additions and 10 deletions

View File

@ -5,7 +5,6 @@ RUN apk add --no-cache --update alpine-sdk linux-headers git zlib-dev openssl-de
WORKDIR /usr/src/telegram-bot-api WORKDIR /usr/src/telegram-bot-api
COPY CMakeLists.txt /usr/src/telegram-bot-api COPY CMakeLists.txt /usr/src/telegram-bot-api
COPY docker-entrypoint.sh /usr/src/telegram-bot-api
ADD td /usr/src/telegram-bot-api/td ADD td /usr/src/telegram-bot-api/td
ADD telegram-bot-api /usr/src/telegram-bot-api/telegram-bot-api ADD telegram-bot-api /usr/src/telegram-bot-api/telegram-bot-api
@ -17,8 +16,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++ curl RUN apk add --no-cache --update openssl libstdc++ curl
@ -27,9 +25,10 @@ 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} \
&& chown nobody:nobody /tmp/telegram-bot-api && chown nobody:nobody ${TELEGRAM_TEMP_DIR}
USER telegram-bot-api:telegram-bot-api
HEALTHCHECK CMD curl -f http://localhost:8082/ || exit 1 HEALTHCHECK CMD curl -f http://localhost:8082/ || exit 1
EXPOSE 8081/tcp 8082/tcp EXPOSE 8081/tcp 8082/tcp

View File

@ -129,7 +129,12 @@ The bot will now receive Updates for all received media, even if a destruction t
<a name="installation"></a> <a name="installation"></a>
## Installation ## Installation
The simplest way to build and install `Telegram Bot API server` is to use our [Telegram Bot API server build instructions generator](https://tdlib.github.io/telegram-bot-api/build.html). The simplest way to use it is with this docker command:
```
docker run -p 8081:8081 --env TELEGRAM_API_ID=API_ID --env TELEGRAM_API_HASH=API_HASH tdlight/tdlightbotapi
```
The simplest way to build `Telegram Bot API server` is to use our [Telegram Bot API server build instructions generator](https://tdlib.github.io/telegram-bot-api/build.html).
If you do that, you'll only need to choose the target operating system to receive the complete build instructions. If you do that, you'll only need to choose the target operating system to receive the complete build instructions.
In general, you need to install all `Telegram Bot API server` [dependencies](#dependencies) and compile the source code using CMake: In general, you need to install all `Telegram Bot API server` [dependencies](#dependencies) and compile the source code using CMake:

View File

@ -1,18 +1,17 @@
#!/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}"
CUSTOM_ARGS="" CUSTOM_ARGS=""
if [ -n "$TELEGRAM_STAT" ]; then if [ -n "$TELEGRAM_STAT" ]; then
@ -48,6 +47,11 @@ fi
if [ -n "$TELEGRAM_MAX_BATCH" ]; then if [ -n "$TELEGRAM_MAX_BATCH" ]; then
CUSTOM_ARGS="${CUSTOM_ARGS} ---max-batch-operations=$TELEGRAM_MAX_BATCH" CUSTOM_ARGS="${CUSTOM_ARGS} ---max-batch-operations=$TELEGRAM_MAX_BATCH"
fi fi
if [ -n "$TELEGRAM_LOGS" ]; then
CUSTOM_ARGS="$CUSTOM_ARGS --log=${TELEGRAM_LOGS}"
else
CUSTOM_ARGS="$CUSTOM_ARGS --log=/proc/1/fd/1"
fi
COMMAND="telegram-bot-api ${DEFAULT_ARGS}${CUSTOM_ARGS}" COMMAND="telegram-bot-api ${DEFAULT_ARGS}${CUSTOM_ARGS}"