first cut of inventree for cloodron

This commit is contained in:
2025-04-21 12:17:52 -04:00
parent 4a0584e2e7
commit d318ed951c
8 changed files with 216 additions and 4 deletions

View File

@@ -0,0 +1,24 @@
{
"id": "org.inventree.cloudronapp",
"title": "InvenTree",
"author": "Your Name",
"description": "InvenTree is an open-source inventory management system which provides intuitive parts management and stock control.",
"tagline": "Open Source Inventory Management System",
"version": "1.0.0",
"healthCheckPath": "/",
"httpPort": 8000,
"manifestVersion": 2,
"website": "https://inventree.org",
"contactEmail": "your.email@example.com",
"icon": "logo.png",
"documentationUrl": "https://docs.inventree.org",
"memoryLimit": 1024000000,
"configurePath": "/admin",
"minBoxVersion": "7.0.0",
"changelog": "Initial version",
"addons": {
"localstorage": {},
"postgresql": {}
},
"postInstallMessage": "InvenTree has been installed. The default admin credentials are:\n\nUsername: admin\nPassword: admin\n\nPlease change the admin password after your first login."
}

View File

@@ -0,0 +1,74 @@
FROM cloudron/base:4.2.0
# Set environment variables
ENV PYTHONUNBUFFERED=1 \
DEBIAN_FRONTEND=noninteractive \
INVENTREE_HOME=/app/data \
INVENTREE_MEDIA_ROOT=/app/data/media \
INVENTREE_STATIC_ROOT=/app/data/static \
INVENTREE_SECRET_KEY_FILE=/app/data/secret_key.txt \
INVENTREE_PLUGINS_ENABLED=true \
INVENTREE_PLUGINS_DIR=/app/data/plugins \
INVENTREE_ADMIN_USER=admin \
INVENTREE_ADMIN_PASSWORD=admin \
INVENTREE_ADMIN_EMAIL=admin@example.com
# Install required packages
RUN apt-get update && apt-get install -y \
python3 \
python3-pip \
python3-dev \
python3-venv \
build-essential \
libpq-dev \
git \
nginx \
supervisor \
&& rm -rf /var/lib/apt/lists/*
# Setup nginx for Cloudron
RUN rm /etc/nginx/sites-enabled/* \
&& sed -e 's,^ErrorLog.*,ErrorLog "/dev/stderr",' -i /etc/nginx/nginx.conf \
&& echo "daemon off;" >> /etc/nginx/nginx.conf
# Create InvenTree directories
RUN mkdir -p /app/code \
&& mkdir -p /tmp/data/media \
&& mkdir -p /tmp/data/static \
&& mkdir -p /tmp/data/plugins \
&& mkdir -p /tmp/data/env \
&& mkdir -p /tmp/data/config
# Create Python virtual environment
RUN python3 -m venv /app/code/env
# Clone InvenTree source code
RUN git clone --depth 1 https://github.com/inventree/InvenTree.git /app/code/inventree
# Install InvenTree requirements
WORKDIR /app/code/inventree
RUN /app/code/env/bin/pip install --upgrade pip \
&& /app/code/env/bin/pip install wheel \
&& /app/code/env/bin/pip install --no-cache-dir -r requirements.txt \
&& /app/code/env/bin/pip install psycopg2 gunicorn
# Create default configuration files
COPY config.yaml /tmp/data/config/config.yaml
COPY nginx.conf /etc/nginx/sites-available/inventree
RUN ln -s /etc/nginx/sites-available/inventree /etc/nginx/sites-enabled/
# Copy supervisor configuration
COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf
# Add startup script
COPY start.sh /app/code/start.sh
RUN chmod +x /app/code/start.sh
# Setup NGINX runtime directory
RUN mkdir -p /run/nginx \
&& chown -R cloudron:cloudron /run/nginx
# Expose port
EXPOSE 8000
CMD ["/app/code/start.sh"]

View 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 Cloudron
# Server settings
server:
workers: 2
allowed_hosts:
- '*' # Cloudron handles this

View File

@@ -1 +0,0 @@
#inventree docker compose for tsys

View File

@@ -1 +0,0 @@
This directory contains template files for the application at FQDN indidicated by the parent directory. They will be processed using mo (bash mustache).

View File

@@ -1 +0,0 @@
This directory contains final docker compose files for the application at FQDN indidicated by the parent directory.

View File

@@ -0,0 +1,69 @@
#!/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
# 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

View File

@@ -1 +0,0 @@
This directory contains files from the vendor unmodified. They serve as a base for the input-files sibling directory