Skip to content

Commit

Permalink
Merge pull request #35
Browse files Browse the repository at this point in the history
merge ubuntu-jammy with master
  • Loading branch information
sssomeshhh authored Nov 8, 2022
2 parents 1763aa7 + 33f900c commit 7bf4ef4
Show file tree
Hide file tree
Showing 8 changed files with 517 additions and 410 deletions.
53 changes: 6 additions & 47 deletions .github/workflows/build-docker-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,47 +3,6 @@ name: build-docker-image
on: [push, workflow_dispatch]

jobs:
build-base:
runs-on: ubuntu-latest
steps:
- name: Login to GitHub Container Registry
uses: docker/login-action@v2.1.0
with:
registry: ghcr.io
username: ksssomesh12
password: ${{ secrets.GH_PACKAGES_TOKEN }}

- name: Setup Docker Buildx
id: setup_buildx
uses: docker/setup-buildx-action@v2.2.1

- name: Cache Docker Layers
id: cache_docker_layers
uses: actions/cache@v3.0.11
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-tgmb-base-${{ github.sha }}
restore-keys: ${{ runner.os }}-buildx-tgmb-base-

- name: Build-Push Docker Image
id: docker_build_push
uses: docker/build-push-action@v3.2.0
with:
builder: ${{ steps.setup_buildx.outputs.name }}
target: 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:base

- 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-api:
runs-on: ubuntu-latest
steps:
Expand Down Expand Up @@ -85,7 +44,7 @@ jobs:
rm -rf /tmp/.buildx-cache
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
build-mega:
build-sdk:
runs-on: ubuntu-latest
steps:
- name: Login to GitHub Container Registry
Expand All @@ -104,19 +63,19 @@ jobs:
uses: actions/cache@v3.0.11
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-tgmb-mega-${{ github.sha }}
restore-keys: ${{ runner.os }}-buildx-tgmb-mega-
key: ${{ runner.os }}-buildx-tgmb-sdk-${{ github.sha }}
restore-keys: ${{ runner.os }}-buildx-tgmb-sdk-

- name: Build-Push Docker Image
id: docker_build_push
uses: docker/build-push-action@v3.2.0
with:
builder: ${{ steps.setup_buildx.outputs.name }}
target: mega
target: sdk
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:mega
tags: ghcr.io/ksssomesh12/tgmb-beta:sdk

- name: Docker Image Digest
run: echo ${{ steps.docker_build_push.outputs.digest }}
Expand All @@ -128,7 +87,7 @@ jobs:
build-app:
runs-on: ubuntu-latest
needs: [build-base, build-api, build-mega]
needs: [build-api, build-sdk]
steps:
- name: Login to GitHub Container Registry
uses: docker/login-action@v2.1.0
Expand Down
6 changes: 6 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
[submodule "deploy"]
path = deploy
url = https://github.com/ksssomesh12/tgmb-beta-deploy.git
[submodule "api"]
path = api
url = https://github.com/tdlib/telegram-bot-api.git
[submodule "sdk"]
path = sdk
url = https://github.com/meganz/sdk.git
47 changes: 20 additions & 27 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,59 +1,52 @@
FROM ubuntu:focal as base
FROM ubuntu:jammy as api
ENV DEBIAN_FRONTEND='noninteractive'
RUN apt-get update && apt-get upgrade -y && \
apt-get install -y aria2 curl ffmpeg jq libc++-dev locales nano pv python3 python3-pip python3-lxml tzdata && \
rm -rf /var/lib/apt/lists/*
RUN locale-gen en_US.UTF-8

FROM ubuntu:focal as api
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 install -y git gperf make cmake clang-14 libc++-dev libc++abi-dev libssl-dev zlib1g-dev && \
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 ab2f0f0 && git submodule update && mkdir build && cd build && \
CXXFLAGS="-stdlib=libc++" CC=/usr/bin/clang-10 CXX=/usr/bin/clang++-10 \
COPY api api
RUN cd api && rm -rf .git && mkdir build && cd build && \
CXXFLAGS="-stdlib=libc++" CC=/usr/bin/clang-14 CXX=/usr/bin/clang++-14 \
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX:PATH=.. .. && \
cmake --build . --target install -- -j $(nproc) && cd .. && \
ls -lh bin/telegram-bot-api*

FROM ubuntu:focal as mega
FROM ubuntu:jammy as sdk
ENV DEBIAN_FRONTEND='noninteractive'
RUN apt-get update && apt-get upgrade -y && \
apt-get install -y autoconf automake gcc g++ git libtool make python3 python3-dev python3-distutils python3-pip && \
apt-get install -y libc-ares-dev libcrypto++-dev libcurl4-openssl-dev libfreeimage-dev libsodium-dev && \
apt-get install -y libsqlite3-dev libssl-dev swig zlib1g-dev && \
rm -rf /var/lib/apt/lists/*
WORKDIR /root
RUN git clone https://github.com/meganz/sdk.git mega-sdk/ && cd mega-sdk/ && \
git checkout v4.6.0 && \
./autogen.sh && ./configure --disable-silent-rules --enable-python --with-sodium --disable-examples && \
COPY sdk sdk
COPY ac-m4-py.patch .
RUN cd sdk && rm -rf .git && mv ../ac-m4-py.patch ./ && git apply ac-m4-py.patch && ./clean.sh && ./autogen.sh && \
./configure --disable-examples --disable-silent-rules --enable-python --with-sodium && \
make -j $(nproc) && cd bindings/python/ && python3 setup.py bdist_wheel && \
ls -lh dist/megasdk*

FROM ghcr.io/ksssomesh12/tgmb-beta:base as app-base
FROM ghcr.io/ksssomesh12/tgmb-beta:api as app-api
FROM ghcr.io/ksssomesh12/tgmb-beta:mega as app-mega
FROM ghcr.io/ksssomesh12/tgmb-beta:sdk as app-sdk

FROM scratch as app
COPY --from=app-base / /
COPY --from=app-api /root/telegram-bot-api/bin/telegram-bot-api /usr/bin/telegram-bot-api
COPY --from=app-mega /root/mega-sdk /root/mega-sdk
ENV LANG='en_US.UTF-8' LANGUAGE='en_US:en' LC_ALL='en_US.UTF-8' TZ='Asia/Kolkata'
FROM ubuntu:jammy as app
COPY --from=app-api /root/api/bin/telegram-bot-api /usr/bin/telegram-bot-api
COPY --from=app-sdk /root/sdk /root/sdk
ENV DEBIAN_FRONTEND='noninteractive'
ENV LANG='en_US.UTF-8' LANGUAGE='en_US:en' LC_ALL='en_US.UTF-8' TZ='Asia/Kolkata'
RUN apt-get update && apt-get upgrade -y && \
apt-get install -y libcrypto++-dev libfreeimage-dev && \
apt-get install -y software-properties-common && \
apt-get install -y aria2 curl ffmpeg jq locales nano pv python3 python3-pip python3-lxml tzdata && \
apt-get install -y libc++-dev libmagic-dev libcrypto++-dev libfreeimage-dev software-properties-common && \
add-apt-repository ppa:qbittorrent-team/qbittorrent-stable && \
apt-get install -y qbittorrent-nox && \
apt-get purge -y software-properties-common && \
apt-get autoremove -y && \
rm -rf /var/lib/apt/lists/*
RUN pip3 install --no-cache-dir /root/mega-sdk/bindings/python/dist/megasdk-*.whl
RUN locale-gen en_US.UTF-8
RUN pip3 install --no-cache-dir /root/sdk/bindings/python/dist/megasdk-*.whl
WORKDIR /usr/src/app
RUN chmod 777 /usr/src/app
COPY requirements.txt .
RUN pip3 install --no-cache-dir -r requirements.txt
COPY . .
COPY tgmb tgmb
CMD ["python3", "-m", "tgmb"]
2 changes: 1 addition & 1 deletion Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ coverage = "*"
twine = "*"

[requires]
python_version = "3.8"
python_version = "3.10"
Loading

0 comments on commit 7bf4ef4

Please sign in to comment.