Install czkawka via download in dockerfile + fix uvicorn dependency
All checks were successful
gitea/file-organizer/pipeline/head This commit looks good
All checks were successful
gitea/file-organizer/pipeline/head This commit looks good
This commit is contained in:
parent
8ab7746a3f
commit
3381a8e310
6
.gitignore
vendored
6
.gitignore
vendored
@ -159,8 +159,4 @@ cython_debug/
|
|||||||
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
|
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
|
||||||
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
||||||
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
||||||
#.idea/
|
#.idea/
|
||||||
|
|
||||||
|
|
||||||
vendor/czkawka/*
|
|
||||||
vendor/ffmpeg/*
|
|
||||||
16
Dockerfile
16
Dockerfile
@ -14,16 +14,18 @@ RUN pip install --no-cache-dir -r requirements.txt
|
|||||||
RUN pip install gunicorn
|
RUN pip install gunicorn
|
||||||
|
|
||||||
# Copy the FastAPI project files into the container
|
# Copy the FastAPI project files into the container
|
||||||
COPY . .
|
COPY src/ .
|
||||||
|
COPY entrypoint.sh .
|
||||||
|
|
||||||
# Copy the czkawka binary into the container
|
# Copy the patterns.txt file into the container
|
||||||
COPY vendor/czkawka /bin/
|
COPY config/patterns.txt /config/patterns.txt
|
||||||
|
|
||||||
# Install ffmpeg with ffprobe
|
# Install binary dependencies
|
||||||
RUN apt-get update && apt-get install -y ffmpeg
|
RUN apt-get update && apt-get install -y wget ffmpeg
|
||||||
|
RUN wget -O /usr/local/bin/czkawka https://github.com/qarmin/czkawka/releases/download/8.0.0/linux_czkawka_cli
|
||||||
|
RUN chmod +x /usr/local/bin/czkawka
|
||||||
|
|
||||||
# Expose the port the app runs on
|
# Expose the port the app runs on
|
||||||
EXPOSE 8000
|
EXPOSE 8000
|
||||||
|
|
||||||
# Command to run the FastAPI app using gunicorn with uvicorn workers
|
ENTRYPOINT ["./entrypoint.sh"]
|
||||||
CMD ["gunicorn", "-w", "4", "-k", "uvicorn.workers.UvicornWorker", "main:app", "--bind", "0.0.0.0:8000"]
|
|
||||||
14
entrypoint.sh
Normal file
14
entrypoint.sh
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Create user and group using UID and GID from docker run command
|
||||||
|
useradd -u $UID -o -m user
|
||||||
|
groupadd -g $GID -o group
|
||||||
|
|
||||||
|
# assign user to group
|
||||||
|
usermod -aG group user
|
||||||
|
|
||||||
|
# switch to user
|
||||||
|
su user
|
||||||
|
|
||||||
|
# launch the application
|
||||||
|
gunicorn -w 4 -k uvicorn.workers.UvicornWorker main:app --bind 0.0.0.0:8000
|
||||||
@ -1,3 +1,5 @@
|
|||||||
requests
|
requests
|
||||||
|
python-dotenv
|
||||||
fastapi
|
fastapi
|
||||||
|
uvicorn
|
||||||
pytest ; extra == 'dev'
|
pytest ; extra == 'dev'
|
||||||
@ -10,15 +10,7 @@ class CZKAWKA_DELETION_METHOD(Enum):
|
|||||||
NONE="NONE"
|
NONE="NONE"
|
||||||
|
|
||||||
def deduplicate_files(target_dir, exclude_files):
|
def deduplicate_files(target_dir, exclude_files):
|
||||||
executables = {
|
czkawka_executable = "czkawka"
|
||||||
"linux": "linux_czkawka_cli",
|
|
||||||
"win32": "windows_czkawka_cli.exe",
|
|
||||||
"darwin": "mac_czkawka_cli",
|
|
||||||
"docker": "linux_czkawka_cli"
|
|
||||||
}
|
|
||||||
|
|
||||||
platform = "docker" if os.path.exists("/.dockerenv") else os.sys.platform
|
|
||||||
czkawka_executable = executables.get(platform, "czkawka_cli")
|
|
||||||
czkawka_deletion_method = CZKAWKA_DELETION_METHOD.ALL_EXCEPT_SMALLEST
|
czkawka_deletion_method = CZKAWKA_DELETION_METHOD.ALL_EXCEPT_SMALLEST
|
||||||
czkawka_tolerance = os.environ.get("CK_DUPLICATE_TOLERANCE", "2")
|
czkawka_tolerance = os.environ.get("CK_DUPLICATE_TOLERANCE", "2")
|
||||||
_remove_duplicates(czkawka_executable, target_dir, exclude_files, czkawka_deletion_method, czkawka_tolerance)
|
_remove_duplicates(czkawka_executable, target_dir, exclude_files, czkawka_deletion_method, czkawka_tolerance)
|
||||||
|
|||||||
@ -7,9 +7,8 @@ from qbittorrent_api import get_qbittorrent_files_downloading
|
|||||||
from filemoving import group_files_by_prefix
|
from filemoving import group_files_by_prefix
|
||||||
from deduplication import deduplicate_files
|
from deduplication import deduplicate_files
|
||||||
import uuid
|
import uuid
|
||||||
import time
|
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__).setLevel(logging.INFO)
|
||||||
|
|
||||||
load_dotenv()
|
load_dotenv()
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user