diff --git a/.github/workflows/build-docker-image.yml b/.github/workflows/build-docker-image.yml deleted file mode 100644 index 7bb0a7c..0000000 --- a/.github/workflows/build-docker-image.yml +++ /dev/null @@ -1,130 +0,0 @@ -name: build-docker-image - -on: [push, workflow_dispatch] - -jobs: - build-api: - 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-api-${{ github.sha }} - restore-keys: ${{ runner.os }}-buildx-tgmb-api- - - - 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: api - 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:api - - - 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-sdk: - 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-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: 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:sdk - - - 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-app: - runs-on: ubuntu-latest - needs: [build-api, build-sdk] - 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-app-${{ github.sha }} - restore-keys: ${{ runner.os }}-buildx-tgmb-app- - - - name: Build-Push Docker Image - id: docker_build_push - uses: docker/build-push-action@v3.2.0 - with: - builder: ${{ steps.setup_buildx.name }} - target: app - 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:${{ github.ref_name }} - - - 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 diff --git a/.github/workflows/build-image.yml b/.github/workflows/build-image.yml new file mode 100644 index 0000000..5b4777d --- /dev/null +++ b/.github/workflows/build-image.yml @@ -0,0 +1,94 @@ +name: build-image + +on: [push, workflow_dispatch] + +jobs: + build-api: + runs-on: ubuntu-22.04 + steps: + - name: Login to Docker Hub + uses: docker/login-action@v2.1.0 + with: + registry: docker.io + username: sssomeshhh + password: ${{ secrets.DOCKER_HUB_TOKEN }} + - name: Setup Docker Buildx + id: setup_buildx + uses: docker/setup-buildx-action@v2.2.1 + - name: Build Load 'api' + id: docker_load_api + uses: docker/build-push-action@v3.2.0 + with: + builder: ${{ steps.setup_buildx.outputs.name }} + target: api + cache-from: | + type=registry,ref=sssomeshhh/cache:tgmb-api-master + type=registry,ref=sssomeshhh/cache:tgmb-api-${{ github.ref_name }} + cache-to: | + type=registry,ref=sssomeshhh/cache:tgmb-api-${{ github.ref_name }} + load: false + push: false + + build-sdk: + runs-on: ubuntu-22.04 + steps: + - name: Login to Docker Hub + uses: docker/login-action@v2.1.0 + with: + registry: docker.io + username: sssomeshhh + password: ${{ secrets.DOCKER_HUB_TOKEN }} + - name: Setup Docker Buildx + id: setup_buildx + uses: docker/setup-buildx-action@v2.2.1 + - name: Build Load 'sdk' + id: docker_load_sdk + uses: docker/build-push-action@v3.2.0 + with: + builder: ${{ steps.setup_buildx.outputs.name }} + target: sdk + cache-from: | + type=registry,ref=sssomeshhh/cache:tgmb-sdk-master + type=registry,ref=sssomeshhh/cache:tgmb-sdk-${{ github.ref_name }} + cache-to: | + type=registry,ref=sssomeshhh/cache:tgmb-sdk-${{ github.ref_name }} + load: false + push: false + + build-app: + runs-on: ubuntu-22.04 + needs: [build-api, build-sdk] + 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: Login to Docker Hub + uses: docker/login-action@v2.1.0 + with: + registry: docker.io + username: sssomeshhh + password: ${{ secrets.DOCKER_HUB_TOKEN }} + - name: Setup Docker Buildx + id: setup_buildx + uses: docker/setup-buildx-action@v2.2.1 + - name: Build Push 'app' + id: docker_push_app + uses: docker/build-push-action@v3.2.0 + with: + builder: ${{ steps.setup_buildx.name }} + target: app + cache-from: | + type=registry,ref=sssomeshhh/cache:tgmb-api-${{ github.ref_name }} + type=registry,ref=sssomeshhh/cache:tgmb-sdk-${{ github.ref_name }} + type=registry,ref=sssomeshhh/cache:tgmb-app-master + type=registry,ref=sssomeshhh/cache:tgmb-app-${{ github.ref_name }} + cache-to: | + type=registry,ref=sssomeshhh/cache:tgmb-app-${{ github.ref_name }} + load: false + push: true + tags: | + ghcr.io/ksssomesh12/tgmb-beta:${{ github.sha }} + ghcr.io/ksssomesh12/tgmb-beta:${{ github.ref_name }} diff --git a/.github/workflows/github-release.yml b/.github/workflows/github-release.yml index f0bbb84..2ce58b7 100644 --- a/.github/workflows/github-release.yml +++ b/.github/workflows/github-release.yml @@ -7,7 +7,7 @@ on: jobs: create-release: - runs-on: ubuntu-latest + runs-on: ubuntu-22.04 steps: - name: Create Release id: create_release @@ -21,7 +21,7 @@ jobs: prerelease: false deploy-package: - runs-on: ubuntu-latest + runs-on: ubuntu-22.04 needs: [create-release] steps: - name: Checkout Repo @@ -29,13 +29,11 @@ jobs: uses: actions/checkout@v3 with: submodules: recursive - - name: Create Package id: create_package run: | rm -rvf ./deploy/.git* tar -cvf deploy.tar deploy - - name: Upload Package id: upload_package uses: softprops/action-gh-release@v1 diff --git a/.github/workflows/pypi-release.yml b/.github/workflows/pypi-release.yml index 0997a3c..c54f731 100644 --- a/.github/workflows/pypi-release.yml +++ b/.github/workflows/pypi-release.yml @@ -7,20 +7,18 @@ on: jobs: create-release: - runs-on: ubuntu-latest + runs-on: ubuntu-22.04 steps: - name: Setup Python 3.9 id: setup_python uses: actions/setup-python@v4.3.0 with: python-version: 3.9 - - name: Checkout Repo id: checkout_repo uses: actions/checkout@v3 with: submodules: recursive - - name: Build Dist id: build_dist env: @@ -30,7 +28,6 @@ jobs: python3 -m pip install build --user python3 -m build ls -shl dist/ - - name: Publish to PyPI id: publish_pypi uses: pypa/gh-action-pypi-publish@v1.5.1 diff --git a/Dockerfile b/Dockerfile index 543ad38..fc8a687 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,46 +1,76 @@ -FROM ubuntu:jammy as api +######################################################################################################################## +FROM ubuntu:jammy AS ubuntu +######################################################################################################################## +FROM ubuntu AS api ENV DEBIAN_FRONTEND='noninteractive' -RUN apt-get update && apt-get upgrade -y && \ - apt-get install -y git gperf make cmake clang-14 libc++-dev libc++abi-dev libssl-dev zlib1g-dev && \ +RUN apt-get update && \ + apt-get install --yes --no-install-recommends \ + git gperf make cmake clang-14 libc++-dev libc++abi-dev libssl-dev zlib1g-dev \ + && \ rm -rf /var/lib/apt/lists/* WORKDIR /root 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 .. && \ +ARG CC="/usr/bin/clang-14" +ARG CXX="/usr/bin/clang++-14" +ARG CXXFLAGS="-stdlib=libc++" +RUN cd api && \ + rm -rf .git && \ + mkdir build && \ + cd build && \ + cmake \ + -DCMAKE_BUILD_TYPE=Release \ + -DCMAKE_INSTALL_PREFIX:PATH=.. .. \ + && \ + cmake \ + --build . \ + --target install \ + -- -j $(nproc) \ + && \ + cd .. && \ ls -lh bin/telegram-bot-api* - -FROM ubuntu:jammy as sdk +######################################################################################################################## +FROM ubuntu 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 && \ +RUN apt-get update && \ + apt-get install --yes --no-install-recommends \ + autoconf automake gcc g++ git libtool make python3 python3-dev python3-distutils python3-pip \ + libc-ares-dev libcrypto++-dev libcurl4-openssl-dev libfreeimage-dev libsodium-dev \ + libsqlite3-dev libssl-dev swig zlib1g-dev \ + && \ rm -rf /var/lib/apt/lists/* WORKDIR /root 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 && \ +RUN cd sdk && \ + rm -rf .git && \ + 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:api as app-api -FROM ghcr.io/ksssomesh12/tgmb-beta:sdk as app-sdk - -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 +######################################################################################################################## +FROM ubuntu AS app +COPY --from=api /root/api/bin/telegram-bot-api /usr/bin/telegram-bot-api +COPY --from=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 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 && \ +RUN apt-get update && \ + apt-get install --yes \ + 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 && \ + apt-get install --yes --no-install-recommends \ + aria2 curl ffmpeg jq locales nano pv python3 python3-pip python3-lxml qbittorrent-nox tzdata \ + libc++-dev libmagic-dev libcrypto++-dev libfreeimage-dev \ + && \ rm -rf /var/lib/apt/lists/* RUN locale-gen en_US.UTF-8 RUN pip3 install --no-cache-dir /root/sdk/bindings/python/dist/megasdk-*.whl @@ -48,6 +78,8 @@ WORKDIR /usr/src/app RUN chmod 777 /usr/src/app COPY Pipfile . COPY grt.py . -RUN python3 grt.py && pip3 install --no-cache-dir -r requirements.txt +RUN python3 grt.py && \ + pip3 install --no-cache-dir -r requirements.txt COPY tgmb tgmb CMD ["python3", "-m", "tgmb"] +########################################################################################################################