Skip to content

Commit

Permalink
Merge pull request #17 from anyproto/new-s3-backend
Browse files Browse the repository at this point in the history
New s3 backend
  • Loading branch information
mighty-sponge authored Jan 24, 2024
2 parents a50476d + 383177a commit 450d49c
Show file tree
Hide file tree
Showing 8 changed files with 60 additions and 20 deletions.
4 changes: 2 additions & 2 deletions .aws/credentials
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[default]
aws_access_key_id=testid
aws_secret_access_key=testkey
aws_access_key_id=minio_access_key
aws_secret_access_key=minio_secret_key
13 changes: 9 additions & 4 deletions .env
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
AWS_ACCESS_KEY_ID=testid
AWS_SECRET_ACCESS_KEY=testkey
AWS_PORT=4569
AWS_ACCESS_KEY_ID=minio_access_key
AWS_SECRET_ACCESS_KEY=minio_secret_key
MINIO_BUCKET=minio-bucket
MINIO_PORT=9000
MINIO_WEB_PORT=9001

ANY_SYNC_NODE_VERSION=latest
ANY_SYNC_FILENODE_VERSION=latest
Expand All @@ -9,7 +11,7 @@ ANY_SYNC_CONSENSUSNODE_VERSION=latest

MONGO_VERSION=7.0.2
REDIS_VERSION=7.2.0-v6
S3_EMULATOR_VERSION=0.0.1
MINIO_VERSION=RELEASE.2024-01-16T16-07-38Z

EXTERNAL_LISTEN_HOST="127.0.0.1"

Expand All @@ -36,6 +38,9 @@ ANY_SYNC_COORDINATOR_PORT=1004
ANY_SYNC_COORDINATOR_ADDRESSES=${ANY_SYNC_COORDINATOR_HOST}:${ANY_SYNC_COORDINATOR_PORT}
ANY_SYNC_COORDINATOR_QUIC_PORT=1014
ANY_SYNC_COORDINATOR_QUIC_ADDRESSES=${ANY_SYNC_COORDINATOR_HOST}:${ANY_SYNC_COORDINATOR_QUIC_PORT}
ANY_SYNC_COORDINATOR_FILE_LIMIT_DEFAULT=1099511627776
ANY_SYNC_COORDINATOR_FILE_LIMIT_ALPHA_USERS=1099511627776
ANY_SYNC_COORDINATOR_FILE_LIMIT_NIGHTLY_USERS=1099511627776

ANY_SYNC_FILENODE_HOST=any-sync-filenode
ANY_SYNC_FILENODE_PORT=1005
Expand Down
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ generate_config:

start: generate_config
docker compose up -d
@echo "Done! Upload your self-hosted network configuration file ${CURDIR}/etc/client.yml into the client app"
@echo "See: https://doc.anytype.io/anytype-docs/data-and-security/self-hosting#switching-between-networks"

stop:
docker compose stop
Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ Self-host for any-sync, designed for review and testing purposes.
> [!IMPORTANT]
> please don't use it for production!
> [!WARNING]
> Starting from release version v2.0.1, we have transitioned from the **s3-emulator** to **minio** as the data storage for any-sync-filenode. Please note that this change will result in the loss of any-sync-filenode data (stored at the path `./storage/s3_root`).
## Prepare
* install docker and docker-compose https://docs.docker.com/compose/install/linux/

Expand Down
41 changes: 35 additions & 6 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,17 +38,46 @@ services:
- "${REDIS_PORT}:${REDIS_PORT}"
volumes:
- ./storage/redis/:/data/
healthcheck:
test: [ "CMD", "redis-cli", "--raw", "incr", "ping" ]
interval: 10s
timeout: 30s
retries: 3

s3-emulator:
image: "stanislavt/s3-emulator:${S3_EMULATOR_VERSION}"
minio:
container_name: minio
image: "minio/minio:${MINIO_VERSION}"
restart: always
command: server /data --console-address ":9001"
environment:
MINIO_ROOT_USER: "${AWS_ACCESS_KEY_ID}"
MINIO_ROOT_PASSWORD: "${AWS_SECRET_ACCESS_KEY}"
ports:
- "${AWS_PORT}:4569"
- "${MINIO_PORT}:9000"
- "${MINIO_WEB_PORT}:9001"
volumes:
- ./storage/s3_root:/s3_root
- ./storage/minio:/data
healthcheck:
test: bash -c ':> /dev/tcp/127.0.0.1/9000' || exit 1
interval: 5s
timeout: 10s
retries: 3
networks:
default:
aliases:
- s3-emulator.s3-emulator
- "${MINIO_BUCKET}.minio" # <bucket-name>.<endpoint-name>

create-bucket:
image: minio/mc:latest
environment:
MC_HOST_minio: http://${AWS_ACCESS_KEY_ID}:${AWS_SECRET_ACCESS_KEY}@minio:${MINIO_PORT}
restart: no
depends_on:
- minio
entrypoint:
- sh
- -c
- mc mb minio/${MINIO_BUCKET}

any-sync-coordinator_bootstrap:
image: "ghcr.io/anyproto/any-sync-coordinator:${ANY_SYNC_COORDINATOR_VERSION}"
Expand Down Expand Up @@ -81,7 +110,7 @@ services:
image: "ghcr.io/anyproto/any-sync-filenode:${ANY_SYNC_FILENODE_VERSION}"
depends_on:
- redis
- s3-emulator
- minio
- any-sync-coordinator
ports:
- "${ANY_SYNC_FILENODE_PORT}:${ANY_SYNC_FILENODE_PORT}"
Expand Down
6 changes: 3 additions & 3 deletions docker-generateconfig/etc/coordinator.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@ quic:
dialTimeoutSec: 10

fileLimit:
limitDefault: 1099511627776
limitAlphaUsers: 1099511627776
limitNightlyUsers: 1099511627776
limitDefault: %ANY_SYNC_COORDINATOR_FILE_LIMIT_DEFAULT%
limitAlphaUsers: %ANY_SYNC_COORDINATOR_FILE_LIMIT_ALPHA_USERS%
limitNightlyUsers: %ANY_SYNC_COORDINATOR_FILE_LIMIT_NIGHTLY_USERS%
9 changes: 5 additions & 4 deletions docker-generateconfig/etc/filenode.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
s3Store:
bucket: s3-emulator
indexBucket: s3-emulator
bucket: %MINIO_BUCKET%
indexBucket: %MINIO_BUCKET%
maxThreads: 16
profile: default
region: eu-central-1
endpoint: http://s3-emulator:%AWS_PORT%
region: us-east-1
endpoint: http://minio:%MINIO_PORT%
forcePathStyle: true # 'true' for self-hosted S3 Object Storage

redis:
isCluster: false
Expand Down
2 changes: 1 addition & 1 deletion docker-generateconfig/processing.sh
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ for node_type in node_1 node_2 node_3 coordinator filenode consensusnode; do
done

# Replace other placeholders
placeholders=( "MONGO_CONNECT" "REDIS_URL" "AWS_PORT" )
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")
for placeholder in "${placeholders[@]}"; do
perl -i -pe "s|%${placeholder}%|${!placeholder}|g" "${network_file}" "${dest_path}/"/*/*.yml
done

0 comments on commit 450d49c

Please sign in to comment.