Skip to content

Commit c188f9b

Browse files
authored
Merge pull request #1 from vlymar-dev/dev
Initialize aiogram-bot-template with modular structure, PostgreSQL, Redis, Docker Compose, and admin panel
2 parents 2776ddd + bdcf7b3 commit c188f9b

76 files changed

Lines changed: 4022 additions & 4 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.dockerignore

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# Byte-compiled / cache
2+
__pycache__/
3+
*.py[cod]
4+
5+
# Virtual environments
6+
.venv/
7+
env/
8+
venv/
9+
10+
# Editors & IDEs
11+
.vscode/
12+
.idea/
13+
*.swp
14+
15+
# Git
16+
.git/
17+
.gitignore
18+
.gitattributes
19+
.gitkeep
20+
21+
# Python tooling
22+
*.egg-info/
23+
.eggs/
24+
pip-wheel-metadata/
25+
.pytest_cache/
26+
.ruff_cache/
27+
.python-version
28+
tests/
29+
30+
# Logs and temp files
31+
logs/
32+
temp/
33+
*.log
34+
*.bak
35+
*.tmp
36+
37+
# Environment files
38+
.env*
39+
40+
# Docker Compose files (not needed in container)
41+
docker_compose/
42+
43+
# Static/media files (unless needed)
44+
static/
45+
assets/
46+
var/
47+
*.png
48+
*.jpeg
49+
*.jpg
50+
*.webp
51+
52+
# Exclude other files
53+
docs/
54+
.github/
55+
.DS_Store
56+
*.md
57+
LICENSE
58+
.pre-commit-config.yaml
59+
requirements-dev.txt

.editorconfig

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
root = true
2+
3+
[**]
4+
charset = utf-8
5+
end_of_line = lf
6+
indent_size = 4
7+
indent_style = space
8+
insert_final_newline = true
9+
trim_trailing_whitespace = true
10+
max_line_length = 99
11+
12+
[**.{yml,yaml,json,conf}]
13+
indent_size = 2
14+
15+
[**.{md,txt,rst}]
16+
trim_trailing_whitespace = false
17+
18+
[**.rst]
19+
indent_size = 2
20+
21+
[Makefile]
22+
indent_style = tab

.env.example

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# Fill in the actual secrets before using the app!
2+
# Note: This is a template file. Create a copy as ".env" and fill in the actual values.
3+
# Never commit your actual ".env" file to version control!
4+
5+
# ========================
6+
# Bot Configuration
7+
# ========================
8+
BOT_TOKEN=your_bot_token_here
9+
BOT_ADMIN_ACCESS_IDs=[12345]
10+
BOT_SUPPORT_USERNAME=support_user
11+
BOT_USERNAME=bot_name
12+
13+
14+
# ========================
15+
# Database Configuration
16+
# ========================
17+
POSTGRES_NAME=postgres
18+
POSTGRES_USER=postgres
19+
POSTGRES_PASSWORD=your_secure_password
20+
POSTGRES_PORT=5432
21+
POSTGRES_HOST=0.0.0.0
22+
DATABASE_DRIVER=postgresql+asyncpg
23+
24+
25+
# ========================
26+
# Redis Configuration
27+
# ========================
28+
REDIS_HOST=localhost
29+
REDIS_PORT=6379
30+
REDIS_DB=0
31+
REDIS_PASSWORD=
32+
REDIS_TTL=3600
33+
34+
35+
# ========================
36+
# Logging Configuration
37+
# ========================
38+
LOG_LEVEL=DEBUG
39+
LOG_FILE_ENABLED=true
40+
LOG_BACKUP_COUNT=15
41+
42+
43+
# ========================
44+
# Environment Mode
45+
# ========================
46+
IMAGE_TAG=latest
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
# Publish Docker Image
2+
# Builds and pushes a multi-platform Docker image to ghcr.io on push to main, tags (v*.*.*), or PR to main.
3+
# Includes artifact attestation for supply chain security.
4+
name: Publish Docker Image
5+
6+
on:
7+
push:
8+
tags: [ 'v*.*.*' ]
9+
10+
env:
11+
REGISTRY: ghcr.io
12+
IMAGE_NAME: ${{ github.repository }}
13+
14+
jobs:
15+
build-and-publish-image:
16+
runs-on: ubuntu-latest
17+
18+
permissions:
19+
contents: read
20+
packages: write
21+
attestations: write
22+
id-token: write
23+
24+
steps:
25+
- name: Checkout repository
26+
uses: actions/checkout@v4
27+
28+
- name: Set up Docker Buildx
29+
uses: docker/setup-buildx-action@b5ca514318bd6ebac0fb2aedd5d36ec1b5c232a2 # v3.10.0
30+
31+
- name: Log into registry ${{ env.REGISTRY }}
32+
uses: docker/login-action@74a5d142397b4f367a81961eba4e8cd7edddf772 # v3.4.0
33+
with:
34+
registry: ${{ env.REGISTRY }}
35+
username: ${{ github.actor }}
36+
password: ${{ secrets.GITHUB_TOKEN }}
37+
38+
- name: Extract metadata (tags, labels) for Docker
39+
id: meta
40+
uses: docker/metadata-action@902fa8ec7d6ecbf8d84d538b9b233a880e428804 # v5.7.0
41+
with:
42+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
43+
tags: |
44+
type=semver,pattern={{version}}
45+
type=sha
46+
type=raw,value=latest
47+
48+
- name: Build and push Docker image
49+
id: build-and-push
50+
uses: docker/build-push-action@14487ce63c7a62a4a324b0bfb37086795e31c6c1 # v6.16.0
51+
with:
52+
context: .
53+
push: true
54+
tags: ${{ steps.meta.outputs.tags }}
55+
labels: ${{ steps.meta.outputs.labels }}
56+
platforms: linux/amd64,linux/arm64
57+
cache-from: type=gha
58+
cache-to: type=gha,mode=max
59+
60+
- name: Generate artifact attestation
61+
uses: actions/attest-build-provenance@v2
62+
with:
63+
subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME}}
64+
subject-digest: ${{ steps.build-and-push.outputs.digest }}
65+
push-to-registry: true

.github/workflows/lint.yaml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Runs linting for Python code on every push to any branch.
2+
name: Lint
3+
4+
on: [push]
5+
6+
jobs:
7+
lint:
8+
runs-on: ubuntu-latest
9+
timeout-minutes: 20
10+
strategy:
11+
matrix:
12+
python-version: [ "3.12.5" ]
13+
steps:
14+
- name: Checkout code
15+
uses: actions/checkout@v4
16+
- name: Set up Python ${{ matrix.python-version }}
17+
uses: actions/setup-python@v5
18+
with:
19+
python-version: ${{ matrix.python-version }}
20+
- name: Run pre-commit
21+
uses: pre-commit/action@v3.0.1

.gitignore

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ cover/
5656
*.pot
5757

5858
# Django stuff:
59-
*.log
6059
local_settings.py
6160
db.sqlite3
6261
db.sqlite3-journal
@@ -165,10 +164,17 @@ cython_debug/
165164
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
166165
# and can be added to the global gitignore or merged into this file. For a more nuclear
167166
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
168-
#.idea/
167+
.idea/
169168

170169
# Ruff stuff:
171170
.ruff_cache/
172171

173172
# PyPI configuration file
174173
.pypirc
174+
175+
# Exclude log files
176+
logs/
177+
*.log
178+
179+
# MacOS
180+
.DS_Store

.pre-commit-config.yaml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
repos:
2+
- repo: https://github.com/pre-commit/pre-commit-hooks
3+
rev: v5.0.0
4+
hooks:
5+
- id: trailing-whitespace
6+
- id: end-of-file-fixer
7+
- id: check-yaml
8+
- id: check-toml
9+
- id: check-case-conflict
10+
- id: detect-private-key
11+
- id: check-added-large-files
12+
args: [--maxkb=500]
13+
14+
- repo: https://github.com/astral-sh/ruff-pre-commit
15+
rev: v0.11.9
16+
hooks:
17+
- id: ruff
18+
args:
19+
- --fix
20+
- id: ruff-format
21+
types: [python]

Dockerfile

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# -----------------------------
2+
# Stage 1: Build dependencies
3+
# -----------------------------
4+
FROM python:3.12.5-slim AS builder
5+
6+
WORKDIR /app
7+
ENV PYTHONUNBUFFERED=1 \
8+
PYTHONDONTWRITEBYTECODE=1 \
9+
POETRY_VERSION=2.1.3
10+
11+
# Install system dependencies
12+
RUN apt-get update && apt-get install -y --no-install-recommends \
13+
gcc \
14+
libpq-dev \
15+
curl \
16+
&& rm -rf /var/lib/apt/lists/*
17+
18+
# Install Poetry via official installer
19+
RUN curl -sSL https://install.python-poetry.org | POETRY_HOME=/opt/poetry python3 - --version ${POETRY_VERSION}
20+
21+
ENV PATH="/opt/poetry/bin:${PATH}"
22+
23+
# Copy only dependency files
24+
COPY pyproject.toml poetry.lock /app/
25+
26+
# Install production dependencies
27+
RUN poetry config virtualenvs.create false \
28+
&& poetry install --only main --no-interaction --no-ansi --no-root
29+
30+
# -----------------------------
31+
# Stage 2: Final image
32+
# -----------------------------
33+
FROM python:3.12.5-slim
34+
WORKDIR /app
35+
36+
ENV PYTHONUNBUFFERED=1 \
37+
PYTHONDONTWRITEBYTECODE=1
38+
39+
# Install runtime dependencies
40+
RUN apt-get update && apt-get install -y --no-install-recommends \
41+
libpq5 \
42+
postgresql-client \
43+
redis-tools \
44+
&& apt-get clean \
45+
&& rm -rf /var/lib/apt/lists/*
46+
47+
# Copy installed dependencies from builder
48+
COPY --from=builder /usr/local/lib/python3.12/site-packages /usr/local/lib/python3.12/site-packages
49+
COPY --from=builder /usr/local/bin /usr/local/bin
50+
51+
# Copy application code
52+
COPY . /app
53+
54+
# Make entrypoint executable
55+
RUN chmod +x /app/entrypoint.sh
56+
57+
# Entrypoint
58+
ENTRYPOINT ["./entrypoint.sh"]

0 commit comments

Comments
 (0)