docker support
This commit is contained in:
16
APP_CORE/Dockerfile.api
Normal file
16
APP_CORE/Dockerfile.api
Normal file
@@ -0,0 +1,16 @@
|
||||
FROM python:3.12-alpine
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# Install dependencies
|
||||
COPY requirements.txt .
|
||||
RUN pip install --no-cache-dir -r requirements.txt
|
||||
|
||||
# Copy source code
|
||||
COPY . .
|
||||
|
||||
# Expose the port
|
||||
EXPOSE 5001
|
||||
|
||||
# Run the API
|
||||
CMD ["python", "openvpn_api_v3.py"]
|
||||
13
APP_CORE/Dockerfile.gatherer
Normal file
13
APP_CORE/Dockerfile.gatherer
Normal file
@@ -0,0 +1,13 @@
|
||||
FROM python:3.12-alpine
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# Install dependencies
|
||||
COPY requirements.txt .
|
||||
RUN pip install --no-cache-dir -r requirements.txt
|
||||
|
||||
# Copy source code
|
||||
COPY . .
|
||||
|
||||
# Run the gatherer
|
||||
CMD ["python", "openvpn_gatherer_v3.py"]
|
||||
21
APP_PROFILER/Dockerfile
Normal file
21
APP_PROFILER/Dockerfile
Normal file
@@ -0,0 +1,21 @@
|
||||
FROM python:3.12-alpine
|
||||
|
||||
# Install OpenVPN, OpenRC and other system deps
|
||||
RUN apk add --no-cache openvpn openrc iproute2 bash
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# Install Python dependencies
|
||||
COPY requirements.txt .
|
||||
RUN pip install --no-cache-dir -r requirements.txt
|
||||
|
||||
# Copy source code and entrypoint
|
||||
COPY . .
|
||||
RUN chmod +x entrypoint.sh
|
||||
|
||||
# Expose API port
|
||||
EXPOSE 8000
|
||||
# Expose OpenVPN port (default 1194 UDP)
|
||||
EXPOSE 1194/udp
|
||||
|
||||
ENTRYPOINT ["./entrypoint.sh"]
|
||||
20
APP_PROFILER/entrypoint.sh
Normal file
20
APP_PROFILER/entrypoint.sh
Normal file
@@ -0,0 +1,20 @@
|
||||
#!/bin/sh
|
||||
|
||||
# EnsureTUN device exists
|
||||
if [ ! -c /dev/net/tun ]; then
|
||||
mkdir -p /dev/net
|
||||
mknod /dev/net/tun c 10 200
|
||||
chmod 600 /dev/net/tun
|
||||
fi
|
||||
|
||||
# Enable IP forwarding
|
||||
sysctl -w net.ipv4.ip_forward=1
|
||||
|
||||
# Start OpenRC (needed for rc-service if we use it, but better to start openvpn directly or via rc)
|
||||
# Since we are in Alpine, we can try to start the service if configured,
|
||||
# but Container 4 main.py might expect rc-service to work.
|
||||
openrc default
|
||||
|
||||
# Start the APP_PROFILER API
|
||||
# We use 0.0.0.0 to be reachable from other containers
|
||||
python main.py
|
||||
6
APP_PROFILER/requirements.txt
Normal file
6
APP_PROFILER/requirements.txt
Normal file
@@ -0,0 +1,6 @@
|
||||
fastapi
|
||||
uvicorn
|
||||
sqlalchemy
|
||||
psutil
|
||||
python-multipart
|
||||
jinja2
|
||||
14
APP_UI/Dockerfile
Normal file
14
APP_UI/Dockerfile
Normal file
@@ -0,0 +1,14 @@
|
||||
# Stage 1: Build
|
||||
FROM node:20-alpine AS build-stage
|
||||
WORKDIR /app
|
||||
COPY package*.json ./
|
||||
RUN npm install
|
||||
COPY . .
|
||||
RUN npm run build
|
||||
|
||||
# Stage 2: Serve
|
||||
FROM nginx:alpine
|
||||
COPY --from=build-stage /app/dist /usr/share/nginx/html
|
||||
COPY nginx.conf /etc/nginx/conf.d/default.conf
|
||||
EXPOSE 80
|
||||
CMD ["nginx", "-g", "daemon off;"]
|
||||
25
APP_UI/nginx.conf
Normal file
25
APP_UI/nginx.conf
Normal file
@@ -0,0 +1,25 @@
|
||||
server {
|
||||
listen 80;
|
||||
server_name localhost;
|
||||
|
||||
root /usr/share/nginx/html;
|
||||
index index.html;
|
||||
|
||||
location / {
|
||||
try_files $uri $uri/ /index.html;
|
||||
}
|
||||
|
||||
# Proxy API requests if needed or let the frontend handle URLs
|
||||
# location /api/v1/ {
|
||||
# proxy_pass http://app-api:5001;
|
||||
# }
|
||||
|
||||
# location /api/ {
|
||||
# proxy_pass http://app-profiler:8000;
|
||||
# }
|
||||
|
||||
error_page 500 502 503 504 /50x.html;
|
||||
location = /50x.html {
|
||||
root /usr/share/nginx/html;
|
||||
}
|
||||
}
|
||||
67
docker-compose.yml
Normal file
67
docker-compose.yml
Normal file
@@ -0,0 +1,67 @@
|
||||
version: '3.8'
|
||||
|
||||
services:
|
||||
app-ui:
|
||||
build: ./APP_UI
|
||||
container_name: ovp-ui
|
||||
ports:
|
||||
- "80:80"
|
||||
depends_on:
|
||||
- app-api
|
||||
- app-profiler
|
||||
networks:
|
||||
- ovp-net
|
||||
|
||||
app-gatherer:
|
||||
build:
|
||||
context: ./APP_CORE
|
||||
dockerfile: Dockerfile.gatherer
|
||||
container_name: ovp-gatherer
|
||||
volumes:
|
||||
- ovp_logs:/var/log/openvpn
|
||||
- db_data:/app/db # Assuming APP_CORE looks for DB in /app/db
|
||||
depends_on:
|
||||
- app-profiler
|
||||
networks:
|
||||
- ovp-net
|
||||
|
||||
app-api:
|
||||
build:
|
||||
context: ./APP_CORE
|
||||
dockerfile: Dockerfile.api
|
||||
container_name: ovp-api
|
||||
ports:
|
||||
- "5001:5001"
|
||||
volumes:
|
||||
- db_data:/app/db
|
||||
networks:
|
||||
- ovp-net
|
||||
environment:
|
||||
- JWT_SECRET=${JWT_SECRET:-supersecret}
|
||||
|
||||
app-profiler:
|
||||
build: ./APP_PROFILER
|
||||
container_name: ovp-profiler
|
||||
cap_add:
|
||||
- NET_ADMIN
|
||||
devices:
|
||||
- "/dev/net/tun:/dev/net/tun"
|
||||
ports:
|
||||
- "8000:8000"
|
||||
- "1194:1194/udp"
|
||||
volumes:
|
||||
- ovp_logs:/var/log/openvpn
|
||||
- ovp_config:/etc/openvpn
|
||||
networks:
|
||||
- ovp-net
|
||||
environment:
|
||||
- JWT_SECRET=${JWT_SECRET:-supersecret}
|
||||
|
||||
networks:
|
||||
ovp-net:
|
||||
driver: bridge
|
||||
|
||||
volumes:
|
||||
ovp_logs:
|
||||
ovp_config:
|
||||
db_data:
|
||||
Reference in New Issue
Block a user