From df2b3f7a320a3f5d74c861413586cc689823c4f0 Mon Sep 17 00:00:00 2001 From: kenwoodjw Date: Sun, 17 Dec 2023 16:23:18 +0800 Subject: [PATCH 1/3] Create Dockerfile --- Dockerfile | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..27527c1 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,19 @@ +FROM bitnami/python:3.10 +WORKDIR /app +RUN apt-get update \ + && apt-get install -y --no-install-recommends \ + gdal-bin \ + libgdal-dev \ + libcairo2 \ + && rm -rf /var/lib/apt/lists/* +# 设置环境变量,使得 Python 包安装程序可以找到 gdal-config +ENV CPLUS_INCLUDE_PATH=/usr/include/gdal +ENV C_INCLUDE_PATH=/usr/include/gdal +# Copy necessary files +COPY requirements.txt ./ +RUN pip install --upgrade pip && pip install --no-cache-dir -r requirements.txt +# 复制项目文件到容器中 +COPY *.py . +COPY handlers /app/handlers +ENV GOOGLE_GEMINI_KEY=your_google_gemini_apikey +CMD python tg.py ${TELEGRAM_BOT_TOKEN} From 5cc6a750bd7cb3a1087820327c977097d526f090 Mon Sep 17 00:00:00 2001 From: kenwoodjw Date: Sun, 17 Dec 2023 16:26:59 +0800 Subject: [PATCH 2/3] Update README.md --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index 249ccaf..d0dcc98 100644 --- a/README.md +++ b/README.md @@ -45,6 +45,10 @@ for yihong0618's channel: https://t.me/hyi0618 3. export GOOGLE_GEMINI_KEY=${your_google_gemini_apikey} 4. python tg.py ${telegram_bot_token} +### Run from Docker +1. docker build -t tg_bot_collections . +2. docker run -d --name tg_bot_collections -e GOOGLE_GEMINI_KEY='${GOOGLE_GEMINI_KEY}' -e TELEGRAM_BOT_TOKEN='${TELEGRAM_BOT_TOKEN}' --network host tg_bot_collections + ## HOW TO Use From 2cfecc53bc6653382240069ec5e330512e50b658 Mon Sep 17 00:00:00 2001 From: kenwoodjw Date: Sun, 17 Dec 2023 19:53:23 +0800 Subject: [PATCH 3/3] Update comments to English --- Dockerfile | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index 27527c1..879da67 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,19 +1,21 @@ FROM bitnami/python:3.10 WORKDIR /app +# Update the package list and install necessary packages including GDAL and Cairo RUN apt-get update \ && apt-get install -y --no-install-recommends \ gdal-bin \ libgdal-dev \ libcairo2 \ && rm -rf /var/lib/apt/lists/* -# 设置环境变量,使得 Python 包安装程序可以找到 gdal-config +# Set environment variables so that Python package installer can find gdal-config ENV CPLUS_INCLUDE_PATH=/usr/include/gdal ENV C_INCLUDE_PATH=/usr/include/gdal # Copy necessary files COPY requirements.txt ./ +# Upgrade pip and install dependencies from requirements.txt RUN pip install --upgrade pip && pip install --no-cache-dir -r requirements.txt -# 复制项目文件到容器中 +# Copy project files into the container COPY *.py . COPY handlers /app/handlers -ENV GOOGLE_GEMINI_KEY=your_google_gemini_apikey +# Command to run the application, using the TELEGRAM_BOT_TOKEN environment variable CMD python tg.py ${TELEGRAM_BOT_TOKEN}