Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
- name: Install uv
uses: astral-sh/setup-uv@v4
with:
python-version: "3.12"
python-version: "3.14"
- name: Install dependencies
run: uv sync --all-extras --frozen --no-install-project
- name: Run linters
Expand Down
11 changes: 4 additions & 7 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
FROM python:3.12-slim-bookworm

RUN apt-get update && apt-get install -y git && rm -rf /var/lib/apt/lists/*

COPY --from=ghcr.io/astral-sh/uv:latest /uv /usr/local/bin/uv
# python-alpine with uv
FROM ghcr.io/astral-sh/uv:python3.14-alpine3.23
Comment on lines +1 to +2

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Add a non-root user for improved security.

The container runs as root by default, which is a security risk. Static analysis (Trivy DS-0002) flagged this. Add a non-root user to reduce the attack surface.

Proposed fix to add non-root user
 # python-alpine with uv
 FROM ghcr.io/astral-sh/uv:python3.14-alpine3.23

 WORKDIR /app

 COPY app/ /app/
 COPY pyproject.toml /app/
+COPY uv.lock /app/

-RUN uv sync --no-dev --no-install-project
+RUN uv sync --frozen --no-dev --no-install-project

+RUN adduser -D appuser && chown -R appuser:appuser /app
+USER appuser

 EXPOSE 8000
 ENTRYPOINT ["/app/start.sh"]
🧰 Tools
🪛 Trivy (0.69.1)

[error] 1-1: Image user should not be 'root'

Specify at least 1 USER command in Dockerfile with non-root user as argument

Rule: DS-0002

Learn more

(IaC/Dockerfile)

🤖 Prompt for AI Agents
In `@Dockerfile` around lines 1 - 2, Add a non-root user in the Dockerfile to
avoid running the container as root: create a new group and user (e.g., group
add/appgroup and user add/appuser with a fixed UID/GID like 1000), create and
chown a home or app directory (WORKDIR) to that user, and switch to that user
with USER before the final image runtime; reference the existing base image line
("FROM ghcr.io/astral-sh/uv:python3.14-alpine3.23") and ensure any files or
directories created earlier in the Dockerfile are chowned to the new user so the
runtime does not require root privileges.


WORKDIR /app

COPY app/ /app/
COPY pyproject.toml uv.lock /app/
COPY pyproject.toml /app/

RUN uv sync --frozen --no-dev --no-install-project
RUN uv sync --no-dev --no-install-project
Comment on lines +7 to +9

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Missing uv.lock and --frozen flag risks non-reproducible builds.

Without copying uv.lock and using --frozen, each build may resolve different dependency versions, leading to inconsistent deployments. Consider restoring the lockfile copy and the --frozen flag for reproducible builds.

Proposed fix
 COPY pyproject.toml /app/
+COPY uv.lock /app/

-RUN uv sync --no-dev --no-install-project
+RUN uv sync --frozen --no-dev --no-install-project
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
COPY pyproject.toml /app/
RUN uv sync --frozen --no-dev --no-install-project
RUN uv sync --no-dev --no-install-project
COPY pyproject.toml /app/
COPY uv.lock /app/
RUN uv sync --frozen --no-dev --no-install-project
🤖 Prompt for AI Agents
In `@Dockerfile` around lines 7 - 9, The Dockerfile currently only copies
pyproject.toml and runs "uv sync --no-dev --no-install-project", which allows
dependency resolution to vary between builds; update the Dockerfile to also COPY
the lockfile (uv.lock) into /app before running the sync and pass the --frozen
flag to the "uv sync" command so it fails on any mismatch and enforces
reproducible installs (refer to the COPY pyproject.toml line and the RUN uv sync
--no-dev --no-install-project command when making the change).


EXPOSE 8000
ENTRYPOINT ["/app/start.sh"]
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,6 @@ lint:
uv run isort --check .
uv run flake8 .
uv run mypy --namespace-packages --show-error-codes ./app

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

mypy removed from dev dependencies but still referenced in Makefile.

The lint target still runs mypy, but according to pyproject.toml changes, mypy has been removed from the dev dependencies. This will cause the lint command to fail.

Either remove the mypy step from the Makefile or restore mypy in dev dependencies.

Proposed fix to remove mypy from lint target
 lint:
 	uv run black --check .
 	uv run isort --check .
 	uv run flake8 .
-	uv run mypy --namespace-packages --show-error-codes ./app
🤖 Prompt for AI Agents
In `@Makefile` at line 9, The Makefile's lint target still invokes mypy ("uv run
mypy --namespace-packages --show-error-codes ./app") but mypy was removed from
dev dependencies; update the Makefile to stop referencing mypy or re-add mypy to
dev dependencies—specifically remove the "uv run mypy ..." line (or the mypy
step within the lint target) so the lint target no longer calls mypy, or
alternatively restore mypy to pyproject.toml dev-dependencies if you intend to
keep static type checks.


docker-up:
docker compose up
55 changes: 30 additions & 25 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,23 +1,28 @@
# Pyuploadcare Example app

This example project demonstrates the pyuploadcare capabilities.
The project is based on Python 3.12 and Django 4.2.10.

* [Installation](#installation)
* [Using docker](#using-docker)
* [Without docker](#without-docker)
* [Usage](#usage)
* [Configuration](#configuration)
* [Project section](#project-section)
* [Files section](#files-section)
* [File Groups section](#file-groups-section)
* [Files uploading](#files-uploading)
* [Conversion](#conversion)
* [Documents conversion](#documents-conversion)
* [Video conversion](#video-conversion)
* [Webhooks](#webhooks)
* [Posts section](#posts-section)
* [Useful links](#useful-links)
The project is based on Python 3.14 and Django 4.2.10.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Django version mismatch with pyproject.toml.

README states Django 4.2.10, but pyproject.toml specifies >=4.2.28,<5. Consider updating to reflect the actual minimum version or use a more general statement like "Django 4.2.x".

🤖 Prompt for AI Agents
In `@README.md` at line 4, The README statement "The project is based on Python
3.14 and Django 4.2.10." conflicts with the dependency specifier '>=4.2.28,<5'
in pyproject.toml; update the README to either match the pyproject.toml minimum
(e.g., "Django >=4.2.28, <5") or use a general phrasing like "Django 4.2.x" so
the documentation and the pyproject.toml spec (the '>=4.2.28,<5' string) are
consistent.


- [Pyuploadcare Example app](#pyuploadcare-example-app)
- [Installation](#installation)
- [Using Docker](#using-docker)
- [Without docker](#without-docker)
- [Usage](#usage)
- [Configuration](#configuration)
- [Project section](#project-section)
- [Files section](#files-section)
- [File Groups section](#file-groups-section)
- [Files uploading](#files-uploading)
- [Conversion](#conversion)
- [Documents conversion](#documents-conversion)
- [Video conversion](#video-conversion)
- [Addons](#addons)
- [Object recognition via AWS](#object-recognition-via-aws)
- [ClamAV Antivirus scan](#clamav-antivirus-scan)
- [Background removing](#background-removing)
- [Webhooks](#webhooks)
- [Posts section](#posts-section)
- [Useful links](#useful-links)

## Installation

Expand Down Expand Up @@ -184,7 +189,7 @@ Conversion result page also includes information about how conversion is going.

User can execute operations that wrapped as addons.
There are three implemented addons:
- background removing
- background removing
- virus scanning
- object recognition

Expand All @@ -197,7 +202,7 @@ You only need to choose a file to start a recognition

![Setup recogntion](./img/setup_addon_aws_recognition.png)

After all corresponding part of file's `adddata` is rendered
After all corresponding part of file's `adddata` is rendered
and you can get into full file information if needed
Comment on lines +205 to 206

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Typo: "adddata" should be "appdata".

The text mentions adddata but the correct term used elsewhere in the README (line 127) is appdata.

Proposed fix
-After all corresponding part of file's `adddata` is rendered
+After all corresponding part of file's `appdata` is rendered
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
After all corresponding part of file's `adddata` is rendered
and you can get into full file information if needed
After all corresponding part of file's `appdata` is rendered
and you can get into full file information if needed
🤖 Prompt for AI Agents
In `@README.md` around lines 205 - 206, The README contains a typo: the phrase
"adddata" should be replaced with the correct term "appdata" to match usage
elsewhere (see existing reference "appdata"); update the sentence "After all
corresponding part of file's `adddata` is rendered" to use `appdata` instead so
documentation is consistent across the README.


![Recogntion results](./img/addon_aws_execution_result.png)
Expand Down Expand Up @@ -225,7 +230,7 @@ so you may see `IN_PROGRESS` status page with refresh button

![Recogntion results](./img/addon_remove_bg_in_progress.png)

Image with removed background will be put into new file,
Image with removed background will be put into new file,
so the result page has both links to the original file and created one

![Background results](./img/addon_remove_bg_result_done.png)
Expand Down Expand Up @@ -273,10 +278,10 @@ To create a new post, click on the `Add` button in posts index page. The post fo
![Create a post](./img/post_create.png)

## Useful links
* [Uploadcare documentation](https://uploadcare.com/docs/?utm_source=github&utm_medium=referral&utm_campaign=pyuploadcare)
* [Upload API reference](https://uploadcare.com/api-refs/upload-api/?utm_source=github&utm_medium=referral&utm_campaign=pyuploadcare)
* [REST API reference](https://uploadcare.com/api-refs/rest-api/?utm_source=github&utm_medium=referral&utm_campaign=pyuploadcare)
* [Contributing guide](https://github.com/uploadcare/.github/blob/master/CONTRIBUTING.md)
* [Security policy](https://github.com/uploadcare/pyuploadcare/security/policy)
* [Uploadcare documentation](https://uploadcare.com/docs/?utm_source=github&utm_medium=referral&utm_campaign=pyuploadcare)
* [Upload API reference](https://uploadcare.com/api-refs/upload-api/?utm_source=github&utm_medium=referral&utm_campaign=pyuploadcare)
* [REST API reference](https://uploadcare.com/api-refs/rest-api/?utm_source=github&utm_medium=referral&utm_campaign=pyuploadcare)
* [Contributing guide](https://github.com/uploadcare/.github/blob/master/CONTRIBUTING.md)
* [Security policy](https://github.com/uploadcare/pyuploadcare/security/policy)
* [Support](https://github.com/uploadcare/.github/blob/master/SUPPORT.md)
* [A Python library for Uploadcare service](https://github.com/uploadcare/pyuploadcare)
6 changes: 0 additions & 6 deletions mypy.ini

This file was deleted.

15 changes: 7 additions & 8 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,27 +1,26 @@
[project]
name = "pyuploadcare-example"
version = "5.0.1"
version = "5.1.0"
description = "Example project for Python library for Uploadcare.com"
authors = [{ name = "Uploadcare Inc", email = "hello@uploadcare.com" }]
requires-python = ">=3.12.12,<4.0"
requires-python = ">=3.14.3,<4.0"
dependencies = [
"Django>=4.2.28,<5",
"django-crispy-forms>=2.1",
"crispy-bootstrap4>=2023.1",
"pyuploadcare @ git+https://github.com/uploadcare/pyuploadcare@v5.0.1",
"pyuploadcare>=6.2.1,<7.0.0",
]

[dependency-groups]
dev = [
"flake8>=7.0.0",
"mypy>=1.8.0",
"black>=24.3.0",
"isort>=5.13.2",
"flake8>=7.3.0",
"black>=26.1.0",
"isort>=7.0.0",
]

[tool.black]
line-length = 100
target-version = ['py312']
target-version = ['py314']
exclude = '''
(
\.eggs
Expand Down
Loading