Scenario 1: container install and update (all-in-one and per-component)
- Variant B: docker-compose.yml gets configurable host ports and health checks. Variant A: deploy/allinone image (nginx, supervisord, gunicorn, uvicorn, gatherer, OpenVPN) with an explicit database migration step before any service; docker-compose.allinone.yml. Same five volumes and paths in both variants. - deploy/docker: install.sh, update.sh (backup, build, stop, separate DB migration phase, start, automatic rollback), backup.sh, restore.sh, lib.sh. - Verified on Docker: install A/B, update with pre-versioned databases, rollback after an injected failure, backup/restore. - Docs: Scenario1_Containers guide, change summary, README, Index; .dockerignore, .gitignore additions. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
e556d6d4b9
commit
1c49d0b9c2
17 files changed
+1930
-50
No files matched your search
@@ -0,0 +1,70 @@
|
||||
# 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 named volumes
|
||||
RUN chmod +x /usr/local/bin/ovpmon-entrypoint.sh \
|
||||
&& mkdir -p /app/db /app/easy-rsa /app/client-config /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
|
||||
|
||||
EXPOSE 80
|
||||
EXPOSE 1194/udp
|
||||
|
||||
ENTRYPOINT ["/usr/local/bin/ovpmon-entrypoint.sh"]
|
||||
Reference in new issue
Block a user