Skip to content

Commit b713122

Browse files
authored
refactor: change to mysql, use cogs and structured services
2 parents 2661057 + a531bd5 commit b713122

43 files changed

Lines changed: 1304 additions & 1175 deletions

Some content is hidden

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

.deepsource.toml

Lines changed: 0 additions & 8 deletions
This file was deleted.
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
name: Build and Push Docker Image
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
tags:
8+
- 'v*'
9+
pull_request:
10+
branches:
11+
- master
12+
13+
env:
14+
REGISTRY: ghcr.io
15+
IMAGE_NAME: ${{ github.repository }}
16+
17+
jobs:
18+
build-and-push:
19+
runs-on: ubuntu-latest
20+
permissions:
21+
contents: read
22+
packages: write
23+
id-token: write
24+
attestations: write
25+
26+
steps:
27+
- name: Checkout repository
28+
uses: actions/checkout@v4
29+
30+
- name: Set up Docker Buildx
31+
uses: docker/setup-buildx-action@v3
32+
33+
- name: Log in to Container Registry
34+
uses: docker/login-action@v3
35+
with:
36+
registry: ${{ env.REGISTRY }}
37+
username: ${{ github.actor }}
38+
password: ${{ secrets.GITHUB_TOKEN }}
39+
40+
- name: Extract metadata
41+
id: meta
42+
uses: docker/metadata-action@v5
43+
with:
44+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
45+
tags: |
46+
type=ref,event=branch
47+
type=ref,event=pr
48+
type=semver,pattern={{version}}
49+
type=semver,pattern={{major}}.{{minor}}
50+
type=raw,value=latest,enable={{is_default_branch}}
51+
52+
- name: Build and push Docker image
53+
id: build
54+
uses: docker/build-push-action@v5
55+
with:
56+
context: .
57+
platforms: linux/amd64
58+
push: true
59+
tags: ${{ steps.meta.outputs.tags }}
60+
labels: ${{ steps.meta.outputs.labels }}
61+
cache-from: type=gha
62+
cache-to: type=gha,mode=max
63+
64+
- name: Generate artifact attestation
65+
uses: actions/attest-build-provenance@v1
66+
with:
67+
subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME}}
68+
subject-digest: ${{ steps.build.outputs.digest }}
69+
push-to-registry: true

.gitignore

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# Byte-compiled / optimized / DLL files
2+
__pycache__/
3+
*.py[cod]
4+
5+
# Virtual environment
6+
.venv/
7+
venv/
8+
ENV/
9+
10+
# Environment variables
11+
.env
12+
*.env
13+
14+
# Alembic migration cache
15+
alembic/versions/__pycache__/
16+
alembic.ini
17+
18+
# Database files
19+
*.sqlite3
20+
*.db
21+
22+
# Docker
23+
*.pid
24+
25+
# VSCode
26+
.vscode/
27+
28+
# JetBrains
29+
.idea/
30+
31+
# OS generated files
32+
.DS_Store
33+
Thumbs.db
34+
35+
# Logs
36+
*.log
37+
38+
# Python egg
39+
*.egg-info/
40+
41+
dist/
42+
build/
43+
44+
# Coverage
45+
.coverage
46+
htmlcov/
47+
48+
# Lint/format
49+
.mypy_cache/
50+
.pytest_cache/
51+
52+
# Misc
53+
*.bak
54+
*.swp
55+
56+
# Ignore Alembic generated files except env.py and README
57+
alembic/versions/*
58+
!alembic/README
59+
!alembic/env.py
60+

Dockerfile

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,19 @@
1-
FROM python:3
1+
FROM python:3.12-slim
22

3-
ENV PYTHONNUNBUFFERED 1
3+
WORKDIR /app
44

5-
ENV DISCORD_TOKEN YOUR_DISCORD_TOKEN
6-
ENV DISCORD_GUILD YOUR_DISCORD_GUILD
7-
ENV REDDIT_USER YOUR_REDDIT_USER
8-
ENV REDDIT_PASSWORD YOUR_REDDIT_PASSWORD
9-
ENV CLIENT_ID YOUR_CLIENT_ID
10-
ENV CLIENT_SECRET YOUR_CLIENT_SECRET
11-
ENV ADMIN_ROLE_ID YOUR_ADMIN_ROLE_ID
12-
ENV CHANNEL_TO_POST_ID YOUR_CHANNEL_TO_POST_ID
13-
ENV CHANNEL_LOGS_ID YOUR_CHANNEL_LOGS_ID
5+
RUN apt-get update && apt-get install -y \
6+
build-essential \
7+
libpq-dev \
8+
gcc \
9+
&& rm -rf /var/lib/apt/lists/*
1410

15-
RUN mkdir /bot-code
16-
WORKDIR /bot-code
17-
ADD . /bot-code
11+
COPY requirements.txt ./
12+
RUN pip install --no-cache-dir -r requirements.txt
1813

19-
RUN apt-get update
20-
RUN pip install -r requirements.txt
14+
COPY . .
15+
16+
ENV PYTHONUNBUFFERED=1
17+
18+
CMD ["python", "main.py"]
2119

22-
CMD ["main.py"]
23-
ENTRYPOINT ["python3"]

Dockerfile_EXAMPLE

Lines changed: 0 additions & 31 deletions
This file was deleted.

LICENSE

Lines changed: 0 additions & 21 deletions
This file was deleted.

Makefile

Lines changed: 0 additions & 14 deletions
This file was deleted.

Pipfile

Lines changed: 0 additions & 18 deletions
This file was deleted.

0 commit comments

Comments
 (0)