Skip to content

Commit

Permalink
caddy: new frontend
Browse files Browse the repository at this point in the history
  • Loading branch information
PhotonQuantum committed Jun 11, 2024
1 parent eaaec27 commit a987123
Show file tree
Hide file tree
Showing 8 changed files with 40 additions and 17 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "frontend"]
path = frontend
url = https://github.com/sjtug/sjtug-mirror-frontend
6 changes: 1 addition & 5 deletions caddy-gen/src/caddy-gen.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,7 @@ def is_local(base: str):

def common() -> list[Node]:
frontends = Node("handle", [
Node('file_server /*', [
Node(f'root {FRONTEND_DIR}')
]),
Node('rewrite /docs/* /', comment='for react app'),
*hidden()
Node('reverse_proxy /* frontend:3000'),
])

lug = Node("handle /lug/*", [
Expand Down
7 changes: 1 addition & 6 deletions caddy/Caddyfile.siyuan
Original file line number Diff line number Diff line change
Expand Up @@ -135,12 +135,7 @@ https://mirror.sjtu.edu.cn {
}

handle {
file_server /* {
root /dists
}
rewrite /docs/* / # for react app
@hidden path */.*
respond @hidden 404
reverse_proxy /* frontend:3000
}

handle /lug/* {
Expand Down
7 changes: 1 addition & 6 deletions caddy/Caddyfile.zhiyuan
Original file line number Diff line number Diff line change
Expand Up @@ -109,12 +109,7 @@ https://mirrors.sjtug.sjtu.edu.cn {
}

handle {
file_server /* {
root /dists
}
rewrite /docs/* / # for react app
@hidden path */.*
respond @hidden 404
reverse_proxy /* frontend:3000
}

handle /lug/* {
Expand Down
5 changes: 5 additions & 0 deletions docker-compose.siyuan.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
services:
frontend:
container_name: siyuan-frontend
mem_limit: 1G
memswap_limit: 1G

caddy:
container_name: siyuan-caddy
volumes:
Expand Down
23 changes: 23 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,29 @@ services:
soft: 80000
hard: 120000

frontend:
restart: unless-stopped
build:
context: ./frontend
networks:
- ipv6-service-net
expose:
- 3000
healthcheck:
test: curl -f http://localhost || exit 1
interval: 1m30s
timeout: 10s
retries: 3
start_period: 40s
logging:
options:
max-size: "4M"
max-file: "20"
ulimits:
nofile:
soft: 80000
hard: 120000

lug:
restart: unless-stopped
command: -c /config.yaml
Expand Down
5 changes: 5 additions & 0 deletions docker-compose.zhiyuan.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
services:
frontend:
container_name: zhiyuan-frontend
mem_limit: 1G
memswap_limit: 1G

caddy:
container_name: zhiyuan-caddy
volumes:
Expand Down
1 change: 1 addition & 0 deletions frontend
Submodule frontend added at b8c754

0 comments on commit a987123

Please sign in to comment.