fix docker deployment

This commit is contained in:
Alberto-Audrix committed 2026-09-11 14:48:18 +07:00
1 parent ded52d1ece
commit fb0f996776
17 files changed
+49 -18

No files matched your search

+3
View File
@@ -13,6 +13,9 @@ ALLOWED_HOSTS=localhost,127.0.0.1,api,frontend,executive.local
CSRF_TRUSTED_ORIGINS=http://localhost,http://127.0.0.1,http://executive.local
CORS_ALLOWED_ORIGINS=http://localhost,http://127.0.0.1,http://executive.local
# Host port for the UI (default 80). Use 8080 if :80 is already taken.
FRONTEND_PORT=80
# Production admin (bootstrap_admin — no demo data)
BOOTSTRAP_ADMIN_USER=admin
BOOTSTRAP_ADMIN_PASSWORD=Pr04dm1n
+3 -1
View File
@@ -22,10 +22,12 @@ COPY backend/ .
COPY docker/entrypoint-api.sh docker/entrypoint-cron.sh docker/karung_sync_loop.sh /app/
COPY docker/crontab /etc/cron.d/executive
# /etc/cron.d files include a username field; system cron reads them directly
# (do not install with `crontab`, which expects user-crontab format).
RUN chmod +x /app/entrypoint-api.sh /app/entrypoint-cron.sh /app/karung_sync_loop.sh \
&& mkdir -p /app/data /app/media /app/staticfiles \
&& chmod 0644 /etc/cron.d/executive \
&& crontab /etc/cron.d/executive
&& touch /var/log/cron.log
EXPOSE 8000
+1 -1
View File
@@ -20,6 +20,6 @@ COPY docker/nginx.conf /etc/nginx/conf.d/default.conf
EXPOSE 80
HEALTHCHECK --interval=30s --timeout=3s --start-period=10s --retries=3 \
CMD wget --quiet --tries=1 --spider http://localhost:80/health || exit 1
CMD wget --quiet --tries=1 --spider http://127.0.0.1:80/health || exit 1
CMD ["nginx", "-g", "daemon off;"]
+3 -1
View File
@@ -7,6 +7,7 @@ printenv | grep -E '^(PATH|DJANGO_|SECRET_|DB_|KARUNG_|IOT_|CHICKEN_COUNTING_|DA
# Render publish-time cron from DASHBOARD_PUBLISH_* (default 17:00).
# Edge syncs are OFF by default at HQ (mirror via city-sites); commands no-op when disabled.
# File lives in /etc/cron.d (requires username field) — do not feed it to `crontab`.
PUBLISH_HOUR="${DASHBOARD_PUBLISH_HOUR:-17}"
PUBLISH_MINUTE="${DASHBOARD_PUBLISH_MINUTE:-0}"
CRON_FILE=/etc/cron.d/executive
@@ -20,9 +21,10 @@ CRON_FILE=/etc/cron.d/executive
echo ""
echo "# Daily publish — optional karung sync then KPI rollups at configured cutoff."
echo "${PUBLISH_MINUTE} ${PUBLISH_HOUR} * * * root cd /app && /usr/local/bin/python manage.py sync_karung_from_web_admin >> /var/log/cron.log 2>&1 && /usr/local/bin/python manage.py recompute_kpi_rollups >> /var/log/cron.log 2>&1"
echo ""
} > "$CRON_FILE"
chmod 0644 "$CRON_FILE"
crontab "$CRON_FILE"
touch /var/log/cron.log
if [ "${KARUNG_WEB_ADMIN_SYNC_ENABLED:-false}" = "true" ] || [ "${KARUNG_WEB_ADMIN_SYNC_ENABLED:-false}" = "True" ]; then
/app/karung_sync_loop.sh &