Gravitee.io Access Management docker-compose运行

时间:2023-02-03 20:57:00

Gravitee.io 官方提供的docker-compose 快速运行的方式

默认ui 账户 admin adminadmin

环境准备

  • docker-compose 文件
#
# Copyright (C) 2015 The Gravitee team (http://gravitee.io)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
version: '2'
volumes:
  datamongo: {}
services:
  nginx:
    image: nginx:1.15-alpine
    container_name: gio_am_nginx
    restart: always
    volumes:
      - ./config/nginx.conf:/etc/nginx/nginx.conf
    ports:
      - ${NGINX_PORT}:80
    depends_on:
      - management
      - gateway
      - webui
  mongodb:
    image: mongo:3.4
    container_name: gio_am_mongodb
    restart: always
    volumes:
      - datamongo:/data/db
      - ./logs/am-mongodb:/var/log/mongodb
  gateway:
    image: graviteeio/am-gateway:${GIO_AM_VERSION}
    container_name: gio_am_gateway
    restart: always
    links:
      - mongodb
    depends_on:
      - mongodb
    volumes:
      - ./logs/am-gateway:/etc/gravitee.io/log
    environment:
      - gravitee_management_mongodb_uri=mongodb://mongodb:27017/graviteeam?serverSelectionTimeoutMS=5000&connectTimeoutMS=5000&socketTimeoutMS=5000
      - gravitee_oauth2_mongodb_uri=mongodb://mongodb:27017/graviteeam?serverSelectionTimeoutMS=5000&connectTimeoutMS=5000&socketTimeoutMS=5000
  management:
    image: graviteeio/am-management-api:${GIO_AM_VERSION}
    container_name: gio_am_management
    restart: always
    links:
      - mongodb
    depends_on:
      - mongodb
    volumes:
      - ./logs/am-management-api:/etc/gravitee.io/log
    environment:
      - gravitee_management_mongodb_uri=mongodb://mongodb:27017/graviteeam?serverSelectionTimeoutMS=5000&connectTimeoutMS=5000&socketTimeoutMS=5000
      - gravitee_oauth2_mongodb_uri=mongodb://mongodb:27017/graviteeam?serverSelectionTimeoutMS=5000&connectTimeoutMS=5000&socketTimeoutMS=5000
  webui:
    image: graviteeio/am-management-ui:${GIO_AM_VERSION}
    container_name: gio_am_webui
    restart: always
    depends_on:
      - management
    environment:
      - MGMT_API_URL=http://localhost:${NGINX_PORT}/am/
      - MGMT_UI_URL=http://localhost:${NGINX_PORT}/am/ui/
    volumes:
      - ./logs/am-webui:/var/log/httpd
 
 
  • env 文件(系统运行的变量配置)
GIO_AM_VERSION=2
NGINX_PORT=80
  • nginx.conf ( nginx proxy 的配置)
worker_processes 4;
events { worker_connections 1024; }
http {
        include /etc/nginx/mime.types;
        resolver 127.0.0.11 ipv6=off;
        upstream management {
            server management:8093;
        }
        upstream gateway {
            server gateway:8092;
        }
        upstream webui {
            server webui:80;
        }
        server {
            listen 80;
              location /am/ui/ {
                    proxy_pass http://webui/;
                    proxy_set_header Host $host;
                    proxy_set_header X-Real-IP $remote_addr;
                    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                    proxy_set_header X-Forwarded-Host $server_name;
                    sub_filter '<base href="/"' '<base href="/am/ui/"';
                    sub_filter_once on;
              }
              location /am/management/ {
                    proxy_pass http://management/management/;
                    proxy_redirect http://$host:$server_port/am/ui/ /am/ui/;
                    proxy_redirect http://$host:$server_port/management/ /am/management/;
                    proxy_cookie_path /management /am/management;
                    proxy_set_header Host $host;
                    proxy_set_header X-Real-IP $remote_addr;
                    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                    proxy_set_header X-Forwarded-Host $server_name;
              }
              location /am/admin/ {
                    proxy_pass http://management/admin/;
                    proxy_redirect http://$http_host/admin/ http://$http_host/am/admin/;
                    proxy_cookie_path /admin /am/admin;
                    proxy_set_header Host $http_host;
                    proxy_set_header X-Real-IP $remote_addr;
                    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                    proxy_set_header X-Forwarded-Host $server_name;
              }
              location /am/ {
                    proxy_pass http://gateway/;
                    proxy_set_header Host $host;
                    proxy_set_header X-Real-IP $remote_addr;
                    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                    proxy_set_header X-Forwarded-Host $server_name;
                    proxy_set_header X-Forwarded-Prefix /am;
              }
              error_page 500 502 503 504 /50x.html;
              location = /50x.html {
                    root /usr/share/nginx/html;
              }
        }
}
 
 
  • 代码结构
    Gravitee.io  Access Management  docker-compose运行

运行&&效果

  • 运行
 
docker-compose up -d 

参考资料

https://docs.gravitee.io/am/2.x/am_installguide_docker.html