sync for dev 033026
This commit is contained in:
91
files/docker/Dockerfile
Normal file
91
files/docker/Dockerfile
Normal file
@ -0,0 +1,91 @@
|
||||
# ------------------------------------------------------------------
|
||||
# 1. Base image
|
||||
# ------------------------------------------------------------------
|
||||
# We use a slim Debian base so we can use apt‑get to pull every
|
||||
# component in one go. Debian Bookworm contains all the
|
||||
# packages we need (nodejs 18, redis, nginx, php8‑fpm, 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
|
||||
|
||||
ENV REDIS_PORT=${REDIS_PORT}
|
||||
ENV NODE_PORT=${NODE_PORT}
|
||||
ENV PHP_PORT=${PHP_PORT}
|
||||
ENV NGX_PORT=${NGX_PORT}
|
||||
|
||||
# ------------------------------------------------------------------
|
||||
# 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/*
|
||||
|
||||
# ------------------------------------------------------------------
|
||||
# 4. Prepare the working directories
|
||||
# ------------------------------------------------------------------
|
||||
# Node app
|
||||
WORKDIR /app
|
||||
COPY web/node_server/package.json ./
|
||||
RUN npm install
|
||||
COPY web/node_server/ ./
|
||||
|
||||
# Web‑dashboard static files
|
||||
COPY web/html /var/www/html/
|
||||
|
||||
# API settings 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
|
||||
|
||||
# ------------------------------------------------------------------
|
||||
# 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
|
||||
|
||||
[program:redis]
|
||||
command=/usr/bin/redis-server --port ${REDIS_PORT}
|
||||
autostart=true
|
||||
autorestart=true
|
||||
user=root
|
||||
|
||||
[program:node]
|
||||
command=npm run start
|
||||
autostart=true
|
||||
autorestart=true
|
||||
user=root
|
||||
|
||||
[program:nginx]
|
||||
command=/usr/sbin/nginx -g 'daemon off;'
|
||||
autostart=true
|
||||
autorestart=true
|
||||
user=root
|
||||
EOF
|
||||
|
||||
# ------------------------------------------------------------------
|
||||
# 6. Expose the ports
|
||||
# ------------------------------------------------------------------
|
||||
EXPOSE ${REDIS_PORT} ${NGX_PORT}
|
||||
|
||||
# 7. Default command – start supervisord
|
||||
CMD ["supervisord", "-c", "/etc/supervisor/conf.d/supervisord.conf"]
|
||||
48
files/docker/Dockerfile-1
Normal file
48
files/docker/Dockerfile-1
Normal file
@ -0,0 +1,48 @@
|
||||
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"]
|
||||
|
||||
|
||||
6
files/docker/entrypoint.sh
Normal file
6
files/docker/entrypoint.sh
Normal file
@ -0,0 +1,6 @@
|
||||
#!/bin/sh
|
||||
# Ensure the shared config file is readable
|
||||
chmod 644 /app/cosmostat_settings.yaml
|
||||
|
||||
# Let Supervisor do the heavy lifting
|
||||
exec "$@"
|
||||
22
files/docker/supervisord.conf
Normal file
22
files/docker/supervisord.conf
Normal file
@ -0,0 +1,22 @@
|
||||
[supervisord]
|
||||
nodaemon=true
|
||||
|
||||
[program:redis]
|
||||
command=/usr/bin/redis-server
|
||||
stdout_logfile=/dev/stdout
|
||||
stderr_logfile=/dev/stderr
|
||||
|
||||
[program:node]
|
||||
command=sh -c "cd /app && node server.js"
|
||||
stdout_logfile=/dev/stdout
|
||||
stderr_logfile=/dev/stderr
|
||||
|
||||
[program:apache]
|
||||
command=/usr/sbin/httpd -DFOREGROUND
|
||||
stdout_logfile=/dev/stdout
|
||||
stderr_logfile=/dev/stderr
|
||||
|
||||
[program:nginx]
|
||||
command=nginx -g "daemon off;"
|
||||
stdout_logfile=/dev/stdout
|
||||
stderr_logfile=/dev/stderr
|
||||
Reference in New Issue
Block a user