Skip to content
Snippets Groups Projects
Verified Commit e960dfb7 authored by TheJoeCoder's avatar TheJoeCoder
Browse files

Update demo

parent b835875d
Branches
No related tags found
No related merge requests found
......@@ -7,6 +7,7 @@ services:
- OPENSEARCH_USERNAME=admin
- OPENSEARCH_PASSWORD=VeryInsecurePassword1!
- SECRET_KEY=VeryInsecureSecretKey
- GOOGLEAPIS_BASE_URL=http://www.googleapis.com # Downgrade the base URL to HTTP, so we can proxy it
volumes:
- demo_static:/home/app/web/staticfiles
- ./demo_media:/home/app/web/mediafiles
......@@ -16,7 +17,9 @@ services:
depends_on:
- opensearch
networks:
- librarydemo
- librarydemo-internal
links:
- nginx-googleapisproxy:www.googleapis.com
opensearch:
image: opensearchproject/opensearch:latest
......@@ -37,7 +40,15 @@ services:
- 9200
- 9600
networks:
- librarydemo
- librarydemo-internal
nginx-googleapisproxy:
image: nginx:1.27
volumes:
- ./nginx_demo_googleapis.conf:/etc/nginx/nginx.conf:ro
networks:
- librarydemo-internal
- librarydemo-external
nginx:
image: nginx:1.27
......@@ -50,11 +61,14 @@ services:
depends_on:
- web
networks:
- librarydemo
- librarydemo-internal
volumes:
demo_static:
demo_opensearch:
networks:
librarydemo:
\ No newline at end of file
librarydemo-internal:
# Block all external traffic to the network
internal: true
librarydemo-external: {}
\ No newline at end of file
......@@ -162,17 +162,17 @@ SPECTACULAR_SETTINGS = {
'REDOC_DIST': 'SIDECAR',
}
# Library settings
LIBRARY_SETTINGS = {
'MAX_ACTIVE_LOANS_PER_USER': 5,
'DEFAULT_LOAN_DURATION': 7,
}
# Opensearch Settings
OPENSEARCH_DSL = {
'default': {
'hosts': 'localhost:9200'
}
}
GOOGLEAPIS_BASE_URL = "https://www.googleapis.com"
......@@ -37,7 +37,7 @@ def load_gbooks_query_pagination(query):
"startIndex": len(items),
"maxResults": 40
}
res = requests.get("https://www.googleapis.com/books/v1/volumes?" + urlencode(qry))
res = requests.get(settings.GOOGLEAPIS_BASE_URL + "/books/v1/volumes?" + urlencode(qry))
if not res.ok:
return None
data = res.json()
......@@ -259,7 +259,7 @@ def book_add_flow_3(request, **kwargs):
form = BookAddForm()
if typ == "gbooks" and tid is not None:
# Query Google Books API for book details
res = requests.get("https://www.googleapis.com/books/v1/volumes/" + tid)
res = requests.get(settings.GOOGLEAPIS_BASE_URL + "/books/v1/volumes/" + tid)
if not res.ok:
other_errors.append("Google Books API request failed")
else:
......
......@@ -49,3 +49,4 @@ OPENSEARCH_DSL = {
}
}
GOOGLEAPIS_BASE_URL = os.environ.get("GOOGLEAPIS_URL_OVERRIDE", GOOGLEAPIS_BASE_URL)
user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log notice;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
limit_req_zone all zone=one:1m rate=10r/m;
limit_req zone=one burst=1 nodelay;
server {
listen 80;
location / {
proxy_pass https://www.googleapis.com;
proxy_set_header Host www.googleapis.com;
proxy_redirect off;
}
}
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment