Skip to content

Commit

Permalink
Merge pull request #14 from anyproto/issues-10
Browse files Browse the repository at this point in the history
fix issue-10
  • Loading branch information
fb929 authored Jan 15, 2024
2 parents 195891a + ebf56e9 commit e8922b5
Show file tree
Hide file tree
Showing 10 changed files with 55 additions and 15 deletions.
2 changes: 2 additions & 0 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ MONGO_VERSION=7.0.2
REDIS_VERSION=7.2.0-v6
S3_EMULATOR_VERSION=0.0.1

EXTERNAL_LISTEN_HOST="127.0.0.1"

ANY_SYNC_NODE_1_HOST=any-sync-node-1
ANY_SYNC_NODE_1_PORT=1001
ANY_SYNC_NODE_1_ADDRESSES=${ANY_SYNC_NODE_1_HOST}:${ANY_SYNC_NODE_1_PORT}
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile-generateconfig
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ COPY --chmod=777 docker-generateconfig/generate_config.sh .env .
RUN ./generate_config.sh

FROM alpine:3.18.4
RUN apk add --no-cache bash perl
RUN apk add --no-cache bash yq perl python3 py3-yaml
WORKDIR /opt/processing
COPY docker-generateconfig/etc/ tmp-etc/
COPY --chmod=777 docker-generateconfig/processing.sh .
COPY --chmod=777 docker-generateconfig/setListenIp.py .
COPY --from=generator /opt/generateconfig/ generateconfig/

CMD ./processing.sh

2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ pull:

down:
docker compose down
logs:
docker compose logs -f

# build with "plain" log for debug
build:
Expand Down
13 changes: 11 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,18 @@ Self-host for any-sync, designed for review and testing purposes.
db.getMongo().setReadPref('primaryPreferred'); db.nodeConf.find().sort( { _id: -1 } ).limit(1)
```

## Set specific versions
* run client
```
# macos example
ANYTYPE_LOG_LEVEL="*=DEBUG" ANYPROF=:6060 ANY_SYNC_NETWORK=<pathToRepo>/any-sync-dockercompose/etc/client.yml /Applications/Anytype.app/Contents/MacOS/Anytype
```

## configuration
Use file .env
### Compatible versions
* Set specific versions: find and edit variables with suffix "_VERSION"
* Set external listen host: default 127.0.0.1, for change you need edit variable "EXTERNAL_LISTEN_HOST"

## Compatible versions
You can find compatible versions on these pages:
* stable versions, used in [production](https://puppetdoc.anytype.io/api/v1/prod-any-sync-compatible-versions/)
* unstable versions, used in [test stand](https://puppetdoc.anytype.io/api/v1/stage1-any-sync-compatible-versions/)
Expand Down
10 changes: 0 additions & 10 deletions docker-compose-generateconfig.yml

This file was deleted.

6 changes: 5 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ services:
container_name: redis
image: "redis/redis-stack-server:${REDIS_VERSION}"
restart: always
command: redis-server --appendonly yes --maxmemory 256mb --maxmemory-policy noeviction --protected-mode no --loadmodule /opt/redis-stack/lib/redisbloom.so
command: redis-server --dir /data/ --appendonly yes --maxmemory 256mb --maxmemory-policy noeviction --protected-mode no --loadmodule /opt/redis-stack/lib/redisbloom.so
ports:
- "${REDIS_PORT}:${REDIS_PORT}"
volumes:
Expand All @@ -45,6 +45,10 @@ services:
- "${AWS_PORT}:4569"
volumes:
- ./storage/s3_root:/s3_root
networks:
default:
aliases:
- s3-emulator.s3-emulator

any-sync-coordinator_bootstrap:
image: "ghcr.io/anyproto/any-sync-coordinator:${ANY_SYNC_COORDINATOR_VERSION}"
Expand Down
5 changes: 5 additions & 0 deletions docker-generateconfig/etc/coordinator.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,8 @@ quic:
- %ANY_SYNC_COORDINATOR_QUIC_ADDRESSES%
writeTimeoutSec: 10
dialTimeoutSec: 10

fileLimit:
limitDefault: 1099511627776
limitAlphaUsers: 1099511627776
limitNightlyUsers: 1099511627776
1 change: 1 addition & 0 deletions docker-generateconfig/generate_config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ if ! [[ -s account0.yml ]]; then
fi
fi

yq --indent 4 --inplace 'del(.creationTime)' nodes.yml
yq --indent 4 --inplace ".networkId |= \"${NETWORK_ID}\"" nodes.yml
yq --indent 4 --inplace ".account.signingKey |= \"${NETWORK_SIGNING_KEY}\"" account3.yml
yq --indent 4 --inplace ".account.signingKey |= \"${NETWORK_SIGNING_KEY}\"" account5.yml
6 changes: 6 additions & 0 deletions docker-generateconfig/processing.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ for node_type in filenode coordinator consensusnode; do
mkdir -p "${dest_path}/any-sync-${node_type}"
done

# add external listen host
./setListenIp.py "${EXTERNAL_LISTEN_HOST}" "generateconfig/nodes.yml"

# create config for clients
cp "generateconfig/nodes.yml" "${dest_path}/client.yml"

# Generate network file
sed 's|^| |; 1s|^|network:\n|' "generateconfig/nodes.yml" > "${network_file}"

Expand Down
21 changes: 21 additions & 0 deletions docker-generateconfig/setListenIp.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import sys
import yaml

listenHost = sys.argv[1]
yamlFile = sys.argv[2]

with open(yamlFile, 'r') as file:
config = yaml.load(file,Loader=yaml.Loader)

for index, nodes in enumerate(config['nodes']):
addresses = nodes['addresses']
port = addresses[0].split(':')[1]
listenAddress = listenHost +':'+ port
if listenAddress not in addresses:
addresses.append(listenAddress)

with open(yamlFile, 'w') as file:
yaml.dump(config, file)

0 comments on commit e8922b5

Please sign in to comment.