Skip to content

Commit

Permalink
0.2.1 feat and hot fix (#64)
Browse files Browse the repository at this point in the history
* docs: update docker.md and version up

* chore: version up

* deps: update pydantic (2.10.2 -> 2.10.3), fastapi (0.115.5 -> 0.115.6)

* chore: update base image for CI/CD to Alpine 3.21

* deps: update deps

* feat: added the basic functionality to check for updates to Docker images.

* feat: added the basic functionality to check for updates to Docker images.

* fix: ValueError: time data does not match format '%Y-%m-%dT%H:%M:%S.%fZ'

* feat: current tag update info - first!

* chore: update template format

* chore: update Dockerfile

* chore: update deps

* feat: more fine-tuning of the module

* feat: bump version to 0.2.1

* deps: update min ver

* chore: added action for rebuild all supported tags

* chore: added action for rebuild all supported tags

* feat: bump version to 0.2.1
  • Loading branch information
orenlab authored Dec 26, 2024
1 parent 8b5934f commit 2ba3b0c
Show file tree
Hide file tree
Showing 24 changed files with 1,352 additions and 664 deletions.
48 changes: 48 additions & 0 deletions .github/workflows/ci_rebuild.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: CI Rebuild All Supported Tags

on:
schedule:
- cron: '0 13 * * 4' # Run every Thursday at 13:00 UTC (18:00 Yekaterinburg time)
workflow_dispatch: # Allow manual trigger

jobs:
docker:
runs-on: ubuntu-latest

steps:
# Set up git and clone the repository
- name: Checkout repository
uses: actions/checkout@v3

# Retrieve all tags and filter by minimum version
- name: Get all supported tags
id: get_tags
run: |
git fetch --tags
# Retrieve all tags in 0.0.0 format starting from 0.2.0
min_version="0.2.0"
tags=$(git tag -l | sort -V | awk -v min_version="$min_version" '$0 >= min_version')
latest_tag=$(echo "$tags" | tail -n 1)
echo "tags=$tags" >> $GITHUB_ENV
echo "latest_tag=$latest_tag" >> $GITHUB_ENV
# Log in to Docker Hub
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

# Build and push Docker images
- name: Build and push Docker images
uses: docker/build-push-action@v5
with:
context: .
build-args: --target prod
sbom: true
provenance: true
file: hub.Dockerfile
push: true
tags: |
${{ join(fromJson(env.tags), ',') }}
orenlab/pytmbot:latest
2 changes: 1 addition & 1 deletion .github/workflows/development_image_ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
# Trigger the workflow on pushes to the master branch
push:
branches:
- 'master'
- '0.2.1'

jobs:
push_dev_image:
Expand Down
84 changes: 42 additions & 42 deletions .run/Dockerfile.run.xml
Original file line number Diff line number Diff line change
@@ -1,44 +1,44 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Dockerfile" type="docker-deploy" factoryName="dockerfile" server-name="Docker">
<deployment type="dockerfile">
<settings>
<option name="imageTag" value="latest" />
<option name="containerName" value="pytmbot" />
<option name="sourceFilePath" value="Dockerfile" />
<option name="volumeBindings">
<list>
<DockerVolumeBindingImpl>
<option name="containerPath" value="/var/run/docker.sock" />
<option name="hostPath" value="/var/run/docker.sock" />
<option name="readOnly" value="true" />
</DockerVolumeBindingImpl>
</list>
</option>
</settings>
</deployment>
<method v="2" />
</configuration>
<configuration default="false" name="Dockerfile" type="docker-deploy" factoryName="dockerfile" server-name="Docker">
<deployment type="dockerfile">
<settings>
<option name="imageTag" value="orenlab/pytmbot:latest" />
<option name="buildCliOptions" value="--target self_build" />
<option name="command" value="--log-level DEBUG --mode dev" />
<option name="containerName" value="pytmbot" />
<option name="commandLineOptions" value="" />
<option name="showCommandPreview" value="true" />
<option name="sourceFilePath" value="Dockerfile" />
<option name="volumeBindings">
<list>
<DockerVolumeBindingImpl>
<option name="containerPath" value="/var/run/docker.sock" />
<option name="hostPath" value="/var/run/docker.sock" />
<option name="readOnly" value="true" />
</DockerVolumeBindingImpl>
</list>
</option>
</settings>
</deployment>
<method v="2" />
</configuration>
<configuration default="false" name="Dockerfile" type="docker-deploy" factoryName="dockerfile" server-name="Docker">
<deployment type="dockerfile">
<settings>
<option name="imageTag" value="latest"/>
<option name="containerName" value="pytmbot"/>
<option name="sourceFilePath" value="Dockerfile"/>
<option name="volumeBindings">
<list>
<DockerVolumeBindingImpl>
<option name="containerPath" value="/var/run/docker.sock"/>
<option name="hostPath" value="/var/run/docker.sock"/>
<option name="readOnly" value="true"/>
</DockerVolumeBindingImpl>
</list>
</option>
</settings>
</deployment>
<method v="2"/>
</configuration>
<configuration default="false" name="Dockerfile" type="docker-deploy" factoryName="dockerfile" server-name="Docker">
<deployment type="dockerfile">
<settings>
<option name="imageTag" value="orenlab/pytmbot:latest"/>
<option name="buildCliOptions" value="--target self_build"/>
<option name="command" value="--log-level DEBUG --mode dev"/>
<option name="containerName" value="pytmbot"/>
<option name="commandLineOptions" value=""/>
<option name="showCommandPreview" value="true"/>
<option name="sourceFilePath" value="Dockerfile"/>
<option name="volumeBindings">
<list>
<DockerVolumeBindingImpl>
<option name="containerPath" value="/var/run/docker.sock"/>
<option name="hostPath" value="/var/run/docker.sock"/>
<option name="readOnly" value="true"/>
</DockerVolumeBindingImpl>
</list>
</option>
</settings>
</deployment>
<method v="2"/>
</configuration>
</component>
6 changes: 4 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

# Set base images tag
ARG PYTHON_IMAGE=3.13-alpine3.20
ARG ALPINE_IMAGE=3.20
ARG ALPINE_IMAGE=3.21

########################################################################################################################
######################### BUILD ALPINE BASED IMAGE #####################################################################
Expand Down Expand Up @@ -73,7 +73,9 @@ COPY ./main.py ./main.py
COPY ./entrypoint.sh ./entrypoint.sh

# Set permissions for entrypoint script
RUN chmod 700 ./entrypoint.sh
RUN chmod 700 ./entrypoint.sh && \
rm -rf /root/.cache/* && \
rm -rf /tmp/*

########################################################################################################################
######################### TARGETS SETUP ###############################################################################
Expand Down
12 changes: 7 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,13 @@ and [docker-py](https://github.com/docker/docker-py) libraries to provide robust

### 🐳 Docker Management

- Manage Docker containers (start, stop, restart, etc.)
- View and monitor the status of running and stopped containers
- Access and search container logs
- Retrieve and inspect Docker images
- Inline query handling for managing containers directly from Telegram
- Efficient management of Docker containers (start, stop, restart, etc.)
- Monitor and retrieve real-time status of running and stopped containers
- Access and search detailed container logs
- Retrieve, inspect, and manage Docker images, including tag information and metadata
- Seamless inline query handling for direct container management via Telegram
- **NEW**: Docker image update checking: Manually check for newer image versions by comparing local tags with those
available on Docker Hub, helping ensure that your containers can be updated when needed

### 🖥️ Local Server Monitoring

Expand Down
98 changes: 31 additions & 67 deletions docs/docker.md
Original file line number Diff line number Diff line change
@@ -1,24 +1,27 @@
# pyTMbot Docker Image

Welcome to the **pyTMbot** Docker Hub page! This guide will walk you through setting up and running pyTMbot step-by-step, ensuring a smooth experience from initial configuration to deployment.
Welcome to the **pyTMbot** Docker Hub page! This guide will walk you through setting up and running pyTMbot
step-by-step, ensuring a smooth experience from initial configuration to deployment.

## 🐋 Image Overview

- **Image Name:** `orenlab/pytmbot`
- **Tags:**
- `latest` - The latest stable release image based on Alpine Linux.
- `0.X.X` - Specific stable release versions based on Alpine Linux.
- `alpine-dev` - Latest development version based on Alpine Linux.
- `latest` - The latest stable release image based on Alpine Linux.
- `0.X.X` - Specific stable release versions based on Alpine Linux.
- `alpine-dev` - Latest development version based on Alpine Linux.

## 🚀 Step-by-Step Setup

### 1️⃣ Preparing for Deployment

Before we begin, ensure you have Docker and Docker Compose installed on your system. If not, please refer to the [Docker documentation](https://docs.docker.com/get-docker/) for installation instructions.
Before we begin, ensure you have Docker and Docker Compose installed on your system. If not, please refer to
the [Docker documentation](https://docs.docker.com/get-docker/) for installation instructions.

### 2️⃣ Generating the Authentication Salt

To securely configure the bot, you'll need a unique salt value for Time-Based One-Time Passwords (TOTP). Run the following command to generate it:
To securely configure the bot, you'll need a unique salt value for Time-Based One-Time Passwords (TOTP). Run the
following command to generate it:

```bash
sudo docker run --rm orenlab/pytmbot:latest --salt
Expand All @@ -30,43 +33,19 @@ Save the generated salt for later use in the `pytmbot.yaml` configuration.

Create a `pytmbot.yaml` file to define your bot's settings. Here’s how:

- **Download the Configuration File:**

```bash
sudo -i
cd /root
nano pytmbot.yaml
sudo curl -o /root/pytmbot.yaml https://raw.githubusercontent.com/orenlab/pytmbot/refs/heads/master/pytmbot.yaml.sample
```

#### Example Configuration File
- **Edit the Configuration File:**

```yaml
# General Bot Settings
bot_token:
prod_token: ['YOUR_PROD_BOT_TOKEN'] # Replace with your production bot token.
chat_id:
global_chat_id: ['YOUR_CHAT_ID'] # Replace with your Telegram chat ID.
access_control:
allowed_user_ids: ['123456789']
allowed_admins_ids: ['987654321']
auth_salt: ['YOUR_GENERATED_SALT']

# Docker Settings
docker:
host: ['unix:///var/run/docker.sock']
debug_docker_client: false

# Plugins Configuration
plugins_config:
monitor:
cpu_usage_threshold: [80]
memory_usage_threshold: [80]
check_interval: [10]
retry_attempts: [3]
outline:
api_url: ['YOUR_OUTLINE_API_URL']
cert: ['YOUR_OUTLINE_CERT']
```bash
nano /root/pytmbot.yaml
```

Refer to the **Plugins Configuration** section below for additional plugin examples.
Please follow the instructions provided in the sample configuration.

### 4️⃣ Creating the `docker-compose.yml` File

Expand All @@ -93,7 +72,7 @@ services:
options:
max-size: "10m"
max-file: "3"
command: --plugins monitor,outline
command: --plugins monitor,outline # if needed
```
### 5️⃣ Deploying the Container
Expand All @@ -107,14 +86,18 @@ docker-compose up -d
Alternatively, you can launch the container directly with the Docker CLI:

```bash
sudo docker run -d \
-v /var/run/docker.sock:/var/run/docker.sock:ro \
-v /root/pytmbot.yaml:/opt/app/pytmbot.yaml:ro \
docker run -d \
--name pytmbot \
--restart on-failure \
--env TZ="Asia/Yekaterinburg" \
--restart=always \
--name=pytmbot \
--volume /var/run/docker.sock:/var/run/docker.sock:ro \
--volume /root/pytmbot.yaml:/opt/app/pytmbot.yaml:ro \
--security-opt no-new-privileges \
--read-only \
--cap-drop ALL \
--pid=host \
--security-opt=no-new-privileges \
--log-opt max-size=10m \
--log-opt max-file=3 \
orenlab/pytmbot:latest --plugins monitor,outline
```

Expand All @@ -124,33 +107,14 @@ pyTMbot supports an extensive plugin system to extend its functionality. Below a

### Monitor Plugin

The **Monitor Plugin** tracks system metrics and Docker events. Here’s an example configuration:

```yaml
plugins_config:
monitor:
cpu_usage_threshold: [80]
memory_usage_threshold: [80]
disk_usage_threshold: [85]
check_interval: [5]
max_notifications: [3]
retry_attempts: [3]
retry_interval: [10]
monitor_docker: true
```
The **Monitor Plugin** tracks system metrics and Docker events.

### Outline VPN Plugin

To monitor your [Outline VPN](https://getoutline.org/), configure the plugin as follows:

```yaml
plugins_config:
outline:
api_url: ['YOUR_OUTLINE_API_URL']
cert: ['YOUR_OUTLINE_CERT']
```
To monitor your [Outline VPN](https://getoutline.org/)

For more detailed plugin configurations, visit the [plugins documentation](https://github.com/orenlab/pytmbot/blob/master/docs/plugins.md).
For more detailed plugin configurations, visit
the [plugins documentation](https://github.com/orenlab/pytmbot/blob/master/docs/plugins.md).

## 🛠️ Updating the Image

Expand Down
1 change: 1 addition & 0 deletions docs/influxdb_host_setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ sudo nano /etc/nginx/sites-available/influxdb
```

Add the following configuration:

```bash
server {
listen 80;
Expand Down
Loading

0 comments on commit 2ba3b0c

Please sign in to comment.