From 7f8baa4fd3aec4cc547b7eb361b1a9292d3053cc Mon Sep 17 00:00:00 2001 From: onurmercury <141233985+onurmercury@users.noreply.github.com> Date: Sat, 15 Jun 2024 16:39:06 +0300 Subject: [PATCH] Improve container support - Switch to Python container image - Switch to Pyrofork - Introduce Compose file support, container registry support and Actions support for possible future use --- .github/workflows/build.yml | 39 +++++++++++++++++++++++++++++++++++++ Dockerfile | 17 ++++++++++++++++ compose.yaml | 12 ++++++++++++ dockerfile | 16 --------------- requirements.txt | 6 +++--- 5 files changed, 71 insertions(+), 19 deletions(-) create mode 100644 .github/workflows/build.yml create mode 100644 Dockerfile create mode 100644 compose.yaml delete mode 100644 dockerfile diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..78c66e5 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,39 @@ +name: Build & Push + +on: + workflow_dispatch: + push: + branches: + - main + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + - name: Login to GitHub Container Registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} +# - name: Login to Docker Hub +# uses: docker/login-action@v3 +# with: +# username: ${{ secrets.DOCKERHUB_USERNAME }} +# password: ${{ secrets.DOCKERHUB_TOKEN }} + - name: Build & Push + uses: docker/build-push-action@v5 + with: + context: . + file: ./Dockerfile + platforms: linux/amd64,linux/386,linux/arm64,linux/arm/v7,linux/arm/v5 + push: true + tags: | + ghcr.io/${{ github.repository_owner }}/ketard-ai:latest +# ${{ secrets.DOCKERHUB_USERNAME }}/ketard-ai:latest diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..2d7ea7b --- /dev/null +++ b/Dockerfile @@ -0,0 +1,17 @@ +FROM python:3-alpine + +# Copy files and set working directory +COPY . /app +WORKDIR /app + +# Install dependencies +RUN set -eux; \ + apk add --no-cache \ + build-base \ + g++ gcc \ + linux-headers \ + musl-dev; \ + pip install --no-cache-dir -Ur requirements.txt + +# Set execution command +CMD ["python", "ketard.py"] diff --git a/compose.yaml b/compose.yaml new file mode 100644 index 0000000..e6e559f --- /dev/null +++ b/compose.yaml @@ -0,0 +1,12 @@ +services: + app: + container_name: ketard-ai + build: + context: . + dockerfile: Dockerfile + image: ghcr.io/ket0x4/ketard-ai:latest + restart: on-failure + volumes: + - type: bind + source: ./settings.json + target: /app/settings.json diff --git a/dockerfile b/dockerfile deleted file mode 100644 index 1da231b..0000000 --- a/dockerfile +++ /dev/null @@ -1,16 +0,0 @@ -FROM alpine:edge - -# Set the working directory -WORKDIR /app - -# Copy the project files to the container -COPY ketard.py /app/ -COPY requirements.txt /app/ -COPY settings.json /app/ - -# Install any dependencies -RUN apk add --no-cache linux-headers python3 python3-dev py3-pip gcc musl-dev g++ build-base -RUN pip3 install --no-cache-dir -r requirements.txt - -# Set the entry point command -CMD ["python3 ketard.py"] \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index 10ff054..93694f1 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,5 @@ +asyncio langchain_community -https://github.com/KurimuzonAkuma/pyrogram/archive/dev.zip psutil -asyncio -TgCrypto \ No newline at end of file +pyrofork +TgCrypto