FROM odoo:18.0

USER root

# Copy requirements and install Python dependencies
COPY requirements.txt /tmp/requirements.txt
RUN pip3 install --break-system-packages --no-cache-dir --ignore-installed typing-extensions -r /tmp/requirements.txt

# Copy production configuration
COPY ./config/odoo.prod.conf /etc/odoo/odoo.conf

# Фиксим права на /var/lib/odoo для корректной работы assets
RUN chown -R odoo:odoo /var/lib/odoo && \
    chmod -R u+w /var/lib/odoo

# Copy entrypoint script
COPY ./entrypoint.py /entrypoint.py

# Copy addons
COPY ./addons /mnt/extra-addons
RUN chown -R odoo:odoo /mnt/extra-addons

USER odoo

# Use Python SDK to load secrets and start Odoo
CMD ["python3", "/entrypoint.py"]
