cosmostat active host inventory file api

This commit is contained in:
2026-04-04 17:47:32 -07:00
parent be95ab7593
commit a89703c420
26 changed files with 1243 additions and 261 deletions

View File

@ -1,91 +1,47 @@
# ------------------------------------------------------------------
# 1. Base image
# ------------------------------------------------------------------
# We use a slim Debian base so we can use aptget to pull every
# component in one go. Debian Bookworm contains all the
# packages we need (nodejs 18, redis, nginx, php8fpm, etc.).
# ------------------------------------------------------------------
FROM php:8.0-apache
# ------------------------------------------------------------------
# 2. Build arguments handy if you want to change the port numbers
# without touching the Dockerfile
# ------------------------------------------------------------------
ARG REDIS_PORT=6379
ARG NODE_PORT=3000
ARG PHP_PORT=8080
ARG NGX_PORT=80
# Base image
FROM php:8.1-apache
ENV REDIS_PORT=${REDIS_PORT}
ENV NODE_PORT=${NODE_PORT}
ENV PHP_PORT=${PHP_PORT}
ENV NGX_PORT=${NGX_PORT}
# Install system packages
RUN apt-get update && apt-get install -y --no-install-recommends \
# Services
redis-server nginx \
# Process supervisor
supervisor \
# Clean up
&& rm -rf /var/lib/apt/lists/*
# ------------------------------------------------------------------
# 3. Install all the system packages we need
# ------------------------------------------------------------------
RUN apt-get update && \
DEBIAN_FRONTEND=noninteractive apt-get install -y \
curl gnupg ca-certificates \
nodejs npm \
redis-server \
nginx \
supervisor \
&& apt-get clean && rm -rf /var/lib/apt/lists/*
# Install Node.js LTS 18.x
RUN curl -fsSL https://deb.nodesource.com/setup_18.x | bash - \
&& apt-get update && apt-get install -y nodejs \
&& rm -rf /var/lib/apt/lists/*
# ------------------------------------------------------------------
# 4. Prepare the working directories
# ------------------------------------------------------------------
# Node app
WORKDIR /app
COPY web/node_server/package.json ./
RUN npm install
COPY web/node_server/ ./
# Webdashboard static files
COPY web/html /var/www/html/
# API settings file
# copy the config file
COPY cosmostat_settings.yaml /app/cosmostat_settings.yaml
# Nginx config you can keep the same file you used for the
# proxy service in the compose file. It will proxy 3000 (WS)
# and 8080 (PHP) to the local container.
COPY web/proxy/nginx.conf /etc/nginx/nginx.conf
# Node on 3000
WORKDIR /usr/src/app
COPY web/node_server/ .
RUN npm install --only=production
# ------------------------------------------------------------------
# 5. Supervisord configuration
# ------------------------------------------------------------------
# Create a minimal supervisord.conf that will launch the four
# services from the same container.
RUN mkdir -p /etc/supervisor/conf.d && \
cat > /etc/supervisor/conf.d/supervisord.conf <<EOF
[supervisord]
nodaemon=true
# Apache on 8080
RUN sed -i 's/^Listen .*/Listen 8080/' /etc/apache2/ports.conf && \
sed -i 's/<VirtualHost \*:80>/<VirtualHost \*:8080>/' /etc/apache2/sites-enabled/000-default.conf
COPY web/html/ /var/www/html/
[program:redis]
command=/usr/bin/redis-server --port ${REDIS_PORT}
autostart=true
autorestart=true
user=root
# nginx on 80
RUN rm -rf /etc/nginx/sites-enabled/default
COPY web/proxy/nginx.conf /etc/nginx/conf.d/default.conf
[program:node]
command=npm run start
autostart=true
autorestart=true
user=root
# Add supervisord configuration
COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf
[program:nginx]
command=/usr/sbin/nginx -g 'daemon off;'
autostart=true
autorestart=true
user=root
EOF
# Expose ports
EXPOSE 80
EXPOSE 6379
# ------------------------------------------------------------------
# 6. Expose the ports
# ------------------------------------------------------------------
EXPOSE ${REDIS_PORT} ${NGX_PORT}
# healthcheck looks for apache
HEALTHCHECK CMD netstat -ltn | grep -c ":8080" > /dev/null; if [ 0 != $? ]; then exit 1; fi;
# 7. Default command start supervisord
CMD ["supervisord", "-c", "/etc/supervisor/conf.d/supervisord.conf"]
# Start supervisord
CMD ["/usr/bin/supervisord", "-c", "/etc/supervisor/conf.d/supervisord.conf"]