From 247934ba7c5cd40521851b83b1b4c3fe60782749 Mon Sep 17 00:00:00 2001 From: admin Date: Wed, 6 Aug 2025 04:09:21 +0300 Subject: [PATCH] add configuration files and update docker-compose for hydra and redis services --- config/back/.env.example | 2 ++ config/back/config.yaml | 10 +++++++ config/hydra/.env | 1 + config/hydra/hydra.yml | 12 ++++---- config/nginx/nginx.conf | 24 +++++++++++++-- docker-compose.yml | 65 ++++++++++++++++++++++++++++++++++------ traefik.yml | 28 +++++++++++++++++ 7 files changed, 124 insertions(+), 18 deletions(-) create mode 100644 config/back/.env.example create mode 100644 config/back/config.yaml create mode 100644 config/hydra/.env create mode 100644 traefik.yml diff --git a/config/back/.env.example b/config/back/.env.example new file mode 100644 index 0000000..629b199 --- /dev/null +++ b/config/back/.env.example @@ -0,0 +1,2 @@ +REDIS_PASSWORD= +HYDRA_PASSWORD= \ No newline at end of file diff --git a/config/back/config.yaml b/config/back/config.yaml new file mode 100644 index 0000000..e6447f2 --- /dev/null +++ b/config/back/config.yaml @@ -0,0 +1,10 @@ +app: + port: 8080 + +redis: + host: redis + port: 6379 + db: 0 + +hydra: + host: https://oauth2.logidex.ru/admin \ No newline at end of file diff --git a/config/hydra/.env b/config/hydra/.env new file mode 100644 index 0000000..432de45 --- /dev/null +++ b/config/hydra/.env @@ -0,0 +1 @@ +DSN=postgres://postgres:postgres@db:5432/hydra?sslmode=disable&max_conns=20&max_idle_conns=4 diff --git a/config/hydra/hydra.yml b/config/hydra/hydra.yml index 382863b..82a9449 100644 --- a/config/hydra/hydra.yml +++ b/config/hydra/hydra.yml @@ -4,12 +4,12 @@ serve: urls: self: - issuer: http://oauth2.logidex.ru - public: http://oauth2.logidex.ru - admin: http://oauth2.logidex.ru - consent: http://id.logidex.ru/consent - login: http://id.logidex.ru/ - logout: http://id.logidex.ru/logout + issuer: https://oauth2.logidex.ru + public: https://oauth2.logidex.ru + admin: https://oauth2.logidex.ru + consent: https://id.logidex.ru/consent + login: https://id.logidex.ru/login + logout: https://id.logidex.ru/logout strategies: access_token: jwt diff --git a/config/nginx/nginx.conf b/config/nginx/nginx.conf index ab00ab4..9811326 100644 --- a/config/nginx/nginx.conf +++ b/config/nginx/nginx.conf @@ -1,14 +1,15 @@ upstream hydra_public_api { server hydra:4444; - server hydra:4444; } upstream hydra_admin_api { server hydra:4445; - server hydra:4445; } upstream frontend { server front:3000; - server front:3000; +} + +upstream backend { + server back:8080; } server { @@ -51,6 +52,15 @@ server { listen 80; server_name id.logidex.ru; + location /api/ { + proxy_pass http://backend/api/; # Replace with your backend API URL + proxy_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection 'upgrade'; + proxy_set_header Host $host; + proxy_cache_bypass $http_upgrade; + } + location / { proxy_pass http://frontend; proxy_set_header Host $http_host; @@ -58,4 +68,12 @@ server { proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; } + location /_next/webpack-hmr { + proxy_pass http://frontend; + proxy_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection "upgrade"; + proxy_set_header Host $host; + } + } \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index cbae056..c10472b 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -10,8 +10,8 @@ services: target: /etc/config/hydra networks: - appnet - environment: - - DSN=postgres://postgres:GjitkeYf%5Beq@172.17.0.1:5432/hydra?sslmode=disable&max_conns=20&max_idle_conns=4 + env_file: + - ./config/hydra/.env hydra-migrate: image: oryd/hydra:v2.3.0 command: migrate -c /etc/config/hydra/hydra.yml sql up -e --yes @@ -21,28 +21,75 @@ services: target: /etc/config/hydra networks: - appnet - environment: - - DSN=postgres://postgres:GjitkeYf%5Beq@172.17.0.1:5432/hydra?sslmode=disable&max_conns=20&max_idle_conns=4 + env_file: + - ./config/hydra/.env + + depends_on: + - db nginx: + container_name: "logidexid" image: nginx:latest volumes: - type: bind source: ./config/nginx/nginx.conf target: /etc/nginx/conf.d/default.conf read_only: true - ports: - - "80:80" - - "443:443" + labels: + - "traefik.enable=true" depends_on: - - hydra - front + - back + - hydra networks: - appnet + ports: + - "80:80" front: image: git.logidex.ru/aserbin/logidex-id-frontend:latest environment: - NODE_ENV=production networks: - appnet + back: + image: git.logidex.ru/fakz9/id-backend:latest + depends_on: + redis: + condition: service_healthy + networks: + - appnet + volumes: + - ./config/back/.env:/app/.env + - ./config/back/config.yaml:/app/config.yaml + redis: + image: redis + command: [ "redis-server", "--save", "60", "1", "--appendonly", "no" ] + volumes: + - redis_data:/data + networks: + - appnet + healthcheck: + test: [ "CMD" ,"redis-cli", "ping" ] + interval: 5s + timeout: 2s + retries: 5 + db: + image: postgres:17-alpine + restart: unless-stopped + environment: + POSTGRES_USER: postgres + POSTGRES_PASSWORD: postgres + POSTGRES_DB: hydra + volumes: + - db:/var/lib/postgresql/data + networks: + - appnet networks: - appnet: \ No newline at end of file + appnet: + external: false +# proxy: +# external: true + +volumes: + redis_data: + db: + driver: local diff --git a/traefik.yml b/traefik.yml new file mode 100644 index 0000000..845a5c5 --- /dev/null +++ b/traefik.yml @@ -0,0 +1,28 @@ +http: + routers: + id-app: + rule: "Host(`id.logidex.ru`)" + entryPoints: + - websecure + service: id-app + tls: + certResolver: default + + oauth2-app: + rule: "Host(`oauth2.logidex.ru`)" + entryPoints: + - websecure + service: oauth2-app + tls: + certResolver: default + + services: + id-app: + loadBalancer: + servers: + - url: "http://logidexid:80" # имя контейнера с NGINX внутри + + oauth2-app: + loadBalancer: + servers: + - url: "http://logidexid:80" # имя контейнера с NGINX внутри