mirror of
https://github.com/rr-/szurubooru.git
synced 2025-07-17 08:26:24 +00:00
server: docker setup for embeds, sharing client's /var/www to the server
This commit is contained in:
@ -23,8 +23,12 @@ services:
|
|||||||
#LOG_SQL: 0 (1 for verbose SQL logs)
|
#LOG_SQL: 0 (1 for verbose SQL logs)
|
||||||
THREADS:
|
THREADS:
|
||||||
volumes:
|
volumes:
|
||||||
|
- client:/opt/app/client:ro
|
||||||
- "${MOUNT_DATA}:/data"
|
- "${MOUNT_DATA}:/data"
|
||||||
- "./server/config.yaml:/opt/app/config.yaml"
|
- "./server/config.yaml:/opt/app/config.yaml"
|
||||||
|
## Expose this port if you want embeds
|
||||||
|
#ports:
|
||||||
|
# - "${PORT_SERVER}:6666"
|
||||||
|
|
||||||
client:
|
client:
|
||||||
image: szurubooru/client:latest
|
image: szurubooru/client:latest
|
||||||
@ -34,6 +38,7 @@ services:
|
|||||||
BACKEND_HOST: server
|
BACKEND_HOST: server
|
||||||
BASE_URL:
|
BASE_URL:
|
||||||
volumes:
|
volumes:
|
||||||
|
- client:/var/www
|
||||||
- "${MOUNT_DATA}:/data:ro"
|
- "${MOUNT_DATA}:/data:ro"
|
||||||
ports:
|
ports:
|
||||||
- "${PORT}:80"
|
- "${PORT}:80"
|
||||||
@ -46,3 +51,6 @@ services:
|
|||||||
POSTGRES_PASSWORD:
|
POSTGRES_PASSWORD:
|
||||||
volumes:
|
volumes:
|
||||||
- "${MOUNT_SQL}:/var/lib/postgresql/data"
|
- "${MOUNT_SQL}:/var/lib/postgresql/data"
|
||||||
|
|
||||||
|
volumes:
|
||||||
|
client:
|
||||||
|
@ -172,11 +172,16 @@ privileges:
|
|||||||
homepage_url: https://www.example.com/
|
homepage_url: https://www.example.com/
|
||||||
site_url: https://www.example.com/booru
|
site_url: https://www.example.com/booru
|
||||||
|
|
||||||
|
## Client folder sharing, required for embeds.
|
||||||
|
# Docker requires you to share /var/www from the client to the server.
|
||||||
|
client_dir: /opt/app/client
|
||||||
|
|
||||||
## ONLY SET THESE IF DEPLOYING OUTSIDE OF DOCKER
|
## ONLY SET THESE IF DEPLOYING OUTSIDE OF DOCKER
|
||||||
#debug: 0 # generate server logs?
|
#debug: 0 # generate server logs?
|
||||||
#show_sql: 0 # show sql in server logs?
|
#show_sql: 0 # show sql in server logs?
|
||||||
#data_url: /data/
|
#data_url: /data/
|
||||||
#data_dir: /var/www/data
|
#data_dir: /var/www/data
|
||||||
|
#client_dir: /var/www
|
||||||
## usage: schema://user:password@host:port/database_name
|
## usage: schema://user:password@host:port/database_name
|
||||||
## example: postgres://szuru:dog@localhost:5432/szuru_test
|
## example: postgres://szuru:dog@localhost:5432/szuru_test
|
||||||
#database:
|
#database:
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
import logging
|
||||||
|
from pathlib import Path
|
||||||
import re
|
import re
|
||||||
import html
|
import html
|
||||||
from urllib.parse import quote
|
from urllib.parse import quote
|
||||||
@ -10,8 +12,11 @@ from szurubooru.func import (
|
|||||||
serialization,
|
serialization,
|
||||||
)
|
)
|
||||||
|
|
||||||
with open(f"{config.config['data_dir']}/../index.htm") as index:
|
if (Path(config.config['client_dir']) / "index.htm").exists():
|
||||||
index_html = index.read()
|
with open(f"{config.config['client_dir']}/index.htm") as index:
|
||||||
|
index_html = index.read()
|
||||||
|
else:
|
||||||
|
logging.warning("Could not find index.htm needed for embeds.")
|
||||||
|
|
||||||
def _index_path(params: Dict[str, str]) -> int:
|
def _index_path(params: Dict[str, str]) -> int:
|
||||||
try:
|
try:
|
||||||
@ -78,6 +83,11 @@ def get_post(
|
|||||||
@rest.routes.get("/index(?P<path>/.+)")
|
@rest.routes.get("/index(?P<path>/.+)")
|
||||||
def post_index(ctx: rest.Context, params: Dict[str, str]) -> rest.Response:
|
def post_index(ctx: rest.Context, params: Dict[str, str]) -> rest.Response:
|
||||||
path = _index_path(params)
|
path = _index_path(params)
|
||||||
|
|
||||||
|
if not index_html:
|
||||||
|
logging.info("Embed was requested but index.htm file does not exist. Redirecting to 404.")
|
||||||
|
return {"return_type": "custom", "status_code": "404", "content": [("content-type", "text/html")]}
|
||||||
|
|
||||||
try:
|
try:
|
||||||
oembed = get_post(ctx, {}, path)
|
oembed = get_post(ctx, {}, path)
|
||||||
except posts.PostNotFoundError:
|
except posts.PostNotFoundError:
|
||||||
|
Reference in New Issue
Block a user