Skip to content
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

Limit admin #20

Merged
merged 6 commits into from
Feb 14, 2024
Merged
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
10 changes: 9 additions & 1 deletion .env
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ ANY_SYNC_NODE_VERSION=latest
ANY_SYNC_FILENODE_VERSION=latest
ANY_SYNC_COORDINATOR_VERSION=latest
ANY_SYNC_CONSENSUSNODE_VERSION=latest
ANY_SYNC_ADMIN_VERSION=latest

MONGO_VERSION=7.0.2
REDIS_VERSION=7.2.0-v6
Expand Down Expand Up @@ -58,5 +59,12 @@ MONGO_1_PORT=27001
MONGO_2_PORT=27002
MONGO_3_PORT=27003
MONGO_CONNECT=mongodb://mongo-1:${MONGO_1_PORT},mongo-2:${MONGO_2_PORT},mongo-3:${MONGO_3_PORT}
MONGO_REPLICA_SET=rs0
MONGO_URL=${MONGO_CONNECT}/?replicaSet=${MONGO_REPLICA_SET}

REDIS_HOST=redis
REDIS_PORT=6379
REDIS_URL="redis://redis:${REDIS_PORT}?dial_timeout=3&read_timeout=6s"
REDIS_URL="redis://${REDIS_HOST}:${REDIS_PORT}?dial_timeout=3&read_timeout=6s"

ANY_SYNC_ADMIN_HOST=0.0.0.0
ANY_SYNC_ADMIN_PORT=5000
7 changes: 4 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
etc/
storage/
docker-compose.override.yml
/etc/
/storage/
/docker-compose.override.yml
/repos/
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,9 @@ If you need to create local build binaries for any-sync-*, you can do so by usin
make restart
```

## limits web admin
open link in browser: http://127.0.0.1:80

## Contribution
Thank you for your desire to develop Anytype together!

Expand Down
12 changes: 12 additions & 0 deletions docker-compose.any-sync-admin.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
version: "3.9"
services:
any-sync-admin:
image: localbuild-admin
build:
context: .
dockerfile: repos/any-sync-admin/Dockerfile
ssh:
- default
args:
REPO_DIR: repos/any-sync-admin/
command: python app.py
23 changes: 17 additions & 6 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,34 +3,33 @@ version: "3.9"
services:
mongo-1:
image: "mongo:${MONGO_VERSION}"
command: --replSet rs0 --port ${MONGO_1_PORT}
command: --replSet ${MONGO_REPLICA_SET} --port ${MONGO_1_PORT}
ports:
- "${MONGO_1_PORT}:${MONGO_1_PORT}"
volumes:
- ./storage/mongo-1/:/data/db
healthcheck:
test: test $$(echo "rs.initiate({_id:'rs0',members:[{_id:0,host:\"mongo-1:${MONGO_1_PORT}\"},{_id:1,host:\"mongo-2:${MONGO_2_PORT}\"},{_id:2,host:\"mongo-3:${MONGO_3_PORT}\"}]}).ok || rs.status().ok" | mongosh --port ${MONGO_1_PORT} --quiet) -eq 1
test: test $$(echo "rs.initiate({_id:'${MONGO_REPLICA_SET}',members:[{_id:0,host:\"mongo-1:${MONGO_1_PORT}\"},{_id:1,host:\"mongo-2:${MONGO_2_PORT}\"},{_id:2,host:\"mongo-3:${MONGO_3_PORT}\"}]}).ok || rs.status().ok" | mongosh --port ${MONGO_1_PORT} --quiet) -eq 1
interval: 10s
start_period: 30s

mongo-2:
image: "mongo:${MONGO_VERSION}"
command: --replSet rs0 --port ${MONGO_2_PORT}
command: --replSet ${MONGO_REPLICA_SET} --port ${MONGO_2_PORT}
ports:
- "${MONGO_2_PORT}:${MONGO_2_PORT}"
volumes:
- ./storage/mongo-2/:/data/db

mongo-3:
image: "mongo:${MONGO_VERSION}"
command: --replSet rs0 --port ${MONGO_3_PORT}
command: --replSet ${MONGO_REPLICA_SET} --port ${MONGO_3_PORT}
ports:
- "${MONGO_3_PORT}:${MONGO_3_PORT}"
volumes:
- ./storage/mongo-3/:/data/db

redis:
container_name: redis
image: "redis/redis-stack-server:${REDIS_VERSION}"
restart: always
command: redis-server --dir /data/ --appendonly yes --maxmemory 256mb --maxmemory-policy noeviction --protected-mode no --loadmodule /opt/redis-stack/lib/redisbloom.so
Expand All @@ -45,7 +44,6 @@ services:
retries: 3

minio:
container_name: minio
image: "minio/minio:${MINIO_VERSION}"
restart: always
command: server /data --console-address ":9001"
Expand Down Expand Up @@ -204,3 +202,16 @@ services:
memory: 500M
restart: on-failure
command: bash -c "sleep 15; /bin/any-sync-consensusnode -c /etc/any-sync-consensusnode/config.yml"

any-sync-admin:
image: "ghcr.io/anyproto/any-sync-admin:${ANY_SYNC_ADMIN_VERSION}"
depends_on:
- redis
- mongo-1
- mongo-2
- mongo-3
ports:
- "80:${ANY_SYNC_ADMIN_PORT}"
volumes:
- ./etc/any-sync-admin/:/etc/any-sync-admin/
restart: on-failure
10 changes: 10 additions & 0 deletions docker-generateconfig/etc/admin.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
listen:
host: %ANY_SYNC_ADMIN_HOST%
port: %ANY_SYNC_ADMIN_PORT%
debug: True
mongo:
url: %MONGO_URL%
redis:
host: %REDIS_HOST%
port: %REDIS_PORT%
19 changes: 18 additions & 1 deletion docker-generateconfig/processing.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ cat "${network_file}" tmp-etc/common.yml generateconfig/account5.yml tmp-etc/con
# Copy network file to coordinator directory
cp "generateconfig/nodes.yml" "${dest_path}/any-sync-coordinator/network.yml"

# Generate any-sync-admin config
mkdir -p ${dest_path}/any-sync-admin
cp "tmp-etc/admin.yml" ${dest_path}/any-sync-admin/config.yml

# Replace placeholders in config files
for node_type in node_1 node_2 node_3 coordinator filenode consensusnode; do
addresses="ANY_SYNC_${node_type^^}_ADDRESSES"
Expand All @@ -48,7 +52,20 @@ for node_type in node_1 node_2 node_3 coordinator filenode consensusnode; do
done

# Replace other placeholders
placeholders=( "MONGO_CONNECT" "REDIS_URL" "MINIO_PORT" "MINIO_BUCKET" "ANY_SYNC_COORDINATOR_FILE_LIMIT_DEFAULT" "ANY_SYNC_COORDINATOR_FILE_LIMIT_ALPHA_USERS" "ANY_SYNC_COORDINATOR_FILE_LIMIT_NIGHTLY_USERS")
placeholders=(
"MONGO_CONNECT"
"MONGO_URL"
"REDIS_URL"
"MINIO_PORT"
"MINIO_BUCKET"
"ANY_SYNC_COORDINATOR_FILE_LIMIT_DEFAULT"
"ANY_SYNC_COORDINATOR_FILE_LIMIT_ALPHA_USERS"
"ANY_SYNC_COORDINATOR_FILE_LIMIT_NIGHTLY_USERS"
"ANY_SYNC_ADMIN_HOST"
"ANY_SYNC_ADMIN_PORT"
"REDIS_HOST"
"REDIS_PORT"
)
for placeholder in "${placeholders[@]}"; do
perl -i -pe "s|%${placeholder}%|${!placeholder}|g" "${network_file}" "${dest_path}/"/*/*.yml
done
Loading