FROM php:8.0-apache

RUN set -eux; \
    apt-get update && apt-get install -y --no-install-recommends \
        ca-certificates \
        gnupg \
        lsb-release \
        wget \
        curl \
        sudo \
        redis-server \
        nginx \
        supervisor \
        && curl -fsSL https://deb.nodesource.com/setup_18.x | bash - \
        && apt-get install -y --no-install-recommends nodejs \
        && rm -rf /var/lib/apt/lists/*

WORKDIR /app

# Node application
COPY web/node_server/ .
RUN npm install --only=production

#RUN npm ci --production

# PHP static files (public web root)
COPY web/html/ /var/www/html/

# NGINX config (overwrites the default)
COPY web/proxy/nginx.conf /etc/nginx/conf.d/default.conf

# Shared settings file (read‑only)
COPY cosmostat_settings.yaml /app/cosmostat_settings.yaml

# Supervisor configuration
COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf

# Entrypoint script
COPY entrypoint.sh /usr/local/bin/entrypoint.sh
RUN chmod +x /usr/local/bin/entrypoint.sh

EXPOSE 6379
EXPOSE 80

ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]
CMD ["supervisord", "-c", "/etc/supervisor/conf.d/supervisord.conf"]


