Encrypted packages (databases, PKI, client profiles) with safe restore and a pre-restore safety copy, usable for server-to-server migration across container and system-service installs. New Management page, ovp_backups volume, migrations code in the profiler image, server name in package names. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
72 lines
3.1 KiB
Docker
72 lines
3.1 KiB
Docker
# OpenVPN Monitor & Profiler: ALL components in ONE container (scenario 1, variant A)
|
|
#
|
|
# Build context: the repository root (see docker-compose.allinone.yml):
|
|
# docker build -f deploy/allinone/Dockerfile .
|
|
#
|
|
# Processes (supervisord): nginx (UI + reverse proxy), gunicorn (monitoring API, APP_CORE),
|
|
# gatherer (APP_CORE), uvicorn (profiler API, APP_PROFILER). OpenVPN is started by the profiler
|
|
# API itself (direct start inside containers, see APP_PROFILER/services/process.py).
|
|
#
|
|
# Layout: code in /app/APP_CORE and /app/APP_PROFILER; data in the same volume paths as the
|
|
# per-component compose file: /app/db, /app/easy-rsa, /app/client-config, /etc/openvpn,
|
|
# /var/log/openvpn. The profiler runs with working directory /app, so its relative paths
|
|
# (easy-rsa, client-config) resolve to the volumes exactly as in variant B.
|
|
#
|
|
# Supported ENV: JWT_SECRET or OVPMON_API_SECRET_KEY (required), OVPMON_INITIAL_ADMIN_USER,
|
|
# OVPMON_INITIAL_ADMIN_PASSWORD, OVPMON_CORS_ORIGINS, OVPMON_* overrides of the components.
|
|
|
|
# Stage 1: build the UI
|
|
FROM node:20-alpine AS ui-build
|
|
WORKDIR /app
|
|
COPY APP_UI/package*.json ./
|
|
RUN npm install
|
|
COPY APP_UI/ ./
|
|
RUN npm run build
|
|
|
|
# Stage 2: runtime
|
|
FROM python:3.12-alpine
|
|
|
|
# openvpn/easy-rsa/iptables/iproute2: like APP_PROFILER/Dockerfile (OpenRC is not needed: direct start)
|
|
# nginx, supervisor: the process tree; gettext: envsubst for the nginx template
|
|
RUN apk add --no-cache openvpn easy-rsa iproute2 iptables bash nginx supervisor gettext \
|
|
&& (command -v envsubst >/dev/null || apk add --no-cache gettext-envsubst) \
|
|
&& command -v envsubst >/dev/null
|
|
|
|
WORKDIR /app
|
|
|
|
# Python dependencies of both components (+ gunicorn for the Flask API). Layers are cached
|
|
# until a requirements file changes.
|
|
COPY APP_CORE/requirements.txt /tmp/requirements-core.txt
|
|
COPY APP_PROFILER/requirements.txt /tmp/requirements-profiler.txt
|
|
RUN pip install --no-cache-dir -r /tmp/requirements-core.txt -r /tmp/requirements-profiler.txt gunicorn \
|
|
&& rm -f /tmp/requirements-*.txt
|
|
|
|
COPY APP_CORE /app/APP_CORE
|
|
COPY APP_PROFILER /app/APP_PROFILER
|
|
|
|
# UI and nginx: the template is rendered at container start (entrypoint.sh)
|
|
COPY --from=ui-build /app/dist /usr/share/nginx/html
|
|
COPY APP_UI/default.conf.template /etc/ovpmon/default.conf.template
|
|
RUN rm -f /etc/nginx/http.d/default.conf \
|
|
&& mkdir -p /run/nginx /var/log/nginx \
|
|
&& ln -sf /dev/stdout /var/log/nginx/access.log \
|
|
&& ln -sf /dev/stderr /var/log/nginx/error.log
|
|
|
|
COPY deploy/allinone/supervisord.conf /etc/supervisord.conf
|
|
COPY deploy/allinone/entrypoint.sh /usr/local/bin/ovpmon-entrypoint.sh
|
|
|
|
# Mount points of the five data volumes and of the backup packages volume (ovp_backups)
|
|
RUN chmod +x /usr/local/bin/ovpmon-entrypoint.sh \
|
|
&& mkdir -p /app/db /app/easy-rsa /app/client-config /app/backups /etc/openvpn /var/log/openvpn
|
|
|
|
# Default database locations (the compose file sets the same values)
|
|
ENV OVPMON_PROFILER_DB_PATH=/app/db/ovpn_profiler.db \
|
|
OVPMON_OPENVPN_MONITOR_DB_PATH=/app/db/openvpn_monitor.db \
|
|
OVPMON_OPENVPN_MONITOR_LOG_PATH=/var/log/openvpn/openvpn-status.log \
|
|
OVPMON_BACKUP_LOCAL_ROOT=/app/backups
|
|
|
|
EXPOSE 80
|
|
EXPOSE 1194/udp
|
|
|
|
ENTRYPOINT ["/usr/local/bin/ovpmon-entrypoint.sh"]
|