try 2
This commit is contained in:
49
Techops/inventree.knownelement.com/config.yaml
Normal file
49
Techops/inventree.knownelement.com/config.yaml
Normal file
@@ -0,0 +1,49 @@
|
||||
# InvenTree configuration file for Cloudron
|
||||
# Refer to InvenTree documentation for detailed configuration options
|
||||
|
||||
# Database connection settings will be provided via environment variables
|
||||
|
||||
# General settings
|
||||
debug: False
|
||||
log_level: WARNING
|
||||
|
||||
# Secret key will be stored in a file
|
||||
secret_key_file: /app/data/secret_key.txt
|
||||
|
||||
# Plugin settings
|
||||
plugins:
|
||||
enabled: True
|
||||
plugin_dir: /app/data/plugins
|
||||
|
||||
# File storage locations
|
||||
media_root: /app/data/media
|
||||
static_root: /app/data/static
|
||||
|
||||
# Email settings - adjust with your Cloudron email settings if needed
|
||||
email:
|
||||
host: localhost
|
||||
port: 25
|
||||
tls: false
|
||||
ssl: false
|
||||
sender: inventree@localhost
|
||||
|
||||
# Login settings
|
||||
login:
|
||||
default_protocol: https
|
||||
allow_unverified_signup: False
|
||||
allow_signup: True
|
||||
signup_email_verification: False
|
||||
login_confirm_days: 3
|
||||
password_reset_timeout_days: 3
|
||||
|
||||
# Display settings
|
||||
customization:
|
||||
instance_name: InvenTree
|
||||
default_currency: USD
|
||||
base_url: "" # Will be set by environment variable in start.sh
|
||||
|
||||
# Server settings
|
||||
server:
|
||||
workers: 2
|
||||
allowed_hosts:
|
||||
- '*' # Cloudron handles this
|
35
Techops/inventree.knownelement.com/nginx.conf
Normal file
35
Techops/inventree.knownelement.com/nginx.conf
Normal file
@@ -0,0 +1,35 @@
|
||||
server {
|
||||
listen 8000; # This should match the httpPort in CloudronManifest.json
|
||||
|
||||
client_max_body_size 100M;
|
||||
|
||||
access_log /dev/stdout;
|
||||
error_log /dev/stderr;
|
||||
|
||||
# Serve static files
|
||||
location /static/ {
|
||||
alias /app/data/static/;
|
||||
expires 30d;
|
||||
add_header Pragma public;
|
||||
add_header Cache-Control "public";
|
||||
}
|
||||
|
||||
# Serve media files
|
||||
location /media/ {
|
||||
alias /app/data/media/;
|
||||
expires 30d;
|
||||
add_header Pragma public;
|
||||
add_header Cache-Control "public";
|
||||
}
|
||||
|
||||
# Proxy requests to gunicorn
|
||||
location / {
|
||||
proxy_pass http://127.0.0.1:8001;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
proxy_redirect off;
|
||||
proxy_buffering off;
|
||||
}
|
||||
}
|
72
Techops/inventree.knownelement.com/start.sh
Normal file
72
Techops/inventree.knownelement.com/start.sh
Normal file
@@ -0,0 +1,72 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
# PostgreSQL configuration from Cloudron environment variables
|
||||
if [ -n "${CLOUDRON_POSTGRESQL_HOST}" ]; then
|
||||
export INVENTREE_DB_ENGINE="postgresql"
|
||||
export INVENTREE_DB_NAME="${CLOUDRON_POSTGRESQL_DATABASE}"
|
||||
export INVENTREE_DB_USER="${CLOUDRON_POSTGRESQL_USERNAME}"
|
||||
export INVENTREE_DB_PASSWORD="${CLOUDRON_POSTGRESQL_PASSWORD}"
|
||||
export INVENTREE_DB_HOST="${CLOUDRON_POSTGRESQL_HOST}"
|
||||
export INVENTREE_DB_PORT="${CLOUDRON_POSTGRESQL_PORT}"
|
||||
else
|
||||
echo "PostgreSQL addon not configured!"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Ensure data directories exist
|
||||
if [ ! -d "${INVENTREE_HOME}/media" ]; then
|
||||
echo "Creating media directory..."
|
||||
mkdir -p "${INVENTREE_HOME}/media"
|
||||
cp -rn /tmp/data/media/* "${INVENTREE_HOME}/media/" || true
|
||||
fi
|
||||
|
||||
if [ ! -d "${INVENTREE_HOME}/static" ]; then
|
||||
echo "Creating static directory..."
|
||||
mkdir -p "${INVENTREE_HOME}/static"
|
||||
cp -rn /tmp/data/static/* "${INVENTREE_HOME}/static/" || true
|
||||
fi
|
||||
|
||||
if [ ! -d "${INVENTREE_HOME}/plugins" ]; then
|
||||
echo "Creating plugins directory..."
|
||||
mkdir -p "${INVENTREE_HOME}/plugins"
|
||||
cp -rn /tmp/data/plugins/* "${INVENTREE_HOME}/plugins/" || true
|
||||
fi
|
||||
|
||||
if [ ! -d "${INVENTREE_HOME}/config" ]; then
|
||||
echo "Creating config directory..."
|
||||
mkdir -p "${INVENTREE_HOME}/config"
|
||||
cp -rn /tmp/data/config/* "${INVENTREE_HOME}/config/" || true
|
||||
fi
|
||||
|
||||
# Generate secret key if it doesn't exist
|
||||
if [ ! -f "${INVENTREE_SECRET_KEY_FILE}" ]; then
|
||||
echo "Generating secret key..."
|
||||
python3 -c "from django.core.management.utils import get_random_secret_key; print(get_random_secret_key())" > "${INVENTREE_SECRET_KEY_FILE}"
|
||||
fi
|
||||
|
||||
cd /app/code/inventree
|
||||
|
||||
# Set InvenTree base URL (from Cloudron environment)
|
||||
export INVENTREE_BASE_URL="https://${CLOUDRON_APP_DOMAIN}"
|
||||
|
||||
# Apply database migrations and collect static files
|
||||
echo "Applying database migrations..."
|
||||
/app/code/env/bin/python manage.py migrate --noinput
|
||||
|
||||
echo "Collecting static files..."
|
||||
/app/code/env/bin/python manage.py collectstatic --noinput
|
||||
|
||||
# Create superuser if not exists
|
||||
echo "Checking for superuser..."
|
||||
DJANGO_SUPERUSER_PASSWORD="${INVENTREE_ADMIN_PASSWORD}" \
|
||||
/app/code/env/bin/python manage.py createsuperuser --noinput \
|
||||
--username "${INVENTREE_ADMIN_USER}" \
|
||||
--email "${INVENTREE_ADMIN_EMAIL}" || true
|
||||
|
||||
# Set proper permissions
|
||||
chown -R cloudron:cloudron "${INVENTREE_HOME}"
|
||||
|
||||
# Start supervisor to manage processes
|
||||
echo "Starting supervisor..."
|
||||
exec /usr/bin/supervisord -c /etc/supervisor/supervisord.conf
|
26
Techops/inventree.knownelement.com/supervisord.conf
Normal file
26
Techops/inventree.knownelement.com/supervisord.conf
Normal file
@@ -0,0 +1,26 @@
|
||||
[supervisord]
|
||||
nodaemon=true
|
||||
user=root
|
||||
logfile=/dev/stdout
|
||||
logfile_maxbytes=0
|
||||
|
||||
[program:gunicorn]
|
||||
command=/app/code/env/bin/gunicorn InvenTree.wsgi --bind 127.0.0.1:8001 --workers 2 --timeout 60 --preload --forwarded-allow-ips='*'
|
||||
directory=/app/code/inventree
|
||||
user=cloudron
|
||||
autostart=true
|
||||
autorestart=true
|
||||
stdout_logfile=/dev/stdout
|
||||
stdout_logfile_maxbytes=0
|
||||
stderr_logfile=/dev/stderr
|
||||
stderr_logfile_maxbytes=0
|
||||
environment=PYTHONUNBUFFERED=1,INVENTREE_CONFIG_FILE=/app/data/config/config.yaml
|
||||
|
||||
[program:nginx]
|
||||
command=/usr/sbin/nginx
|
||||
autostart=true
|
||||
autorestart=true
|
||||
stdout_logfile=/dev/stdout
|
||||
stdout_logfile_maxbytes=0
|
||||
stderr_logfile=/dev/stderr
|
||||
stderr_logfile_maxbytes=0
|
Reference in New Issue
Block a user