Build [v.1.3.9]

This commit is contained in:
Daniel Bedeleanu
2026-04-12 07:29:58 +03:00
parent 38e9428109
commit 161a182281
13 changed files with 142 additions and 24 deletions

View File

@@ -19,6 +19,9 @@ RUN adduser --system --group appuser
# Copy application files
COPY backend ./backend
# Copy initialization scripts (shared with start_server.sh)
COPY scripts ./scripts
# We define the data dir explicitly for Docker
ENV DATA_DIR="/app/data"
ENV LOGS_DIR="/app/logs"
@@ -27,9 +30,12 @@ ENV LOGS_DIR="/app/logs"
# although Docker volumes will handle ownership context.
RUN mkdir -p /app/data /app/logs && chown -R appuser:appuser /app
# Make initialization scripts executable
RUN chmod +x /app/scripts/init_data.sh /app/backend/entrypoint.sh
USER appuser
EXPOSE 8000
# Start Uvicorn pointing to the backend module
CMD ["python", "-m", "uvicorn", "backend.main:app", "--host", "0.0.0.0", "--port", "8000"]
# Entrypoint runs init_data.sh first, then starts uvicorn
ENTRYPOINT ["/app/backend/entrypoint.sh"]

28
backend/entrypoint.sh Executable file
View File

@@ -0,0 +1,28 @@
#!/bin/bash
# =============================================================================
# backend/entrypoint.sh
# =============================================================================
# Docker container entrypoint for TFM aInventory backend.
# Runs first-run initialization then starts the application server.
#
# This script is the ENTRYPOINT defined in backend/Dockerfile.
# DATA_DIR and LOGS_DIR are set via docker-compose.yml environment section.
# =============================================================================
set -euo pipefail
echo "🐳 [Docker] Backend container starting..."
echo "🐳 [Docker] DATA_DIR=${DATA_DIR:-/app/data}"
echo "🐳 [Docker] LOGS_DIR=${LOGS_DIR:-/app/logs}"
# Export defaults if not already set by docker-compose
export DATA_DIR="${DATA_DIR:-/app/data}"
export LOGS_DIR="${LOGS_DIR:-/app/logs}"
# Run shared first-run initialization
echo "🐳 [Docker] Running data initialization..."
bash /app/scripts/init_data.sh
# Hand off to the application server
echo "🐳 [Docker] Starting uvicorn..."
exec python -m uvicorn backend.main:app --host 0.0.0.0 --port 8000

View File

@@ -1 +0,0 @@
{"ldap_enabled": true, "server_uri": "ldap://192.168.84.107:3890", "base_dn": "dc=example,dc=com", "user_template": "cn={username},ou=people,dc=example,dc=com", "groups_dn": "ou=groups", "use_tls": false, "role_mappings": [{"group": "inventory_admins", "role": "admin"}, {"group": "inventory_users", "role": "user"}]}