Gravitee.io docker-compose執行
阿新 • • 發佈:2018-12-30
Gravitee.io 官方提供的docker-compose 快速執行的方式
環境準備
- 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;
}
}
}
- 程式碼結構
執行&&效果
- 執行
docker-compose up -d
- 訪問地址
gateway http://localhost/am
gayeway manager api http://localhost/am/management
manager ui http://localhost/am/ui/ - 介面