From 6b12d8318b57ede1b31e3984c2651f8a6e18eaed Mon Sep 17 00:00:00 2001 From: syui Date: Fri, 18 Oct 2024 23:46:53 +0900 Subject: [PATCH] fix --- README.md | 4 +- build.sh | 7 ++ compose.yaml | 153 +++++++++++++++++++++++++++++++++ configs/postgres/init/init.sql | 35 ++++++++ envs/bgs | 6 ++ envs/bsky | 19 ++++ envs/ozone | 21 +++++ envs/pds | 21 +++++ envs/plc | 4 + envs/postgres | 4 + envs/social-app | 1 + repos/.keep | 0 repos/atproto | 1 + repos/did-method-plc | 1 + repos/feed-generator | 1 + repos/social-app | 1 + 16 files changed, 278 insertions(+), 1 deletion(-) create mode 100755 build.sh create mode 100644 compose.yaml create mode 100644 configs/postgres/init/init.sql create mode 100644 envs/bgs create mode 100644 envs/bsky create mode 100644 envs/ozone create mode 100644 envs/pds create mode 100644 envs/plc create mode 100644 envs/postgres create mode 100644 envs/social-app create mode 100644 repos/.keep create mode 160000 repos/atproto create mode 160000 repos/did-method-plc create mode 160000 repos/feed-generator create mode 160000 repos/social-app diff --git a/README.md b/README.md index 6bcd623..a83e64e 100644 --- a/README.md +++ b/README.md @@ -29,6 +29,8 @@ 2. https://${host}/xrpc/com.atproto.sync.getBlob?did=${did}&cid=${cid} ``` +docker composeはportsを書かなければ公開されません。内部間のみ有効になります。公開するもののみportsをつけましょう。 + ## api ```sh @@ -36,7 +38,7 @@ $ curl -X POST -H "Content-Type: application/json" -sL https://${pds}/xrpc/com.atproto.server.createAccount -d "{\"email\": \"$email\", \"handle\": \"$handle\", \"password\": \"$password\"}" ``` -3文字以下の名前を使用するには`pds/handle`を変更します。また、social-app(web client)からは3文字以下のアカウントを作成できません。apiから作成してください。 +3文字以下の名前を使用するには`src/pds/handle`を変更します。また、social-app(web client)からは3文字以下のアカウントを作成できません。apiから作成してください。 - [/atproto/packages/pds/src/handle/index.ts](https://github.com/bluesky-social/atproto/blame/d4d5a6edba972c0e9976289bde8bc0b42ff547ca/packages/pds/src/handle/index.ts#L86-L88) diff --git a/build.sh b/build.sh new file mode 100755 index 0000000..f7613e8 --- /dev/null +++ b/build.sh @@ -0,0 +1,7 @@ +#!/bin/zsh + +cd ./repos +git clone https://github.com/bluesky-social/atproto +git clone https://github.com/did-method-plc/did-method-plc +git clone https://github.com/bluesky-social/feed-generator +git clone https://github.com/bluesky-social/social-app diff --git a/compose.yaml b/compose.yaml new file mode 100644 index 0000000..2ca0e35 --- /dev/null +++ b/compose.yaml @@ -0,0 +1,153 @@ +services: + + database: + image: postgres:16-alpine + restart: always + env_file: + - ./envs/postgres + volumes: + - ./configs/postgres/init/:/docker-entrypoint-initdb.d/ + - ./data/postgres/:/var/lib/postgresql/data/ + healthcheck: + test: "pg_isready -U $$POSTGRES_USER -d $$POSTGRES_DB" + interval: 5s + retries: 20 + + redis: + image: redis:alpine + restart: always + volumes: + - ./data/redis/:/data/ + healthcheck: + test: ["CMD", "redis-cli", "ping", "|", "grep", "PONG"] + interval: 1s + timeout: 5s + retries: 5 + + pds-fix-permission: + image: alpine:latest + volumes: + - ./data/pds/:/data/ + command: chown 1000.1000 /data + + bsky-fix-permission: + image: alpine:latest + volumes: + - ./data/bsky/:/data/ + command: chown 1000.1000 /data + + opensearch-fix-permission: + image: alpine:latest + volumes: + - ./data/opensearch/:/data/ + command: chown 1000.1000 /data/ + + plc: + ports: + - 2582:3000 + build: + context: ./repos/did-method-plc/ + dockerfile: packages/server/Dockerfile + restart: always + env_file: + - ./envs/plc + depends_on: + database: + condition: service_healthy + + pds: + ports: + - 2583:3000 + build: + context: ./repos/atproto/ + dockerfile: services/pds/Dockerfile + restart: always + env_file: + - ./envs/pds + volumes: + - ./data/pds/:/data/ + depends_on: + database: + condition: service_healthy + pds-fix-permission: + condition: service_completed_successfully + + bgs: + ports: + - 2470:2470 + build: + context: ./repos/indigo/ + dockerfile: cmd/bigsky/Dockerfile + restart: always + env_file: + - ./envs/bgs + volumes: + - ./data/bgs/:/data/ + depends_on: + database: + condition: service_healthy + + ozone: + ports: + - 2585:3000 + build: + context: ./repos/atproto/ + dockerfile: services/ozone/Dockerfile + restart: always + command: node --enable-source-maps api.js + volumes: + - ./data/ozone/:/data/ + - ./repos/ozone.js:/app/services/ozone/api.js:ro + env_file: + - ./envs/ozone + healthcheck: + test: "wget -q --spider http://localhost:3000/xrpc/_health" + interval: 5s + retries: 20 + depends_on: + database: + condition: service_healthy + + ozone-daemon: + build: + context: ./repos/atproto/ + dockerfile: services/ozone/Dockerfile + restart: always + command: node --enable-source-maps daemon.js + env_file: + - ./envs/ozone + depends_on: + ozone: + condition: service_healthy + database: + condition: service_healthy + + social-app: + ports: + - 8100:8100 + image: itaru2622/bluesky-social-app + restart: always + env_file: + - ./envs/social-app + command: "/usr/bin/bskyweb serve" + + bsky: + ports: + - 2584:2584 + image: itaru2622/bluesky-atproto-bsky + restart: always + env_file: + - ./envs/bsky + user: root + volumes: + - ./data/bsky/:/data/ + # - ./repos/bsky.js:/app/services/bsky/api.js:ro + command: node --enable-source-maps api.js + depends_on: + database: + condition: service_healthy + redis: + condition: service_healthy + bsky-fix-permission: + condition: service_completed_successfully + diff --git a/configs/postgres/init/init.sql b/configs/postgres/init/init.sql new file mode 100644 index 0000000..f86b7c9 --- /dev/null +++ b/configs/postgres/init/init.sql @@ -0,0 +1,35 @@ +-- PLC +CREATE DATABASE plc; +GRANT ALL PRIVILEGES ON DATABASE plc TO postgres; + +-- BGS +CREATE DATABASE bgs; +CREATE DATABASE carstore; +GRANT ALL PRIVILEGES ON DATABASE bgs TO postgres; +GRANT ALL PRIVILEGES ON DATABASE carstore TO postgres; + +-- bsky(AppView) +--CREATE DATABASE appview; +--GRANT ALL PRIVILEGES ON DATABASE appview TO postgres; +CREATE DATABASE bsky; +GRANT ALL PRIVILEGES ON DATABASE bsky TO postgres; + +-- ozone(Moderation) +--CREATE DATABASE moderation; +--GRANT ALL PRIVILEGES ON DATABASE moderation TO postgres; +CREATE DATABASE ozone; +GRANT ALL PRIVILEGES ON DATABASE ozone TO postgres; + +-- search(palomar) +CREATE DATABASE search; +GRANT ALL PRIVILEGES ON DATABASE search TO postgres; +--CREATE DATABASE palomar; +--GRANT ALL PRIVILEGES ON DATABASE palomar TO postgres; + +-- PDS +CREATE DATABASE pds; +GRANT ALL PRIVILEGES ON DATABASE pds TO postgres; + +-- BSYNC +CREATE DATABASE bsync; +GRANT ALL PRIVILEGES ON DATABASE bsync TO postgres; diff --git a/envs/bgs b/envs/bgs new file mode 100644 index 0000000..fa79239 --- /dev/null +++ b/envs/bgs @@ -0,0 +1,6 @@ +DATABASE_URL=postgres://postgres:postgres@database/bgs +CARSTORE_DATABASE_URL=postgres://postgres:postgres@database/carstore +DATA_DIR=/data +ATP_PLC_HOST=https://plc.${host} + +BGS_ADMIN_KEY diff --git a/envs/bsky b/envs/bsky new file mode 100644 index 0000000..5bebd98 --- /dev/null +++ b/envs/bsky @@ -0,0 +1,19 @@ +BSKY_PORT=2584 +BSKY_BLOB_CACHE_LOC=/data/ +BSKY_BSYNC_HTTP_VERSION=1.1 +BSKY_BSYNC_PORT=3002 +BSKY_BSYNC_URL=http://bsky:3002 +BSKY_COURIER_URL=http://fake-courier.example.invalid/ +BSKY_DATAPLANE_HTTP_VERSION=1.1 +BSKY_DATAPLANE_PORT=3001 +BSKY_DATAPLANE_URLS=http://bsky:3001 +BSKY_DB_POSTGRES_URL=postgres://postgres:postgres@database/bsky +BSKY_DID_PLC_URL=https://plc.${host} +BSKY_PUBLIC_URL=https://bsky.${host} +BSKY_REPO_PROVIDER=wss://bgs.${host} +BSKY_SERVER_DID=did:web:bsky.${host} +MOD_SERVICE_DID=did:web:ozone.${host} + +#BSKY_IMG_URI_ENDPOINT=https://bsky.${host}/img +BSKY_ADMIN_PASSWORDS +BSKY_SERVICE_SIGNING_KEY diff --git a/envs/ozone b/envs/ozone new file mode 100644 index 0000000..72b0158 --- /dev/null +++ b/envs/ozone @@ -0,0 +1,21 @@ +OZONE_SERVER_DID=did:web:ozone.${host} +OZONE_PUBLIC_URL=https://ozone.${host} +OZONE_ADMIN_HANDLE=${user}.${host} +OZONE_MODERATOR_DIDS=${did} +OZONE_ADMIN_DIDS=${did} +OZONE_DB_POSTGRES_URL=postgres://postgres:postgres@database/ozone +OZONE_DID_PLC_URL=https://plc.${host} +NEXT_PUBLIC_PLC_DIRECTORY_URL=https://plc.${host} +NEXT_PUBLIC_OZONE_SERVICE_DID=did:web:ozone.${host} +NEXT_PUBLIC_SOCIAL_APP_DOMAIN=mod.${host} +NEXT_PUBLIC_SOCIAL_APP_URL=https://mod.${host} +OZONE_APPVIEW_DID=did:web:bsky.${host} +OZONE_APPVIEW_URL=https://bsky.${host} +OZONE_APPVIEW_PUSH_EVENTS=false +OZONE_PDS_DID=did:web:${host} +OZONE_PDS_URL=https://${host} +OZONE_DEV_MODE=true +OZONE_DB_MIGRATE=1 + +OZONE_ADMIN_PASSWORD +OZONE_SIGNING_KEY_HEX diff --git a/envs/pds b/envs/pds new file mode 100644 index 0000000..fabc2a4 --- /dev/null +++ b/envs/pds @@ -0,0 +1,21 @@ +PDS_HOSTNAME=${host} +PDS_DB_POSTGRES_URL=postgres://postgres:postgres@database/pds +PDS_DATA_DIRECTORY=/data +PDS_BLOBSTORE_DISK_LOCATION=/data/img/static +#PDS_BLOBSTORE_DISK_TMP_LOCATION=/data/img/tmp +PDS_BSKY_APP_VIEW_DID=did:web:bsky.${host} +PDS_BSKY_APP_VIEW_URL=https://bsky.${host} +PDS_CRAWLERS=https://bgs.${host} +PDS_DEV_MODE=true +PDS_DID_PLC_URL=https://plc.${host} +PDS_ENABLE_DID_DOC_WITH_SESSION=true +PDS_INVITE_INTERVAL=604800000 +PDS_SERVICE_DID=did:web:${host} +PDS_EMAIL_FROM_ADDRESS=no-reply@${host} + +PDS_INVITE_REQUIRED=true +PDS_EMAIL_SMTP_URL=smtps://${user}:${app_password}@smtp.gmail.com +PDS_ADMIN_PASSWORD +PDS_PLC_ROTATION_KEY_K256_PRIVATE_KEY_HEX +PDS_REPO_SIGNING_KEY_K256_PRIVATE_KEY_HEX +PDS_JWT_SECRET diff --git a/envs/plc b/envs/plc new file mode 100644 index 0000000..f0ccb52 --- /dev/null +++ b/envs/plc @@ -0,0 +1,4 @@ +DATABASE_URL=postgres://postgres:postgres@database/plc +DB_CREDS_JSON='{"username":"postgres","password":"postgres","host":"database","port":"5432","database":"plc"}' +ENABLE_MIGRATIONS=true +DB_MIGRATE_CREDS_JSON='{"username":"postgres","password":"postgres","host":"database","port":"5432","database":"plc"}' diff --git a/envs/postgres b/envs/postgres new file mode 100644 index 0000000..4184165 --- /dev/null +++ b/envs/postgres @@ -0,0 +1,4 @@ +#POSTGRES_INITDB_ARGS=--encoding=UTF-8 --lc-collate=C --lc-ctype=C +POSTGRES_USER=postgres +POSTGRES_PASSWORD=postgres +POSTGRES_DB=healthcheck diff --git a/envs/social-app b/envs/social-app new file mode 100644 index 0000000..a6752de --- /dev/null +++ b/envs/social-app @@ -0,0 +1 @@ +ATP_APPVIEW_HOST=https://bsky.${host} diff --git a/repos/.keep b/repos/.keep new file mode 100644 index 0000000..e69de29 diff --git a/repos/atproto b/repos/atproto new file mode 160000 index 0000000..7f26b17 --- /dev/null +++ b/repos/atproto @@ -0,0 +1 @@ +Subproject commit 7f26b176526b9856a8f61faca6f065f0afd43abf diff --git a/repos/did-method-plc b/repos/did-method-plc new file mode 160000 index 0000000..13da315 --- /dev/null +++ b/repos/did-method-plc @@ -0,0 +1 @@ +Subproject commit 13da315787e50bd79548d5b695f4f597b43b4015 diff --git a/repos/feed-generator b/repos/feed-generator new file mode 160000 index 0000000..9a887dd --- /dev/null +++ b/repos/feed-generator @@ -0,0 +1 @@ +Subproject commit 9a887dd8f2ee634c5e524cfa802f754878a91e5a diff --git a/repos/social-app b/repos/social-app new file mode 160000 index 0000000..fd2e94f --- /dev/null +++ b/repos/social-app @@ -0,0 +1 @@ +Subproject commit fd2e94f3534ea459b08a4d6b9a6f0aaccfd2445e