mirror of
https://github.com/tdlight-team/tdlight-telegram-bot-api.git
synced 2025-01-24 02:37:40 +01:00
Update docker.yml, Dockerfile, and docker-entrypoint.sh
This commit is contained in:
parent
4af4c5a73c
commit
d376aa22ec
50
.github/workflows/docker.yml
vendored
50
.github/workflows/docker.yml
vendored
@ -12,7 +12,8 @@ jobs:
|
|||||||
name: Build Image
|
name: Build Image
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
env:
|
env:
|
||||||
IMAGE_id: docker.pkg.github.com/${{ github.repository }}/${{ github.repository }}
|
REGISTRY: ghcr.io
|
||||||
|
IMAGE_TAG: ghcr.io/tdlight-team/tdlightbotapi
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout current repo
|
- name: Checkout current repo
|
||||||
@ -20,33 +21,50 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
submodules: "recursive"
|
submodules: "recursive"
|
||||||
|
|
||||||
- name: Get Version
|
- name: Get version
|
||||||
run: |
|
run: |
|
||||||
# get telegram bot api version
|
# Get latest commit short hash
|
||||||
telegram_bot_api_version=$(git rev-parse --short HEAD)
|
HASH_VERSION=$(git rev-parse --short HEAD)
|
||||||
|
|
||||||
# get tdlib version
|
# Strip git ref prefix from version
|
||||||
tdlib_version=$(cd td && git rev-parse --short HEAD)
|
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
|
||||||
|
|
||||||
|
# Strip "v" prefix from tag name
|
||||||
|
[[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//')
|
||||||
|
|
||||||
|
# Use Docker `latest` tag convention
|
||||||
|
[ "$VERSION" == "master" ] && VERSION=latest
|
||||||
|
|
||||||
|
# Convert IMAGE_ID and VERSION to lowercase (repository name must be lowercase)
|
||||||
|
IMAGE_ID=$(echo "$IMAGE_ID" | awk '{print tolower($0)}')
|
||||||
|
HASH_VERSION=$(echo "$HASH_VERSION" | awk '{print tolower($0)}')
|
||||||
|
VERSION=$(echo "$VERSION" | awk '{print tolower($0)}')
|
||||||
|
|
||||||
# concat tdlib and telegram bot api version
|
# Store variable for future use
|
||||||
version=$telegram_bot_api_version-$tdlib_version
|
echo "HASH_VERSION=$HASH_VERSION" >> $GITHUB_ENV
|
||||||
|
echo "VERSION=$VERSION" >> $GITHUB_ENV
|
||||||
|
|
||||||
# store variable for future use
|
# Print debug info
|
||||||
echo "version=$version" >> $GITHUB_ENV
|
echo "hash version: $HASH_VERSION"
|
||||||
|
echo "version: $VERSION"
|
||||||
|
|
||||||
- name: Build image
|
- name: Build image
|
||||||
run: |
|
run: |
|
||||||
IMAGE_ID=docker.pkg.github.com/${{ github.repository }}/${{ github.repository }}
|
|
||||||
docker build \
|
docker build \
|
||||||
--tag tdlight-team/tdlight-telegram-bot-api:latest \
|
--cache-from $IMAGE_TAG:latest \
|
||||||
--tag tdlight-team/tdlight-telegram-bot-api:$version \
|
--tag $IMAGE_TAG:$HASH_VERSION \
|
||||||
|
--tag $IMAGE_TAG:$VERSION \
|
||||||
.
|
.
|
||||||
|
|
||||||
- name: Login to registry
|
- name: Login to registry
|
||||||
run: |
|
run: |
|
||||||
echo "${{ secrets.GITHUB_ACCESS_TOKEN }}" | docker login docker.pkg.github.com -u ${{ github.actor }} --password-stdin
|
echo "${{ secrets.GH_ACCESS_TOKEN }}" | docker login $REGISTRY -u ${{ github.actor }} --password-stdin
|
||||||
|
|
||||||
|
|
||||||
- name: Push images
|
- name: Push images
|
||||||
run: |
|
run: |
|
||||||
docker push $IMAGE_ID:$version
|
docker push $IMAGE_TAG:$VERSION
|
||||||
|
docker push $IMAGE_TAG:$HASH_VERSION
|
||||||
|
|
||||||
|
- name: Logout from registry
|
||||||
|
run: |
|
||||||
|
docker logout $REGISTRY
|
||||||
|
@ -17,10 +17,11 @@ RUN cmake --build . --target install --
|
|||||||
|
|
||||||
FROM alpine:3.12.1
|
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 --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
|
HEALTHCHECK CMD curl -f http://localhost:8082/ || exit 1
|
||||||
|
|
||||||
ENTRYPOINT ["/usr/local/bin/telegram-bot-api -s 8082"]
|
ENTRYPOINT ["/docker-entrypoint.sh"]
|
||||||
|
43
docker-entrypoint.sh
Executable file
43
docker-entrypoint.sh
Executable file
@ -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
|
Loading…
x
Reference in New Issue
Block a user