upload-sorter init
This commit is contained in:
parent
4c5f615ba1
commit
5ed9bbf1fd
17
publish.sh
Executable file
17
publish.sh
Executable file
@ -0,0 +1,17 @@
|
||||
#!/bin/sh
|
||||
|
||||
REGISTRY=code.balsillie.net
|
||||
REPOSITORY=containers
|
||||
IMAGE=$1
|
||||
|
||||
TAG1=$(date +%Y-%m-%d_%H-%M-%S)
|
||||
TAG2=latest
|
||||
|
||||
docker build \
|
||||
-t $REGISTRY/$REPOSITORY/$IMAGE:$TAG1 \
|
||||
-t $REGISTRY/$REPOSITORY/$IMAGE:$TAG2 \
|
||||
-f ./$IMAGE/DOCKERFILE \
|
||||
./$IMAGE
|
||||
|
||||
docker push $REGISTRY/$REPOSITORY/$IMAGE:$TAG1
|
||||
docker push $REGISTRY/$REPOSITORY/$IMAGE:$TAG2
|
20
upload-sorter/DOCKERFILE
Normal file
20
upload-sorter/DOCKERFILE
Normal file
@ -0,0 +1,20 @@
|
||||
FROM python:3.12-slim
|
||||
|
||||
# Set the working directory
|
||||
WORKDIR /app
|
||||
|
||||
# Copy the sort.py file to the working directory
|
||||
COPY sort.py .
|
||||
COPY requirements.txt .
|
||||
|
||||
# Ensure pip
|
||||
RUN python -m ensurepip
|
||||
|
||||
# Upgrade pip
|
||||
RUN pip install --upgrade pip
|
||||
|
||||
# Install requirements
|
||||
RUN pip install -r requirements.txt
|
||||
|
||||
# Set the entry point to sort.py
|
||||
ENTRYPOINT ["python", "/app/sort.py"]
|
1
upload-sorter/requirements.txt
Normal file
1
upload-sorter/requirements.txt
Normal file
@ -0,0 +1 @@
|
||||
pillow
|
33
upload-sorter/sort.py
Normal file
33
upload-sorter/sort.py
Normal file
@ -0,0 +1,33 @@
|
||||
#!/usr/bin/python
|
||||
|
||||
import time
|
||||
import os
|
||||
import signal
|
||||
import sys
|
||||
|
||||
# Set the directories
|
||||
watch_directories: list[str] = os.getenv('WATCH_DIR', '/sync').split(':')
|
||||
recordings_directory: str = os.getenv('RECORDINGS_DIRECTORY', '/recordings')
|
||||
photos_directory: str = os.getenv('PHOTOS_DIRECTORY', '/photos')
|
||||
sleep_duration: int = 30
|
||||
|
||||
def main():
|
||||
while True:
|
||||
for directory in watch_directories:
|
||||
sort_directory(directory)
|
||||
print(f"Finished sorting directory {directory}")
|
||||
print(f"Sleeping for {sleep_duration} seconds")
|
||||
time.sleep(sleep_duration)
|
||||
|
||||
def sort_directory(directory):
|
||||
|
||||
|
||||
signal.signal(signal.SIGINT, signal_handler)
|
||||
signal.signal(signal.SIGTERM, signal_handler)
|
||||
|
||||
def signal_handler(sig, frame):
|
||||
print('Shutdown signal received. Exiting gracefully.')
|
||||
sys.exit(0)
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
Loading…
x
Reference in New Issue
Block a user