-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 011c367
Showing
17 changed files
with
2,071 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
.git | ||
.gitignore | ||
.github | ||
deploy |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,132 @@ | ||
name: build-docker-image | ||
|
||
on: [push, workflow_dispatch] | ||
|
||
jobs: | ||
build-base-image: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Login to GitHub Container Registry | ||
uses: docker/login-action@v1 | ||
with: | ||
registry: ghcr.io | ||
username: ksssomesh12 | ||
password: ${{ secrets.GH_PACKAGES_TOKEN }} | ||
|
||
- name: Setup Docker Buildx | ||
id: setup_buildx | ||
uses: docker/setup-buildx-action@v1 | ||
|
||
- name: Cache Docker Layers | ||
id: cache_docker_layers | ||
uses: actions/cache@v2 | ||
with: | ||
path: /tmp/.buildx-cache | ||
key: ${{ runner.os }}-buildx-app-base-${{ github.sha }} | ||
restore-keys: ${{ runner.os }}-buildx-app-base- | ||
|
||
- name: Build-Push Docker Image | ||
id: docker_build_push | ||
uses: docker/build-push-action@v2 | ||
with: | ||
builder: ${{ steps.setup_buildx.outputs.name }} | ||
target: app-base | ||
cache-from: type=local,src=/tmp/.buildx-cache | ||
cache-to: type=local,dest=/tmp/.buildx-cache-new | ||
push: true | ||
tags: ghcr.io/ksssomesh12/tgmb-beta:app-base | ||
|
||
- name: Move Docker Layer Cache | ||
run: | | ||
rm -rf /tmp/.buildx-cache | ||
mv /tmp/.buildx-cache-new /tmp/.buildx-cache | ||
build-compile-image: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Login to GitHub Container Registry | ||
uses: docker/login-action@v1 | ||
with: | ||
registry: ghcr.io | ||
username: ksssomesh12 | ||
password: ${{ secrets.GH_PACKAGES_TOKEN }} | ||
|
||
- name: Setup Docker Buildx | ||
id: setup_buildx | ||
uses: docker/setup-buildx-action@v1 | ||
|
||
- name: Cache Docker Layers | ||
id: cache_docker_layers | ||
uses: actions/cache@v2 | ||
with: | ||
path: /tmp/.buildx-cache | ||
key: ${{ runner.os }}-buildx-app-compile-${{ github.sha }} | ||
restore-keys: ${{ runner.os }}-buildx-app-compile- | ||
|
||
- name: Build-Push Docker Image | ||
id: docker_build_push | ||
uses: docker/build-push-action@v2 | ||
with: | ||
builder: ${{ steps.setup_buildx.outputs.name }} | ||
target: app-compile | ||
cache-from: type=local,src=/tmp/.buildx-cache | ||
cache-to: type=local,dest=/tmp/.buildx-cache-new | ||
push: true | ||
tags: ghcr.io/ksssomesh12/tgmb-beta:app-compile | ||
|
||
- name: Docker Image Digest | ||
run: echo ${{ steps.docker_build_push.outputs.digest }} | ||
|
||
- name: Move Docker Layer Cache | ||
run: | | ||
rm -rf /tmp/.buildx-cache | ||
mv /tmp/.buildx-cache-new /tmp/.buildx-cache | ||
build-final-image: | ||
runs-on: ubuntu-latest | ||
needs: [build-base-image, build-compile-image] | ||
steps: | ||
- name: Login to GitHub Container Registry | ||
uses: docker/login-action@v1 | ||
with: | ||
registry: ghcr.io | ||
username: ksssomesh12 | ||
password: ${{ secrets.GH_PACKAGES_TOKEN }} | ||
|
||
- name: Setup Docker Buildx | ||
id: setup_buildx | ||
uses: docker/setup-buildx-action@v1 | ||
|
||
- name: Cache Docker Layers | ||
id: cache_docker_layers | ||
uses: actions/cache@v2 | ||
with: | ||
path: /tmp/.buildx-cache | ||
key: ${{ runner.os }}-buildx-app-final-${{ github.sha }} | ||
restore-keys: ${{ runner.os }}-buildx-app-final- | ||
|
||
- name: Get Branch/Tag Ref | ||
id: get_ref | ||
shell: bash | ||
run: echo "##[set-output name=ref;]$(echo ${GITHUB_REF##*/})" | ||
|
||
- name: Build-Push Docker Image | ||
id: docker_build_push | ||
uses: docker/build-push-action@v2 | ||
with: | ||
builder: ${{ steps.setup_buildx.name }} | ||
target: app-final | ||
cache-from: type=local,src=/tmp/.buildx-cache | ||
cache-to: type=local,dest=/tmp/.buildx-cache-new | ||
push: true | ||
tags: | | ||
ghcr.io/ksssomesh12/tgmb-beta:${{ github.sha }} | ||
ghcr.io/ksssomesh12/tgmb-beta:${{ steps.get_ref.outputs.ref }} | ||
- name: Docker Image Digest | ||
run: echo ${{ steps.docker_build_push.outputs.digest }} | ||
|
||
- name: Move Docker Layer Cache | ||
run: | | ||
rm -rf /tmp/.buildx-cache | ||
mv /tmp/.buildx-cache-new /tmp/.buildx-cache |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
name: create-release | ||
|
||
on: | ||
push: | ||
tags: | ||
- "v*.*" | ||
|
||
jobs: | ||
create-release: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Create Release | ||
id: create_release | ||
uses: actions/create-release@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
tag_name: ${{ github.ref }} | ||
release_name: Release ${{ github.ref }} | ||
draft: false | ||
prerelease: false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
name: deploy-heroku | ||
|
||
on: workflow_dispatch | ||
|
||
jobs: | ||
deploy-heroku: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Setup Docker Buildx | ||
id: setup_buildx | ||
uses: docker/setup-buildx-action@v1 | ||
with: | ||
driver: docker | ||
install: true | ||
|
||
- name: Build-Push-Release App to Heroku | ||
env: | ||
DYNAMIC_ENV_FILEID: ${{ secrets.DYNAMIC_ENV_FILEID }} | ||
HEROKU_API_KEY: ${{ secrets.HEROKU_API_KEY }} | ||
HEROKU_APP_NAME: ${{ secrets.HEROKU_APP_NAME }} | ||
run: | | ||
heroku container:login | ||
echo "FROM ghcr.io/ksssomesh12/tgmb-beta:master | ||
COPY . . | ||
" >> Dockerfile | ||
echo "https://docs.google.com/uc?export=download&id=$DYNAMIC_ENV_FILEID" | aria2c --input-file=- | ||
docker build . -t registry.heroku.com/$HEROKU_APP_NAME/worker --progress=plain | ||
docker push registry.heroku.com/$HEROKU_APP_NAME/worker | ||
heroku container:release worker -a $HEROKU_APP_NAME |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
.idea |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
FROM ubuntu:latest as app-base | ||
ENV DEBIAN_FRONTEND='noninteractive' | ||
RUN apt-get update && apt-get upgrade -y && \ | ||
apt-get install -y aria2 curl jq libc++-dev locales nano pv python3 python3-pip python3-lxml tzdata && \ | ||
apt-get clean && rm -rf /var/lib/apt/lists/* | ||
RUN locale-gen en_US.UTF-8 | ||
ENV LANG='en_US.UTF-8' LANGUAGE='en_US:en' LC_ALL='en_US.UTF-8' TZ='Asia/Kolkata' | ||
|
||
FROM ubuntu:latest as app-compile | ||
ENV DEBIAN_FRONTEND='noninteractive' | ||
RUN apt-get update && apt-get upgrade -y && \ | ||
apt-get install -y git gperf make cmake clang-10 libc++-dev libc++abi-dev libssl-dev zlib1g-dev && \ | ||
apt-get clean && rm -rf /var/lib/apt/lists/* | ||
WORKDIR /root | ||
RUN git clone --recursive https://github.com/tdlib/telegram-bot-api.git && \ | ||
cd telegram-bot-api && git checkout 81f2983 && mkdir build && cd build && \ | ||
CXXFLAGS="-stdlib=libc++" CC=/usr/bin/clang-10 CXX=/usr/bin/clang++-10 \ | ||
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX:PATH=/usr .. && \ | ||
cmake --build . --target install -- -j $(nproc) && \ | ||
cd ../.. && rm -rf telegram-bot-api && \ | ||
ls -l /usr/bin/telegram-bot-api* | ||
|
||
FROM ghcr.io/ksssomesh12/tgmb-beta:app-base as base | ||
FROM ghcr.io/ksssomesh12/tgmb-beta:app-compile as compile | ||
|
||
FROM scratch as app-final | ||
COPY --from=base / / | ||
COPY --from=compile /usr/bin/telegram-bot-api /usr/bin | ||
WORKDIR /usr/src/app | ||
RUN chmod 777 /usr/src/app | ||
COPY requirements.txt . | ||
RUN pip3 install --no-cache-dir -r requirements.txt | ||
COPY . . | ||
CMD ["python3", "-m", "tgmb"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# tgmb-beta | ||
|
||
[![build-docker-image](https://github.com/ksssomesh12/tgmb-beta/actions/workflows/build-docker-image.yml/badge.svg)](https://github.com/ksssomesh12/tgmb-beta/actions/workflows/build-docker-image.yml) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
FROM ghcr.io/ksssomesh12/tgmb-beta:master | ||
COPY . . |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
botToken = "" | ||
botOwnerId = "" | ||
telegramApiId = "" | ||
telegramApiHash = "" | ||
googleDriveFolderId = "" | ||
authorizedChats = "" | ||
ariaRpcSecret = "tgmb-beta" | ||
dlRootDir = "dl" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
build: | ||
docker: | ||
worker: Dockerfile |
Oops, something went wrong.