Skip to content

ISSUE-287 Replace connexion[swagger-ui] dependency with dedicated swagger-ui container #291

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 19 additions & 25 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ services:
"docker_compose_diagram.icon": "nginx"
links:
- pgadmin4
- swagger_ui
- tagbase_server
networks:
- internal-network
Expand Down Expand Up @@ -100,31 +101,6 @@ services:
networks:
- internal-network
restart: unless-stopped
# postgres:
# build:
# context: ./services/postgres
# environment:
# - PGDATA=/var/lib/postgresql/data/pgdata
# - POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
# expose:
# - ${POSTGRES_PORT}
# healthcheck:
# test: ["CMD-SHELL", "pg_isready -d tagbase -h postgres -U tagbase"]
# interval: 15s
# timeout: 5s
# retries: 5
# start_period: 15s
# hostname: postgres
# labels:
# "docker_compose_diagram.cluster": "Internal Network"
# "docker_compose_diagram.description": "Tagbase PostgreSQL server"
# networks:
# - internal-network
# ports:
# - ${POSTGRES_PORT}:${POSTGRES_PORT}
# restart: unless-stopped
# volumes:
# - ./postgres-data:/var/lib/postgresql/data
postgis:
environment:
- ALLOW_IP_RANGE=0.0.0.0/0
Expand Down Expand Up @@ -167,6 +143,24 @@ services:
"docker_compose_diagram.icon": "docker"
volumes:
- /var/run/docker.sock:/var/run/docker.sock
swagger_ui:
environment:
- BASE_URL=/docs
- SWAGGER_JSON_URL=http://tagbase_server:5433/tagbase/api/v0.14.0/openapi.yaml
# expose:
# - 5431
image: swaggerapi/swagger-ui:v5.4.2
labels:
"docker_compose_diagram.cluster": "Internal Network"
"docker_compose_diagram.description": "REST API Docs"
"docker_compose_diagram.icon": "docker"
links:
- tagbase_server
networks:
- internal-network
ports:
- 5431:8080
restart: unless-stopped
tagbase_server:
build:
context: ./tagbase_server
Expand Down
10 changes: 8 additions & 2 deletions services/nginx/config/nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ http {
server tagbase_server:5433;
}

upstream swagger_ui {
server swagger_ui:5431;
}

# always redirect to https
server {
listen 81 default_server;
Expand All @@ -28,8 +32,9 @@ http {
}

server {
listen 443 ssl http2;
listen 443 ssl;
listen [::]:443 ssl;
http2 on;
ssl_certificate /etc/nginx/certs/cert.pem;
ssl_certificate_key /etc/nginx/certs/key.pem;

Expand All @@ -49,8 +54,9 @@ http {
}

location /docs {
proxy_pass http://tagbase_server/tagbase/api/v0.14.0/ui;
proxy_pass http://swagger_ui;
proxy_set_header Origin http://127.0.0.1;
proxy_set_header X-Forwarded-Path /docs;
proxy_hide_header Access-Control-Allow-Origin;
add_header Access-Control-Allow-Origin $http_origin;
}
Expand Down
2 changes: 1 addition & 1 deletion tagbase_server/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
connexion[swagger-ui]==2.14.2
connexion==2.14.2
flask[async]==2.2.5
flask-cors==4.0.0
gunicorn==21.2.0
Expand Down
6 changes: 2 additions & 4 deletions tagbase_server/tagbase_server/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,13 @@
logger.addHandler(rf_handler)

options = {
"swagger_ui_config": {
"url": "https://raw.githubusercontent.com/tagbase/tagbase-server/main/openapi.yaml"
}
"swagger_ui": False
}
app = connexion.App(__name__, specification_dir="./openapi/", options=options)
app.app.json_encoder = encoder.JSONEncoder
app.add_api(
"openapi.yaml",
arguments={"title": "tagbase-server API"},
arguments={"title": "tagbase-server REST API"},
pythonic_params=True,
strict_validation=True,
)
Expand Down