91 lines
2.7 KiB
YAML
91 lines
2.7 KiB
YAML
---
|
|
|
|
# Create docker Folder
|
|
- name: carputer - photo_refresh - create photo_refresh folder
|
|
file:
|
|
path: "{{ photo_refresh_folder }}"
|
|
state: directory
|
|
mode: '0755'
|
|
owner: root
|
|
group: root
|
|
|
|
|
|
- name: carputer - photo_refresh - copy files for docker container
|
|
copy:
|
|
src: "image_refresh_php/"
|
|
dest: "{{ photo_refresh_folder }}/html"
|
|
mode: 0755
|
|
owner: root
|
|
group: root
|
|
|
|
# - name: carputer - photo_refresh - Build image
|
|
# shell: "docker build -t photo_refresh {{ photo_refresh_folder }}/."
|
|
|
|
# docker_image:
|
|
# name: photo_refresh # Name of the Docker image
|
|
# source: build
|
|
# build:
|
|
# path: "{{ photo_refresh_folder }}" # Path to the directory containing your Dockerfile
|
|
# state: present
|
|
# tag: latest
|
|
|
|
|
|
###############################################
|
|
# Start photo_refresh
|
|
###############################################
|
|
|
|
- name: start photo_refresh
|
|
block:
|
|
- name: carputer - photo_refresh - set container_name
|
|
set_fact:
|
|
container_name: "photo_refresh"
|
|
container_http_port: "8080"
|
|
extra_volumes: |
|
|
- {{ working_folder }}/small_thumbs:/var/www/html/capture
|
|
|
|
- name: carputer - photo_refresh - template config
|
|
template:
|
|
src: docker-compose-php.yaml.j2
|
|
dest: "{{ photo_refresh_folder }}/docker-compose.yaml"
|
|
mode: 0644
|
|
|
|
- name: carputer - photo_refresh - Start container at 0.0.0.0:8080
|
|
shell: "docker-compose -f {{ photo_refresh_folder }}/docker-compose.yaml up -d"
|
|
register: docker_output
|
|
- debug: |
|
|
msg="{{ docker_output.stdout_lines }}"
|
|
msg="{{ docker_output.stderr_lines }}"
|
|
|
|
###############################################
|
|
# set up thumbnail_purge
|
|
###############################################
|
|
|
|
- name: timelapse - purge thumbnail cron job
|
|
block:
|
|
|
|
- name: timelapse - create purge script
|
|
copy:
|
|
dest: "{{ photo_refresh_folder }}/purge_thumbnails.sh"
|
|
content: |
|
|
#!/bin/bash
|
|
TARGET_DIR="{{ working_folder }}/small_thumbs"
|
|
cd "$TARGET_DIR" || exit
|
|
# Find all files, sort them by modification time (oldest first), and delete all but the 50 most recent
|
|
ls -t | tail -n +1000 | while read -r file; do
|
|
if [ -f "$file" ]; then
|
|
# echo "Deleting file: $file"
|
|
rm "$file"
|
|
fi
|
|
done
|
|
mode: 0755
|
|
|
|
- name: timelapse - add purge to cron
|
|
copy:
|
|
dest: "/etc/cron.d/purge_thumbnails"
|
|
content: |
|
|
# This is for deleting the small thumbnails generated by the timelapse
|
|
# It should run once an hour
|
|
00 * * * * root {{ photo_refresh_folder }}/purge_thumbnails.sh
|
|
mode: 0755
|
|
|
|
... |