From e4984dd29db879fb14cc385bd2e7c5dae1609ee2 Mon Sep 17 00:00:00 2001 From: Ultradesu Date: Mon, 29 Sep 2025 11:19:11 +0100 Subject: [PATCH] Added docker-compose --- Dockerfile | 45 +++++++++++++++++++++++++++++++++++++++++++++ config.docker.toml | 17 +++++++++++++++++ docker-compose.yml | 45 +++++++++++++++++++++++++++++++++++++++++++++ xray-config.json | 34 ++++++++++++++++++++++++++++++++++ 4 files changed, 141 insertions(+) create mode 100644 Dockerfile create mode 100644 config.docker.toml create mode 100644 docker-compose.yml create mode 100644 xray-config.json diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..591fd9c --- /dev/null +++ b/Dockerfile @@ -0,0 +1,45 @@ +# Build stage +FROM rust:latest as builder + +WORKDIR /app + +# Install system dependencies +RUN apt-get update && apt-get install -y \ + pkg-config \ + libssl-dev \ + protobuf-compiler \ + && rm -rf /var/lib/apt/lists/* + +# Copy dependency files +COPY Cargo.toml Cargo.lock ./ + +# Copy source code +COPY src ./src +COPY static ./static + +# Build the application +RUN cargo build --release + +# Runtime stage +FROM ubuntu:24.04 + +WORKDIR /app + +# Install runtime dependencies +RUN apt-get update && apt-get install -y \ + ca-certificates \ + libssl3 \ + && rm -rf /var/lib/apt/lists/* + +# Copy the binary from builder +COPY --from=builder /app/target/release/xray-admin /app/xray-admin + +# Copy static files +COPY --from=builder /app/static ./static + +# Copy config file +COPY config.docker.toml ./config.toml + +EXPOSE 8081 + +CMD ["/app/xray-admin", "--host", "0.0.0.0"] diff --git a/config.docker.toml b/config.docker.toml new file mode 100644 index 0000000..af4245d --- /dev/null +++ b/config.docker.toml @@ -0,0 +1,17 @@ +[database] +url = "postgres://postgres:postgres@postgres:5432/outfleet" + +[web] +host = "0.0.0.0" +port = 8081 + +[telegram] +enabled = false +admin_chat_ids = [] +allowed_users = [] + +[xray] +config_path = "./templates" + +[log] +level = "debug" diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..d727cd2 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,45 @@ +services: + admin: + build: + context: . + dockerfile: Dockerfile + container_name: outfleet-admin + ports: + - "8081:8081" + environment: + - DATABASE_URL=postgres://postgres:postgres@postgres:5432/outfleet + - RUST_LOG=info + - XRAY_ADMIN__WEB__PORT=8081 + depends_on: + postgres: + condition: service_healthy + + postgres: + image: postgres:15 + container_name: postgres + environment: + POSTGRES_USER: postgres + POSTGRES_PASSWORD: postgres + POSTGRES_DB: outfleet + ports: + - "5432:5432" + volumes: + - postgres_data:/var/lib/postgresql/data + healthcheck: + test: ["CMD-SHELL", "pg_isready -U postgres"] + interval: 10s + timeout: 5s + retries: 5 + + xray: + image: teddysun/xray:25.8.3 + container_name: xray-server + ports: + - "10085:10085" + volumes: + - ./xray-config.json:/etc/xray/config.json + command: ["xray", "-c", "/etc/xray/config.json"] + restart: unless-stopped + +volumes: + postgres_data: diff --git a/xray-config.json b/xray-config.json new file mode 100644 index 0000000..c35298d --- /dev/null +++ b/xray-config.json @@ -0,0 +1,34 @@ +{ + "log": { + "loglevel": "info" + }, + "api": { + "tag": "api", + "listen": "0.0.0.0:10085", + "services": [ + "HandlerService", + "LoggerService", + "StatsService" + ] + }, + "stats": {}, + "policy": { + "system": { + "statsInboundDownlink": true, + "statsInboundUplink": true, + "statsOutboundDownlink": true, + "statsOutboundUplink": true + } + }, + "inbounds": [], + "outbounds": [ + { + "tag": "direct", + "protocol": "freedom", + "settings": {} + } + ], + "routing": { + "rules": [] + } +}