From 908db09cbbc6ae9a3b2bfd3eabc408ba1a5431b6 Mon Sep 17 00:00:00 2001 From: Nick Yeoman Date: Thu, 18 Jul 2024 09:42:31 -0700 Subject: [PATCH] Started using Docker's Extend feature. Nginx Proxy Manager and Stash App Updated --- nginx-proxy-manager/README.md | 60 +++++++++++ nginx-proxy-manager/docker-compose.yml | 18 ++++ stashapp/README.md | 139 +++++++++++++++++++++++++ stashapp/compose.bash | 76 -------------- stashapp/config | 1 - stashapp/docker-compose.yml | 58 ++++------- stashapp/env-sample | 3 - 7 files changed, 235 insertions(+), 120 deletions(-) create mode 100644 nginx-proxy-manager/README.md create mode 100644 nginx-proxy-manager/docker-compose.yml create mode 100644 stashapp/README.md delete mode 100644 stashapp/compose.bash delete mode 100644 stashapp/config delete mode 100644 stashapp/env-sample diff --git a/nginx-proxy-manager/README.md b/nginx-proxy-manager/README.md new file mode 100644 index 0000000..7ba1d8a --- /dev/null +++ b/nginx-proxy-manager/README.md @@ -0,0 +1,60 @@ +# Nginx Proxy Manager + +## Overview +This Docker Compose configuration sets up the Reverse Proxy application using Docker container. + +- App: [Proxy Manager on Docker Hub](https://hub.docker.com/r/jc21/nginx-proxy-manager) +- Official Site: [Nginx Proxy Manager](https://nginxproxymanager.com/) +- Expose ports: 80, 81, 443 + +## Create Network + +The first thing you want to do is create the network: + +```bash +docker network create proxy +``` + +## Expose Ports + +80 and 443 must be exposed, but you could proxy to 81 for the admin interface. + +## Project Setup + +```yaml +proxy: + extends: + file: ${COOKBOOK}/nginx-proxy-manager/docker-compose.yml + service: proxy + env_file: + - .env +``` + +### Create volumes +```bash +mkdir -p data/proxy data/proxy-letsencrypt +``` + +### env file + +```text +PROXY_IMAGE=jc21/nginx-proxy-manager:2.11.3 +``` + +## Usage + +In the project directory you have to run as root as you use port 80 and 443 + +```bash +# Docker Start +docker-compose up -d + +# Docker Stop +docker-compose down + +# Podman Start +sudo podman-compose up -d + +# Podman Stop +sudo podman-compose down +``` \ No newline at end of file diff --git a/nginx-proxy-manager/docker-compose.yml b/nginx-proxy-manager/docker-compose.yml new file mode 100644 index 0000000..d2bf0d2 --- /dev/null +++ b/nginx-proxy-manager/docker-compose.yml @@ -0,0 +1,18 @@ +version: '3.8' + +services: + proxy: + image: ${PROXY_IMAGE:-jc21/nginx-proxy-manager:latest} + restart: unless-stopped + environment: + X_FRAME_OPTIONS: "sameorigin" + DB_SQLITE_FILE: "/data/database.sqlite" + ports: + - "80:80" + - "81:81" + - "443:443" + volumes: + - "./data/proxy:/data" + - "./data/proxy-letsencrypt:/etc/letsencrypt" + networks: + - proxy diff --git a/stashapp/README.md b/stashapp/README.md new file mode 100644 index 0000000..648b68c --- /dev/null +++ b/stashapp/README.md @@ -0,0 +1,139 @@ +# Stash App Docker Compose Configuration + +## Overview +This Docker Compose configuration sets up the Stash application using Docker containers. + +- Stash App: [Stash on Docker Hub](https://hub.docker.com/r/stashapp/stash) +- Compose Example: [Stash GitHub Repository](https://github.com/stashapp/stash/blob/develop/docker/production/docker-compose.yml) +- ProxyPort: 9999 + +## Setup + +### COOKBOOK SETUP + +Clone the repository then set the COOKBOOK Variable in your PROJECT's env file +``` +git clone git@github.com:nickyeoman/docker-compose-cookbooks.git +``` + +### Project Setup + +Note this setup is meant to be used between two directories, COOKBOOK and PROJECT. +In your PROJECT directory set the following env file: + +```text +# Local +PROD=prod.domain.com +PRODDIR=/var/www/stashdomain-com/ +NETWORKNAME=proxy +COOKBOOK=/home/user/git/docker-compose-cookbooks +STASH_IMAGE=stashapp/stash:v0.26.2 + +# Container +STASH_DOMAIN_NAME=stash.4lt.ca +MAX_SIZE=200m +STASH_STASH=/data/ +STASH_GENERATED=/generated/ +STASH_METADATA=/metadata/ +STASH_CACHE=/cache/ +``` + +### Docker Compose Extend + +Now using extend you can call the service: + +```yaml +version: '3.4' + +services: + stash: + extends: + file: ${COOKBOOK}/stashapp/docker-compose.yml + service: stash + env_file: + - .env + ports: + - "9999:9999" +``` + +### Data directories + +By default the compose file creates volumes locally in the project: + +```bash +mkdir -p data/video data/cache data/metadata data/generated data/root/.stash +touch data/root/.stash/config.yml +``` + +Usually I .gitignore the data directory and use a backup solution for redundancy. + + +## Usage + +In the project directory just run + +```bash +# Docker Start +docker-compose up -d + +# Docker Stop +docker-compose down + +# Podman Start +podman-compose up -d + +# Podman Stop +podman-compose down +``` + +## Configuration Details + +### Environment Variables + +#### STASH_IMAGE + +Docker image tag for Stash app. + +#### STASH_DOMAIN_NAME + +Domain name for the Stash app. + +#### MAX_SIZE + +Maximum size for log files. + +#### Other + +STASH_STASH, STASH_GENERATED, STASH_METADATA, STASH_CACHE: Paths for Stash data directories. + +### Volumes + +/etc/localtime:/etc/localtime:ro: Mounts host system's timezone information. +./data/video:/data: Maps local ./data/video directory to Stash /data directory. +./data/metadata:/metadata: Maps local ./data/metadata directory to Stash /metadata directory. +./data/cache:/cache: Maps local ./data/cache directory to Stash /cache directory. +./data/generated:/generated: Maps local ./data/generated directory to Stash /generated directory. +./data/root:/root: Maps local ./data/root directory to Stash /root directory. + +### Networking + +In your project file, you can change the network mode to host: +```yaml +stash: + extends: + file: ${COOKBOOK}/stashapp/docker-compose.yml + service: stash + env_file: + - .env + ports: + - "8000:9999" + network_mode: "host" +``` + +If you are using a reverse proxy, you need to set that network: + +```yaml +networks: + proxy: + external: true +``` diff --git a/stashapp/compose.bash b/stashapp/compose.bash deleted file mode 100644 index f1de6ab..0000000 --- a/stashapp/compose.bash +++ /dev/null @@ -1,76 +0,0 @@ -#!/bin/#!/usr/bin/env bash - -#Variables -path="${PWD}/static/videos" -path_content="${PWD}/content/blog" -dt=`date +'%Y-%m-%d'` - -#setup -mkdir ${path}/meta - -#get filename var -for i in $(ls $path/*mp4); - do - # filename with no ext - filename="${i##*/}" - filename="${filename%.mp4}" - - # Get the resolution - res=`ffmpeg -i $i 2>&1 | grep Stream | grep -oP ', \K[0-9]+x[0-9]+'`; - name=`echo $i | sed 's/\(.*\)\..*/\1/'`; #remove extension - echo "res: $res" - - #Get the number of frames - #frames=`ffprobe -v error -select_streams v:0 -show_entries stream=nb_frames -of default=nokey=1:noprint_wrappers=1 $i` - #half frames - #z=$(($frames / 2)) - #Create thumb - #ffmpeg -i $i -y -vf scale=300:-1,"select=gte(n\,${z})" -vframes 1 ${path}/thumbs/${filename}.png - - #create a gif - ffmpeg -i $i -y -r 15 -vf scale=300:-1 -ss 00:00:03 -to 00:00:06 ${path}/thumbs/${filename}.gif - - # get metadata - ffmpeg -i $i -y -f ffmetadata ${path}/meta/${filename}.txt - - #title - title=`grep title ${path}/meta/${filename}.txt` - title=${title##*=} - - #alias/slug - alias=${title// /_} - alias=${alias,,} - - #artist - artist=`grep title ${path}/meta/${filename}.txt` - - #tags - echo "tags:" > ${path}/meta/${filename}-tags.txt - tags=`grep genre ${path}/meta/${filename}.txt` - tags=${tags##*=} - for value in $tags - do - #Work here - echo " - $value" >> ${path}/meta/${filename}-tags.txt - done - tags=`cat ${path}/meta/${filename}-tags.txt` - - # create or replace file - cat << EOF > ${path_content}/${filename}-${alias}.md ---- -title: "${filename} - ${title}" -cover: "${filename}" -date: "${dt}" -description: "Here is video${filename} which is ${res} and starting ${artist}" -${tags} ---- - -Here is video${filename} which is ${res} and starting ${artist}. - -{{< vids "${filename}" >}} - -EOF - -done; - -rm -rf ${path}/meta diff --git a/stashapp/config b/stashapp/config deleted file mode 100644 index cd4d08f..0000000 --- a/stashapp/config +++ /dev/null @@ -1 +0,0 @@ -#not sure what to put here diff --git a/stashapp/docker-compose.yml b/stashapp/docker-compose.yml index f4519e6..c369f3e 100644 --- a/stashapp/docker-compose.yml +++ b/stashapp/docker-compose.yml @@ -1,49 +1,27 @@ -################################################################################ -# Stash -# make sure you use the $PREFIX from .env for project_name -# docker-compose -p project_name up -d -# -# Version 1 -################################################################################ -version: '2' - -volumes: - stash: - stash-metadata: - stash-cache: - stash-generated: - -networks: - admin_web: - external: - name: admin_web +version: '3.4' services: stash: - # https://hub.docker.com/r/stashapp/stash - image: stashapp/stash:latest - restart: unless-stopped + image: ${STASH_IMAGE:-stashapp/stash:v0.26.2} logging: driver: "json-file" options: max-file: "100" - max-size: "200m" + max-size: ${MAX_SIZE:-200m} + restart: unless-stopped environment: - - STASH_STASH=/data/ - - STASH_GENERATED=/generated/ - - STASH_METADATA=/metadata/ - - STASH_CACHE=/cache/ - networks: - - admin_web + - STASH_STASH=${STASH_STASH:-/data/} + - STASH_GENERATED=${STASH_GENERATED:-/generated/} + - STASH_METADATA=${STASH_METADATA:-/metadata/} + - STASH_CACHE=${STASH_CACHE:-/cache/} volumes: - - /etc/localtime:/etc/localtime:ro - - stash:/data - - stash-metadata:/metadata - - stash-cache:/cache - - stash-generated:/generated - labels: - - "traefik.enable=true" - - "traefik.http.routers.${PREFIX}_stash.rule=Host(`${STASH_DOMAIN_NAME}`)" - - "traefik.http.routers.${PREFIX}_stash.entrypoints=websecure" - - "traefik.http.routers.${PREFIX}_stash.tls.certresolver=letsencrypt" - - "traefik.http.services.${PREFIX}_stash.loadbalancer.server.port=9999" + - "/etc/localtime:/etc/localtime:ro" + - "./data/video:/data" + - "./data/metadata:/metadata" + - "./data/cache:/cache" + - "./data/generated:/generated" + - "./data/root:/root" + # Uncomment and use if needed + # network_mode: "host" + + diff --git a/stashapp/env-sample b/stashapp/env-sample deleted file mode 100644 index 3f9a7fb..0000000 --- a/stashapp/env-sample +++ /dev/null @@ -1,3 +0,0 @@ -# Domain and project -STASH_DOMAIN_NAME=stash.nickyeoman.com -PREFIX=p1