Compare commits
5 Commits
83dc6440d8
...
master
Author | SHA1 | Date | |
---|---|---|---|
b8b9faa8f5
|
|||
3564af2a21
|
|||
0383ba2a82
|
|||
ee41b64af0
|
|||
cb87f4e2d7
|
@ -91,13 +91,11 @@ jobs:
|
|||||||
# Extract metadata (tags, labels) from Git reference and GitHub events for Docker
|
# Extract metadata (tags, labels) from Git reference and GitHub events for Docker
|
||||||
- id: meta
|
- id: meta
|
||||||
uses: https://github.com/docker/metadata-action@v5
|
uses: https://github.com/docker/metadata-action@v5
|
||||||
env:
|
|
||||||
DOCKER_METADATA_ANNOTATIONS_LEVELS: manifest,index
|
|
||||||
with:
|
with:
|
||||||
images: |
|
images: |
|
||||||
ghcr.io/thelovinator1/discord-embed
|
ghcr.io/thelovinator1/discord-embed
|
||||||
thelovinator/discord-nice-embed-maker-for-my-yoy
|
thelovinator/discord-nice-embed-maker-for-my-yoy
|
||||||
git.lovinator.space/thelovinator/anewdawn
|
git.lovinator.space/thelovinator/discord-embed
|
||||||
tags: |
|
tags: |
|
||||||
type=raw,value=latest,enable=${{ gitea.ref == format('refs/heads/{0}', 'master') }}
|
type=raw,value=latest,enable=${{ gitea.ref == format('refs/heads/{0}', 'master') }}
|
||||||
type=raw,value=master,enable=${{ gitea.ref == format('refs/heads/{0}', 'master') }}
|
type=raw,value=master,enable=${{ gitea.ref == format('refs/heads/{0}', 'master') }}
|
||||||
|
@ -26,10 +26,10 @@ repos:
|
|||||||
rev: v3.19.1
|
rev: v3.19.1
|
||||||
hooks:
|
hooks:
|
||||||
- id: pyupgrade
|
- id: pyupgrade
|
||||||
args: ["--py311-plus"]
|
args: ["--py39-plus"]
|
||||||
|
|
||||||
- repo: https://github.com/astral-sh/ruff-pre-commit
|
- repo: https://github.com/astral-sh/ruff-pre-commit
|
||||||
rev: v0.9.5
|
rev: v0.11.5
|
||||||
hooks:
|
hooks:
|
||||||
- id: ruff-format
|
- id: ruff-format
|
||||||
- id: ruff
|
- id: ruff
|
||||||
|
2
.vscode/settings.json
vendored
2
.vscode/settings.json
vendored
@ -5,8 +5,10 @@
|
|||||||
"docstrings",
|
"docstrings",
|
||||||
"dotenv",
|
"dotenv",
|
||||||
"fastapi",
|
"fastapi",
|
||||||
|
"ffprobe",
|
||||||
"httpx",
|
"httpx",
|
||||||
"isort",
|
"isort",
|
||||||
|
"jrottenberg",
|
||||||
"pycodestyle",
|
"pycodestyle",
|
||||||
"pydocstyle",
|
"pydocstyle",
|
||||||
"pyproject",
|
"pyproject",
|
||||||
|
26
Dockerfile
26
Dockerfile
@ -1,23 +1,29 @@
|
|||||||
FROM python:3.13-slim
|
# syntax=docker/dockerfile:1
|
||||||
|
# check=error=true;experimental=all
|
||||||
|
|
||||||
|
FROM --platform=$BUILDPLATFORM ghcr.io/jrottenberg/ffmpeg:7.1-scratch AS ffmpeg
|
||||||
|
FROM --platform=$BUILDPLATFORM python:3.13-slim-bookworm AS base
|
||||||
|
COPY --from=ffmpeg /bin/ffmpeg /bin/ffprobe /usr/local/bin/
|
||||||
|
COPY --from=ffmpeg /lib /lib
|
||||||
|
COPY --from=ffmpeg /share /share
|
||||||
COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/
|
COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/
|
||||||
|
|
||||||
RUN apt-get update && apt-get install ffmpeg -y --no-install-recommends && rm -rf /var/lib/apt/lists/*
|
ENV PYTHONUNBUFFERED=1
|
||||||
|
ENV PYTHONDONTWRITEBYTECODE=1
|
||||||
|
ENV UV_COMPILE_BYTECODE=1
|
||||||
|
ENV UV_LINK_MODE=copy
|
||||||
|
ENV UV_NO_CACHE=1
|
||||||
|
|
||||||
RUN useradd --create-home botuser && mkdir /Uploads && chown botuser:botuser /Uploads
|
RUN useradd --create-home botuser && mkdir /Uploads && chown botuser:botuser /Uploads
|
||||||
USER botuser
|
USER botuser
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
ADD --chown=botuser:botuser discord_embed /app/discord_embed
|
||||||
|
|
||||||
RUN --mount=type=cache,target=/root/.cache/uv \
|
RUN --mount=type=bind,source=pyproject.toml,target=pyproject.toml \
|
||||||
--mount=type=bind,source=pyproject.toml,target=pyproject.toml \
|
uv sync --no-install-project --no-dev
|
||||||
uv sync --no-install-project
|
|
||||||
|
|
||||||
COPY --chown=botuser:botuser discord_embed /app/discord_embed
|
|
||||||
|
|
||||||
VOLUME ["/Uploads"]
|
VOLUME ["/Uploads"]
|
||||||
EXPOSE 5000
|
EXPOSE 5000
|
||||||
|
|
||||||
ENV PYTHONUNBUFFERED=1
|
|
||||||
ENV PYTHONDONTWRITEBYTECODE=1
|
|
||||||
|
|
||||||
CMD ["uv", "run", "uvicorn", "discord_embed.main:app", "--host", "0.0.0.0", "--port", "5000", "--use-colors", "--proxy-headers", "--forwarded-allow-ips", "*", "--log-level", "debug"]
|
CMD ["uv", "run", "uvicorn", "discord_embed.main:app", "--host", "0.0.0.0", "--port", "5000", "--use-colors", "--proxy-headers", "--forwarded-allow-ips", "*", "--log-level", "debug"]
|
||||||
|
@ -29,7 +29,7 @@ def generate_html_for_videos(
|
|||||||
Returns:
|
Returns:
|
||||||
Returns HTML for video.
|
Returns HTML for video.
|
||||||
"""
|
"""
|
||||||
time_now: datetime.datetime = datetime.datetime.now(tz=datetime.UTC)
|
time_now: datetime.datetime = datetime.datetime.now(tz=datetime.timezone.utc)
|
||||||
time_now_str: str = time_now.strftime("%Y-%m-%d %H:%M:%S %Z")
|
time_now_str: str = time_now.strftime("%Y-%m-%d %H:%M:%S %Z")
|
||||||
|
|
||||||
video_html: str = f"""
|
video_html: str = f"""
|
||||||
|
14
noxfile.py
Normal file
14
noxfile.py
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
|
import nox
|
||||||
|
|
||||||
|
nox.options.default_venv_backend = "uv"
|
||||||
|
|
||||||
|
|
||||||
|
@nox.session(python=["3.9", "3.10", "3.11", "3.12", "3.13"])
|
||||||
|
def tests(session: nox.Session) -> None:
|
||||||
|
"""Run the test suite."""
|
||||||
|
# pip install .
|
||||||
|
session.install(".")
|
||||||
|
session.install("pytest", "pytest-httpx")
|
||||||
|
session.run("pytest")
|
@ -3,7 +3,7 @@ name = "discord-embed"
|
|||||||
version = "1.0.0"
|
version = "1.0.0"
|
||||||
description = "Make nice embeds for Discord"
|
description = "Make nice embeds for Discord"
|
||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
requires-python = ">=3.13"
|
requires-python = ">=3.9"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"discord-webhook",
|
"discord-webhook",
|
||||||
"fastapi",
|
"fastapi",
|
||||||
@ -16,7 +16,7 @@ dependencies = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
[dependency-groups]
|
[dependency-groups]
|
||||||
dev = ["pytest", "httpx"]
|
dev = ["pytest", "httpx", "nox"]
|
||||||
|
|
||||||
[build-system]
|
[build-system]
|
||||||
build-backend = "poetry.core.masonry.api"
|
build-backend = "poetry.core.masonry.api"
|
||||||
@ -30,19 +30,20 @@ authors = ["Joakim Hellsén <tlovinator@gmail.com>"]
|
|||||||
license = "GPL-3.0-or-later"
|
license = "GPL-3.0-or-later"
|
||||||
|
|
||||||
[tool.poetry.dependencies]
|
[tool.poetry.dependencies]
|
||||||
python = "^3.13"
|
python = "^3.9"
|
||||||
discord-webhook = "*"
|
discord-webhook = "*"
|
||||||
fastapi = "*"
|
fastapi = "*"
|
||||||
ffmpeg-python = "*"
|
ffmpeg-python = "*"
|
||||||
Jinja2 = "*"
|
Jinja2 = "*"
|
||||||
python-dotenv = "*"
|
python-dotenv = "*"
|
||||||
python-multipart = "*"
|
python-multipart = "*"
|
||||||
sentry-sdk = {extras = ["fastapi"], version = "*"}
|
sentry-sdk = { extras = ["fastapi"], version = "*" }
|
||||||
uvicorn = {extras = ["standard"], version = "*"}
|
uvicorn = { extras = ["standard"], version = "*" }
|
||||||
|
|
||||||
[tool.poetry.group.dev.dependencies]
|
[tool.poetry.group.dev.dependencies]
|
||||||
httpx = "*"
|
httpx = "*"
|
||||||
pytest = "*"
|
pytest = "*"
|
||||||
|
nox = "*"
|
||||||
|
|
||||||
[tool.ruff]
|
[tool.ruff]
|
||||||
preview = true
|
preview = true
|
||||||
|
Reference in New Issue
Block a user