mirror of
https://github.com/nickyeoman/docker-compose-cookbooks.git
synced 2026-09-03 18:36:22 +00:00
docker extend build bash script working
This commit is contained in:
@@ -0,0 +1,7 @@
|
||||
#!/bin/bash
|
||||
|
||||
debug_print_helper_variables() {
|
||||
for var in $(compgen -v | grep '^HLPR_'); do
|
||||
echo "$var=${!var}"
|
||||
done
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Function to create directories based on volumes in docker-compose files
|
||||
create_dirs() {
|
||||
local project_path="$1"
|
||||
local selected_dirs="$2"
|
||||
local cookbook_dir="$3"
|
||||
|
||||
local data_dir="$project_path/data"
|
||||
|
||||
# Loop through selected directories
|
||||
for dir in $selected_dirs; do
|
||||
local compose_file="$cookbook_dir/$dir/docker-compose.yml"
|
||||
|
||||
# Check if the docker-compose file exists
|
||||
if [ -f "$compose_file" ]; then
|
||||
# Loop through each line in the file
|
||||
while IFS= read -r line; do
|
||||
trimmed_line=$(echo "$line" | sed 's/^[[:space:]]*//;s/[[:space:]]*$//')
|
||||
# Check if the line starts with a dash
|
||||
if [[ $trimmed_line =~ ^- ]]; then
|
||||
if [[ $trimmed_line =~ VOL_PATH ]]; then
|
||||
extracted=$(echo "$trimmed_line" | sed -n 's/.*\${VOL_PATH:-[^}]*}\([^:]*\):.*/\1/p' | sed 's/^\/\+//')
|
||||
# Echo the line if it starts with a dash
|
||||
mkdir -p $project_path/data/${extracted}
|
||||
fi
|
||||
fi
|
||||
done < "$compose_file"
|
||||
|
||||
else
|
||||
echo "Warning: No docker-compose.yml found in $dir"
|
||||
fi
|
||||
done
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Function to create a new docker-compose file using extends
|
||||
create_dockercompose() {
|
||||
local project_path="$1"
|
||||
local selected_dirs="$2"
|
||||
local script_dir="$3" # Directory where helper.bash is located
|
||||
|
||||
# Initialize the new docker-compose file
|
||||
local new_compose_file="$project_path/docker-compose.yml"
|
||||
|
||||
# Write the initial part of the docker-compose file
|
||||
echo "version: '3.4'" > "$new_compose_file"
|
||||
echo "" >> "$new_compose_file"
|
||||
echo "services:" >> "$new_compose_file"
|
||||
|
||||
# Loop through selected directories
|
||||
for dir in $selected_dirs; do
|
||||
local sample_file="$script_dir/$dir/sample-extends.yml"
|
||||
|
||||
if [ -f "$sample_file" ]; then
|
||||
# Extract services section from the sample file and append it
|
||||
awk '/^services:/{flag=1; next}/^$/{flag=0}flag' "$sample_file" >> "$new_compose_file"
|
||||
echo "" >> "$new_compose_file" # Add a newline after each file's content
|
||||
else
|
||||
echo "Warning: Create an issue: No sample-extends.yml found in $dir"
|
||||
cp $script_dir/$dir/docker-compose.yml $new_compose_file
|
||||
fi
|
||||
done
|
||||
}
|
||||
+102
@@ -0,0 +1,102 @@
|
||||
#!/bin/bash
|
||||
|
||||
process_help_comments() {
|
||||
local input_file="$1"
|
||||
local output_file="$2"
|
||||
local project_path="$3"
|
||||
local cookbook_dir="$4"
|
||||
|
||||
local temp_file=$(mktemp)
|
||||
|
||||
while IFS= read -r line; do
|
||||
# Handle headings (keep headings and process below lines)
|
||||
if [[ "$line" =~ ^# ]]; then
|
||||
echo "$line" >> "$temp_file"
|
||||
elif [[ "$line" =~ ^([^=]+)= ]]; then
|
||||
local var_name="${BASH_REMATCH[1]}"
|
||||
local var_value="${line#*=}"
|
||||
var_value=$(echo "$var_value" | sed 's/\s*#HELP:.*$//')
|
||||
|
||||
# Process #HELP comments
|
||||
if [[ "$line" =~ \#HELP:\ project_path ]]; then
|
||||
var_value="$HLPR_PROJECTPATH"
|
||||
elif [[ "$line" =~ \#HELP:\ volpath ]]; then
|
||||
var_value="$HLPR_PROJECTPATH/data"
|
||||
elif [[ "$line" =~ \#HELP:\ cookbooks ]]; then
|
||||
var_value="$HLPR_COOKBOOKDIR"
|
||||
elif [[ "$line" =~ \#HELP:\ gen32 ]]; then
|
||||
var_value=$(pwgen -cnsB1v 32)
|
||||
fi
|
||||
|
||||
# Add the processed variable to the temp file
|
||||
echo "${var_name}=${var_value}" >> "$temp_file"
|
||||
else
|
||||
# If the line doesn't match a variable, just echo it
|
||||
echo "$line" >> "$temp_file"
|
||||
fi
|
||||
done < "$input_file"
|
||||
|
||||
# Call remove_duplicate_variables to process temp_file and write to output_file
|
||||
cat "$temp_file" >> $output_file
|
||||
rm "$temp_file"
|
||||
}
|
||||
|
||||
remove_duplicate_variables() {
|
||||
local input_file="$1"
|
||||
local temp_file=$(mktemp)
|
||||
declare -A seen_keys
|
||||
|
||||
while IFS= read -r line; do
|
||||
|
||||
# Skip lines that start with # or are blank
|
||||
if [[ ! $line =~ ^# ]] && [[ -n $line ]]; then
|
||||
# Extract the part before the equals sign
|
||||
key=$(echo "$line" | awk -F '=' '{print $1}')
|
||||
|
||||
# Check if the key has already been seen
|
||||
if [[ -z "${seen_keys[$key]}" ]]; then
|
||||
# Mark the key as seen
|
||||
seen_keys[$key]=1
|
||||
# Output the key
|
||||
echo "$line" >> "$temp_file"
|
||||
fi
|
||||
else
|
||||
echo "$line" >> "$temp_file"
|
||||
fi
|
||||
done < "$input_file"
|
||||
|
||||
# Replace the original file with the deduplicated version
|
||||
mv "$temp_file" "$input_file"
|
||||
}
|
||||
|
||||
# Function to create .env file
|
||||
create_env() {
|
||||
local project_path="$1"
|
||||
local selected_dirs="$2"
|
||||
local cookbook_dir="$3"
|
||||
local new_env_file="$project_path/.env"
|
||||
local current_date=$(date)
|
||||
local git_user=$(git config --get user.name)
|
||||
if [[ -z "$git_user" ]]; then
|
||||
local git_user=$USER
|
||||
fi
|
||||
|
||||
# Create the file
|
||||
touch $new_env_file
|
||||
echo "# Auto Generated env file on $current_date by $git_user" >> "$new_env_file"
|
||||
|
||||
# Loop through selected directories and process sample.env files
|
||||
for dir in $selected_dirs; do
|
||||
local sample_file="$cookbook_dir/$dir/sample.env"
|
||||
|
||||
if [ -f "$sample_file" ]; then
|
||||
process_help_comments "$sample_file" "$new_env_file" "$project_path" "$cookbook_dir"
|
||||
else
|
||||
echo "Warning: Create an issue: No sample.env found in $dir" >&2
|
||||
echo "#No Sample File found, raise a bug" >> "$new_env_file"
|
||||
fi
|
||||
done
|
||||
|
||||
remove_duplicate_variables "$new_env_file"
|
||||
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
#!/bin/bash
|
||||
|
||||
function display_footer() {
|
||||
echo "======================================"
|
||||
echo "All Done"
|
||||
echo "Created Project: $HLPR_PROJECTNAME in $HLPR_PROJECTDIR"
|
||||
echo "With the following containers:"
|
||||
echo $HLPR_CONTAINERS
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Function to create a .gitignore file with standard ignores
|
||||
create_gitignore() {
|
||||
local project_path="$1"
|
||||
local gitignore_path="$project_path/.gitignore"
|
||||
|
||||
# Create the .gitignore file
|
||||
cat <<EOL > "$gitignore_path"
|
||||
data/
|
||||
logs/
|
||||
*.log
|
||||
.vscode/
|
||||
.idea/
|
||||
*.suo
|
||||
*.ntvs*
|
||||
*.njsproj
|
||||
*.sln
|
||||
.DS_Store
|
||||
Thumbs.db
|
||||
EOL
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
#!/bin/bash
|
||||
|
||||
function display_header() {
|
||||
echo "======================================"
|
||||
echo " Docker Compose Project Setup Wizard"
|
||||
echo "======================================"
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Function to check if fzf is installed and provide installation instructions if not
|
||||
check_fzf() {
|
||||
if ! command -v fzf &> /dev/null; then
|
||||
echo "fzf is not installed."
|
||||
echo "To install fzf:"
|
||||
echo " - Fedora: sudo dnf install fzf"
|
||||
echo " - Arch: sudo pacman -S fzf"
|
||||
echo " - Debian: sudo apt install fzf"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
# Function to check if pwgen is installed and provide installation instructions if not
|
||||
check_pwgen() {
|
||||
if ! command -v pwgen &> /dev/null; then
|
||||
echo "pwgen is not installed."
|
||||
echo "To install pwgen:"
|
||||
echo " - Fedora: sudo dnf install pwgen"
|
||||
echo " - Arch: sudo pacman -S pwgen"
|
||||
echo " - Debian: sudo apt install pwgen"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Function to check if the project directory already exists
|
||||
check_project() {
|
||||
local path="$1"
|
||||
if [ -d "$path" ]; then
|
||||
echo "Error: Directory '$path' already exists."
|
||||
return 1
|
||||
fi
|
||||
return 0
|
||||
}
|
||||
|
||||
# Function to create the project directory
|
||||
create_project() {
|
||||
local path="$1"
|
||||
mkdir -p "$path"
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Error: Failed to create directory '$path'. Exiting."
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
# Function to handle the project directory creation process
|
||||
handle_project_creation() {
|
||||
local project_path="$1"
|
||||
local project_name="$2"
|
||||
|
||||
while true; do
|
||||
check_project "$HLPR_PROJECTDIR"
|
||||
if [ $? -eq 0 ]; then
|
||||
create_project "$HLPR_PROJECTDIR"
|
||||
break
|
||||
else
|
||||
read -p "Please enter a new directory path (must not exist): " new_project_path
|
||||
if [ -z "$new_project_path" ]; then
|
||||
echo "Error: Path cannot be empty. Exiting."
|
||||
exit 1
|
||||
fi
|
||||
project_path="$new_project_path"
|
||||
HLPR_PROJECTDIR="$project_path/$project_name"
|
||||
fi
|
||||
done
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Function to get user input for project name
|
||||
get_project_name() {
|
||||
while true; do
|
||||
read -p "Enter project name (usually the domain name, like www-example-com): " HLPR_PROJECTNAME
|
||||
if [[ "$HLPR_PROJECTNAME" =~ ^[a-zA-Z0-9-]+$ ]]; then
|
||||
break
|
||||
else
|
||||
echo "Invalid project name. Please use only letters, numbers, and dashes. No spaces allowed."
|
||||
fi
|
||||
done
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Function to display directories using fzf with enhanced parameters
|
||||
select_directory_with_fzf() {
|
||||
# Find all directories under the user's home directory, excluding dot directories and suppressing permission errors
|
||||
local fzf_input=$(find "$HOME" -type d -not -path '*/\.*' 2>/dev/null | while read -r dir; do [ -r "$dir" ] && echo "$dir"; done)
|
||||
|
||||
# Use fzf with enhanced parameters for better usability
|
||||
selected_path=$(echo "$fzf_input" | fzf --height 40% --layout=reverse --border --preview 'echo {} | xargs -I % du -sh % 2>/dev/null' --preview-window=up:30% --prompt="Select a directory: ")
|
||||
|
||||
# Handle the case where no directory was selected
|
||||
if [ -z "$selected_path" ]; then
|
||||
echo "No directory selected. Exiting."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Output the selected path
|
||||
HLPR_PROJECTPATH="$selected_path"
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Function to create a README.md file
|
||||
create_readme() {
|
||||
local project_path="$1"
|
||||
local project_name="$2"
|
||||
local selected_dirs="$3"
|
||||
local readme_path="$project_path/README.md"
|
||||
local current_date=$(date +"%Y-%m-%d")
|
||||
|
||||
# Retrieve the full name from the global Git config
|
||||
local git_name=$(git config --global user.name)
|
||||
if [ -z "$git_name" ]; then
|
||||
echo 'WARNING: Set your git username: git config --global user.name "Your Name"'
|
||||
git_name="$USER"
|
||||
fi
|
||||
|
||||
# Create the README.md file
|
||||
cat <<EOL > "$readme_path"
|
||||
# $project_name
|
||||
|
||||
Project created on $current_date by $git_name
|
||||
|
||||
## Description
|
||||
|
||||
A brief description of your project goes here.
|
||||
|
||||
## Project Structure
|
||||
|
||||
This project includes the following containers:
|
||||
|
||||
EOL
|
||||
|
||||
# Add the selected directories to the README
|
||||
if [ -n "$selected_dirs" ]; then
|
||||
echo "$selected_dirs" | while read -r dir; do
|
||||
echo "- $(basename "$dir")" >> "$readme_path"
|
||||
done
|
||||
else
|
||||
echo "No containers selected." >> "$readme_path"
|
||||
fi
|
||||
|
||||
cat <<EOL >> "$readme_path"
|
||||
|
||||
## Usage
|
||||
|
||||
podman-compose up -d
|
||||
|
||||
EOL
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Function to list all directories in the same directory as the helper script and allow the user to select multiple directories
|
||||
select_directories() {
|
||||
# Get the directory where this script is located
|
||||
local script_dir=$(dirname "$(realpath "$0")")
|
||||
|
||||
# Find all directories in the same directory as the helper script and get their basenames, excluding those starting with an underscore
|
||||
local dir_list=$(find "$script_dir" -maxdepth 1 -type d -not -path '*/\.*' -not -path "$script_dir" -not -name '_*' | xargs -I {} basename {})
|
||||
|
||||
# Use fzf to allow the user to select multiple directories with checkboxes
|
||||
local selected_dirs=$(echo "$dir_list" | fzf --multi --height 40% --layout=reverse --border --prompt="Select directories (TAB to toggle, ENTER to confirm): " --bind 'tab:toggle+down')
|
||||
|
||||
# Handle the case where no directory was selected
|
||||
if [ -z "$selected_dirs" ]; then
|
||||
echo "No directories selected. Exiting."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
HLPR_CONTAINERS="$selected_dirs"
|
||||
}
|
||||
+84
@@ -0,0 +1,84 @@
|
||||
#!/bin/bash
|
||||
|
||||
HLPR_COOKBOOKDIR="$(dirname "$(realpath "$BASH_SOURCE")")"
|
||||
HLPR_PROJECTNAME='NEW_PROJECT'
|
||||
HLPR_PROJECTPATH=$HOME
|
||||
HLPR_PROJECTDIR="$HLPR_PROJECTPATH/$HLPR_PROJECTNAME"
|
||||
HLPR_CONTAINERS=''
|
||||
|
||||
#source ./_helper/debug.sh
|
||||
# debug_print_helper_variables
|
||||
|
||||
################################################
|
||||
# Pre Check
|
||||
################################################
|
||||
source ./_helper/precheck.sh
|
||||
check_fzf
|
||||
check_pwgen
|
||||
|
||||
################################################
|
||||
# Display Header
|
||||
################################################
|
||||
source ./_helper/header.sh
|
||||
display_header
|
||||
|
||||
################################################
|
||||
# Get Project Name
|
||||
################################################
|
||||
source ./_helper/project-name.sh
|
||||
get_project_name
|
||||
|
||||
################################################
|
||||
# Get Project Path
|
||||
################################################
|
||||
source ./_helper/project-path.sh
|
||||
select_directory_with_fzf
|
||||
HLPR_PROJECTDIR="$HLPR_PROJECTPATH/$HLPR_PROJECTNAME"
|
||||
|
||||
################################################
|
||||
# Select containers
|
||||
################################################
|
||||
source ./_helper/select-containers.sh
|
||||
select_directories
|
||||
|
||||
################################################
|
||||
# Create Project Directory
|
||||
################################################
|
||||
source ./_helper/project-create.sh
|
||||
handle_project_creation "$HLPR_PROJECTPATH" "$HLPR_PROJECTNAME"
|
||||
|
||||
################################################
|
||||
# Create a .gitignore
|
||||
################################################
|
||||
source ./_helper/gitignore.sh
|
||||
create_gitignore "$HLPR_PROJECTDIR"
|
||||
|
||||
################################################
|
||||
# Create a README.md
|
||||
################################################
|
||||
source ./_helper/readme.sh
|
||||
create_readme "$HLPR_PROJECTDIR" "$HLPR_PROJECTNAME" "$HLPR_CONTAINERS"
|
||||
|
||||
################################################
|
||||
# Create docker-compose
|
||||
################################################
|
||||
source ./_helper/dockercompose.sh
|
||||
create_dockercompose "$HLPR_PROJECTDIR" "$HLPR_CONTAINERS" "$HLPR_COOKBOOKDIR"
|
||||
|
||||
################################################
|
||||
# Create env
|
||||
################################################
|
||||
source ./_helper/env.sh
|
||||
create_env "$HLPR_PROJECTDIR" "$HLPR_CONTAINERS" "$HLPR_COOKBOOKDIR"
|
||||
|
||||
################################################
|
||||
# Create directories
|
||||
################################################
|
||||
source ./_helper/dirs.sh
|
||||
create_dirs "$HLPR_PROJECTDIR" "$HLPR_CONTAINERS" "$HLPR_COOKBOOKDIR"
|
||||
|
||||
################################################
|
||||
# Display Footer
|
||||
################################################
|
||||
source ./_helper/footer.sh
|
||||
display_footer
|
||||
@@ -21,14 +21,7 @@ docker network create proxy
|
||||
|
||||
## Project Setup
|
||||
|
||||
```yaml
|
||||
proxy:
|
||||
extends:
|
||||
file: ${COOKBOOK}/nginx-proxy-manager/docker-compose.yml
|
||||
service: proxy
|
||||
env_file:
|
||||
- .env
|
||||
```
|
||||
See sample-extends.yml
|
||||
|
||||
### Create volumes
|
||||
```bash
|
||||
@@ -38,6 +31,10 @@ mkdir -p data/proxy data/proxy-letsencrypt
|
||||
### env file
|
||||
|
||||
```text
|
||||
# Nginx Proxy Manager
|
||||
PRODDIR=/var/www/stashdomain-com/ #HELP: project_path
|
||||
VOL_PATH=/docker/vol/portainer-data #HELP: volpath
|
||||
COOKBOOK=/home/user/git/docker-compose-cookbooks #HELP: cookbooks
|
||||
PROXY_IMAGE=jc21/nginx-proxy-manager:2.11.3
|
||||
```
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ services:
|
||||
- "81:81"
|
||||
- "443:443"
|
||||
volumes:
|
||||
- "./data/proxy:/data"
|
||||
- "./data/proxy-letsencrypt:/etc/letsencrypt"
|
||||
- "${VOL_PATH:-./data/proxy}/proxy-data:/data"
|
||||
- "${VOL_PATH:-./data/proxy-letsencrypt}/proxy-letsencrypt:/etc/letsencrypt"
|
||||
networks:
|
||||
- proxy
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
version: '3.4'
|
||||
|
||||
services:
|
||||
proxy:
|
||||
extends:
|
||||
file: ${COOKBOOK}/nginx-proxy-manager/docker-compose.yml
|
||||
service: proxy
|
||||
env_file:
|
||||
- .env
|
||||
@@ -0,0 +1,5 @@
|
||||
# Nginx Proxy Manager
|
||||
PRODDIR=/var/www/stashdomain-com/ #HELP: project_path
|
||||
VOL_PATH=/docker/vol/portainer-data #HELP: volpath
|
||||
COOKBOOK=/home/user/git/docker-compose-cookbooks #HELP: cookbooks
|
||||
PROXY_IMAGE=jc21/nginx-proxy-manager:2.11.3
|
||||
@@ -8,4 +8,4 @@ services:
|
||||
restart: always
|
||||
volumes:
|
||||
- "${VOL_PATH:-./data}/website:/data"
|
||||
- "${VOL_PATH:-./config}/php.ini:/usr/local/etc/php/php.ini"
|
||||
- "./config/php.ini:/usr/local/etc/php/php.ini"
|
||||
|
||||
+4
-3
@@ -14,11 +14,12 @@ Create a private network for portainer: ```sudo podman network create portainer-
|
||||
You must set an agent secret ```openssl rand -base64 32```
|
||||
|
||||
```
|
||||
# Portainer
|
||||
PORTAINER_IMAGE=portainer/portainer-ce:latest
|
||||
PORTAINER_AGENT_IMAGE=portainer/agent:latest
|
||||
AGENT_SECRET=01234567890132456789012345678912
|
||||
VOL_PATH=/docker/vol/portainer-data
|
||||
COOKBOOK=/home/user/git/docker-compose-cookbooks
|
||||
AGENT_SECRET=01234567890132456789012345678912 #HELP: gen32
|
||||
VOL_PATH=/docker/vol/portainer-data #HELP: volpath
|
||||
COOKBOOK=/home/user/git/docker-compose-cookbooks #HELP: cookbooks
|
||||
```
|
||||
|
||||
### Docker Compose Extend
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
# Domains & Project
|
||||
PORTAINER_DOMAIN_NAME=portainer.nickyeoman.com
|
||||
|
||||
# Software versions
|
||||
|
||||
# https://hub.docker.com/r/portainer/portainer
|
||||
PORTAINER_V=1.24.0
|
||||
@@ -0,0 +1,20 @@
|
||||
version: '3.4'
|
||||
|
||||
networks:
|
||||
portainer-net:
|
||||
external: true
|
||||
|
||||
services:
|
||||
portainer-agent:
|
||||
extends:
|
||||
file: ${COOKBOOK}/portainer/docker-compose.yml
|
||||
service: portainer-agent
|
||||
env_file:
|
||||
- .env
|
||||
|
||||
portainer:
|
||||
extends:
|
||||
file: ${COOKBOOK}/portainer/docker-compose.yml
|
||||
service: portainer
|
||||
env_file:
|
||||
- .env
|
||||
@@ -0,0 +1,6 @@
|
||||
# Portainer
|
||||
PORTAINER_IMAGE=portainer/portainer-ce:latest
|
||||
PORTAINER_AGENT_IMAGE=portainer/agent:latest
|
||||
AGENT_SECRET=01234567890132456789012345678912 #HELP: gen32
|
||||
VOL_PATH=/docker/vol/portainer-data #HELP: volpath
|
||||
COOKBOOK=/home/user/git/docker-compose-cookbooks #HELP: cookbooks
|
||||
+5
-5
@@ -22,14 +22,14 @@ Note this setup is meant to be used between two directories, COOKBOOK and PROJEC
|
||||
In your PROJECT directory set the following env file:
|
||||
|
||||
```text
|
||||
# Local
|
||||
# Stash App
|
||||
PROD=prod.domain.com
|
||||
PRODDIR=/var/www/stashdomain-com/
|
||||
COOKBOOK=/home/user/git/docker-compose-cookbooks
|
||||
VOL_PATH=/project-dir/project-name/data
|
||||
PRODDIR=/var/www/stashdomain-com/ #HELP: project_path
|
||||
COOKBOOK=/home/user/git/docker-compose-cookbooks #HELP: cookbooks
|
||||
VOL_PATH=/project-dir/project-name/data #HELP: volpath
|
||||
STASH_IMAGE=stashapp/stash:v0.26.2
|
||||
|
||||
# Container
|
||||
# Stash Container
|
||||
STASH_DOMAIN_NAME=stash.4lt.ca
|
||||
MAX_SIZE=200m
|
||||
STASH_STASH=/data/
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
version: '3.4'
|
||||
|
||||
services:
|
||||
stash:
|
||||
extends:
|
||||
file: ${COOKBOOK}/stashapp/docker-compose.yml
|
||||
service: stash
|
||||
env_file:
|
||||
- .env
|
||||
ports:
|
||||
- "9999:9999"
|
||||
@@ -0,0 +1,13 @@
|
||||
# Stash App
|
||||
PROD=prod.domain.com
|
||||
PRODDIR=/var/www/stashdomain-com/ #HELP: project_path
|
||||
COOKBOOK=/home/user/git/docker-compose-cookbooks #HELP: cookbooks
|
||||
VOL_PATH=/project-dir/project-name/data #HELP: volpath
|
||||
STASH_IMAGE=stashapp/stash:v0.26.2
|
||||
# Stash Container
|
||||
STASH_DOMAIN_NAME=stash.4lt.ca
|
||||
MAX_SIZE=200m
|
||||
STASH_STASH=/data/
|
||||
STASH_GENERATED=/generated/
|
||||
STASH_METADATA=/metadata/
|
||||
STASH_CACHE=/cache/
|
||||
@@ -1,15 +0,0 @@
|
||||
FROM openjdk:8-jre-slim
|
||||
|
||||
WORKDIR /app/streama
|
||||
|
||||
RUN apt-get -y update && \
|
||||
apt-get -y install curl && \
|
||||
apt-get -y clean && \
|
||||
apt-get -y autoremove && \
|
||||
URL_DOWNLOAD_LATEST_RELEASE=$(curl -L https://api.github.com/repos/streamaserver/streama/releases | grep -i browser_download_url | head -n 1 | cut -d '"' -f 4) && \
|
||||
curl -o streama.jar -L $URL_DOWNLOAD_LATEST_RELEASE && \
|
||||
chmod u+x streama.jar
|
||||
|
||||
EXPOSE 8080
|
||||
|
||||
ENTRYPOINT [ "java", "-jar", "streama.jar" ]
|
||||
@@ -1,31 +0,0 @@
|
||||
---
|
||||
version: "2"
|
||||
|
||||
services:
|
||||
streama-db:
|
||||
image: mariadb:${DB_V}
|
||||
restart: always
|
||||
volumes:
|
||||
- streama-db:/var/lib/mysql
|
||||
environment:
|
||||
MYSQL_ROOT_PASSWORD: ${STREAMA_MYSQL_ROOT_PASSWORD}
|
||||
MYSQL_PASSWORD: ${STREAMA_MYSQL_PASSWORD}
|
||||
MYSQL_DATABASE: streama
|
||||
MYSQL_USER: streama
|
||||
|
||||
streama:
|
||||
image: streama
|
||||
build: .
|
||||
restart: always
|
||||
depends_on:
|
||||
- streama-db
|
||||
volumes:
|
||||
- streama-movies:/data/streama # Change to your video folder
|
||||
- streama-appdata:/app/streama
|
||||
environment:
|
||||
ACTIVE_PROFILE: mysql
|
||||
MYSQL_HOST: ${PREFIX}_streama-db_1
|
||||
MYSQL_PORT: 3306
|
||||
MYSQL_DB: streama
|
||||
MYSQL_USER: streama
|
||||
MYSQL_PASSWORD: ${STREAMA_MYSQL_PASSWORD}
|
||||
@@ -1,8 +0,0 @@
|
||||
# Domains & Project
|
||||
PREFIX=p1
|
||||
STREAMA_MYSQL_ROOT_PASSWORD=<NEW-PASSWORD>
|
||||
STREAMA_MYSQL_PASSWORD=<NEW-PASSWORD>
|
||||
STREAMA_DOMAIN_NAME=sample.example.com
|
||||
|
||||
# Software versions
|
||||
DB_V=10.4.11
|
||||
@@ -1,3 +0,0 @@
|
||||
FROM nginx:alpine
|
||||
|
||||
COPY nginx.conf /etc/nginx/nginx.conf
|
||||
@@ -1,35 +0,0 @@
|
||||
user nginx;
|
||||
worker_processes auto;
|
||||
|
||||
error_log /var/log/nginx/error.log warn;
|
||||
pid /var/run/nginx.pid;
|
||||
|
||||
events { worker_connections 512; }
|
||||
|
||||
http {
|
||||
|
||||
sendfile on;
|
||||
|
||||
server {
|
||||
listen 80;
|
||||
listen [::]:80;
|
||||
|
||||
client_max_body_size 128g; # allows larger files (like videos) to be uploaded.
|
||||
|
||||
location / {
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
proxy_set_header X-Forwarded-Port $server_port;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
|
||||
#WebSocket Support
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection $http_connection;
|
||||
|
||||
proxy_pass http://streama:8080;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,58 +0,0 @@
|
||||
###############################################################################
|
||||
# Traefik
|
||||
#
|
||||
# Should only need one instance of this.
|
||||
# Make sure the .env file is updated
|
||||
# docker-compose up -d
|
||||
###############################################################################
|
||||
version: '2'
|
||||
|
||||
networks:
|
||||
web:
|
||||
driver: bridge
|
||||
|
||||
volumes:
|
||||
traefik:
|
||||
|
||||
services:
|
||||
|
||||
traefik:
|
||||
# https://hub.docker.com/_/traefik
|
||||
image: "traefik:${TRAEFIK_V}"
|
||||
restart: unless-stopped
|
||||
command:
|
||||
- --entrypoints.web.address=:80
|
||||
- --entrypoints.websecure.address=:443
|
||||
- --api
|
||||
- "--log.level=DEBUG"
|
||||
- "--api.dashboard=true"
|
||||
- "--providers.docker=true"
|
||||
- "--providers.docker.exposedbydefault=false"
|
||||
- "--certificatesresolvers.letsencrypt.acme.httpchallenge=true"
|
||||
- "--certificatesresolvers.letsencrypt.acme.httpchallenge.entrypoint=web"
|
||||
- "--certificatesresolvers.letsencrypt.acme.email=${TRAEFIK_LE_EMAIL}"
|
||||
- "--certificatesresolvers.letsencrypt.acme.storage=/letsencrypt/acme.json"
|
||||
ports:
|
||||
- "80:80"
|
||||
- "443:443"
|
||||
volumes:
|
||||
- "/var/run/docker.sock:/var/run/docker.sock:ro"
|
||||
- traefik:/letsencrypt
|
||||
networks:
|
||||
- web
|
||||
labels:
|
||||
# Dashboard
|
||||
- "traefik.http.routers.traefik.rule=Host(`${TRAEFIK_DOMAIN_NAME}`)"
|
||||
- "traefik.http.routers.traefik.service=api@internal"
|
||||
- "traefik.http.routers.traefik.tls.certresolver=letsencrypt"
|
||||
- "traefik.http.routers.traefik.entrypoints=websecure"
|
||||
- "traefik.http.routers.traefik.middlewares=dashboardauth"
|
||||
- "traefik.http.routers.traefik.middlewares=authtraefik"
|
||||
- "traefik.http.middlewares.authtraefik.basicauth.users=<USER>:<PASSWORD>"
|
||||
# global redirect to https
|
||||
- "traefik.http.routers.http-catchall.rule=hostregexp(`{host:.+}`)"
|
||||
- "traefik.http.routers.http-catchall.entrypoints=web"
|
||||
- "traefik.http.routers.http-catchall.middlewares=redirect-to-https@docker"
|
||||
# middleware redirect
|
||||
- "traefik.http.middlewares.redirect-to-https.redirectscheme.scheme=https"
|
||||
- "traefik.enable=true"
|
||||
@@ -1,13 +0,0 @@
|
||||
# Domains & Project
|
||||
PREFIX=p1
|
||||
TRAEFIK_DOMAIN_NAME=traefik.nickyeoman.com
|
||||
TRAEFIK_LE_EMAIL=email@domain.com
|
||||
# Passwords
|
||||
# https://medium.com/@techupbusiness/add-basic-authentication-in-docker-compose-files-with-traefik-34c781234970
|
||||
# echo $(htpasswd -nbB <USER> "<PASS>") | sed -e s/\\$/\\$\\$/g
|
||||
TRAEFIK_USER=username
|
||||
TRAEFIK_PASS=M@keASecureOne
|
||||
|
||||
# Software versions
|
||||
# https://hub.docker.com/_/traefik
|
||||
TRAEFIK_V=2.2.0
|
||||
Reference in New Issue
Block a user