ai/at
1
0

add social-app-custom

This commit is contained in:
2025-12-03 12:38:37 +09:00
parent 647dd5978c
commit 76c70765a6
15 changed files with 736 additions and 53 deletions

View File

@@ -18,6 +18,8 @@ function at-repos-env() {
https://github.com/bluesky-social/ozone
https://github.com/bluesky-social/jetstream
)
services=( bsky plc pds jetstream bgs ozone social-app )
img=( bsky plc pds jetstream bgs ozone social-app ozone-web ozone-daemon )
d=${0:a:h}
dh=${0:a:h:h}
name=${host%%.*}
@@ -108,7 +110,53 @@ function at-repos-social-app-avatar-write() {
grep -R syu.is .|cut -d : -f 1|sort -u|xargs sed -i "s/syu.is/${host}/g"
grep -R web.syu.is .|cut -d : -f 1|sort -u|xargs sed -i "s/web.syu.is/web.${host}/g"
f=$dt/lib/constants.ts
sed -i "s/public.api.web/bsky/g" $f
sed -i "s#export const BSKY_SERVICE = 'https://bsky.social'#export const BSKY_SERVICE = 'https://${host}'#g" $f
sed -i "s#export const BSKY_SERVICE_DID = 'did:web:bsky.social'#export const BSKY_SERVICE_DID = 'did:web:${host}'#g" $f
sed -i "s#export const PUBLIC_BSKY_SERVICE = 'https://public.api.bsky.app'#export const PUBLIC_BSKY_SERVICE = 'https://bsky.${host}'#g" $f
sed -i "s#export const PUBLIC_APPVIEW = 'https://api.bsky.app'#export const PUBLIC_APPVIEW = 'https://bsky.${host}'#g" $f
sed -i "s#export const PUBLIC_APPVIEW_DID = 'did:web:api.bsky.app'#export const PUBLIC_APPVIEW_DID = 'did:web:bsky.${host}'#g" $f
# Disable external services (CORS fix)
f=$dt/state/geolocation/const.ts
curl -sL https://raw.githubusercontent.com/bluesky-social/social-app/refs/heads/main/src/state/geolocation/const.ts -o $f
cat > $f << 'GEOEOF'
import {type GeolocationStatus} from '#/state/geolocation/types'
import {BAPP_CONFIG_DEV_URL, IS_DEV} from '#/env'
import {type Device} from '#/storage'
export const IPCC_URL = `https://bsky.app/ipcc`
// Disabled for self-hosted environment to avoid CORS errors
export const BAPP_CONFIG_URL_PROD = null
export const BAPP_CONFIG_URL = null
export const GEOLOCATION_CONFIG_URL = BAPP_CONFIG_URL
export const DEFAULT_GEOLOCATION_CONFIG: Device['geolocation'] = {
countryCode: undefined,
regionCode: undefined,
ageRestrictedGeos: [],
ageBlockedGeos: [],
}
export const DEFAULT_GEOLOCATION_STATUS: GeolocationStatus = {
countryCode: undefined,
regionCode: undefined,
isAgeRestrictedGeo: false,
isAgeBlockedGeo: false,
}
GEOEOF
# Add null check to geolocation config.ts to prevent fetch(null) errors
f=$dt/state/geolocation/config.ts
curl -sL https://raw.githubusercontent.com/bluesky-social/social-app/refs/heads/main/src/state/geolocation/config.ts -o $f
# Add null check at the beginning of getGeolocationConfig function (after line with 'url: string,')
sed -i "s/): Promise<Device\['geolocation'\]> {/): Promise<Device['geolocation']> {\n if (!url) return undefined/" $f
# Disable Statsig (CORS fix)
f=$dt/lib/statsig/statsig.tsx
sed -i "s#api: 'https://events.bsky.app/v2'#api: '' // Disabled for self-hosted#g" $f
# Disable SDK initialization to prevent statsigapi.net connections
sed -i "s#const SDK_KEY = 'client-SXJakO39w9vIhl3D44u8UupyzFl4oZ2qPIkjwcvuPsV'#const SDK_KEY = '' // Disabled for self-hosted#g" $f
f=$dt/view/icons/Logotype.tsx
o=$d/icons/Logotype.tsx
cp -rf $o $f
@@ -156,6 +204,16 @@ function at-repos-social-app-agent-patch() {
popd
}
function at-repos-social-app-disable-external-services-patch() {
f=$d/repos/social-app/src/state/geolocation/const.ts
p_=$d/patching/8980-social-app-disable-external-services.diff
d_=$d/repos/social-app
echo "applying patch: under ${f} for ${p_}"
pushd ${d_}
patch -p1 < ${p_}
popd
}
function at-repos-ozone-patch() {
#DOMAIN=syu.is
cd $d/repos
@@ -180,48 +238,40 @@ function at-repos-ozone-patch() {
function at-repos-build-docker-atproto() {
cd $d
docker image prune -a
docker compose build --no-cache bsky plc pds jetstream bgs ozone
if [ -z "$1" ];then
for ((i=1; i<=${#services}; i++)); do
service=${services[$i]}
docker compose build --no-cache $service
done
else
docker compose build --no-cache $1
fi
}
function at-repos-build-docker-social() {
cd $d
docker compose build --no-cache social-app
}
function at-repos-build-docker-tag() {
function at-repos-push-reset() {
docker restart registry
docker stop registry
docker rm registry
docker volume rm registry-data 2>/dev/null || true
docker run -d -p 5000:5000 --name registry \
docker run -d -p ${dport}:${dport} --name registry \
--restart=always \
-v registry-data:/var/lib/registry \
registry:2
sleep 3
docker run -d -p ${dport}:${dport} --name registry --restart=always registry:2
docker tag at-pds:latest localhost:${dport}/pds:latest
docker tag at-ozone-web:latest localhost:${dport}/ozone-web:latest
docker tag at-bgs:latest localhost:${dport}/bgs:latest
docker tag at-jetstream:latest localhost:${dport}/jetstream:latest
docker tag at-bsky:latest localhost:${dport}/bsky:latest
docker tag at-ozone-daemon:latest localhost:${dport}/ozone-daemon:latest
docker tag at-ozone:latest localhost:${dport}/ozone:latest
docker tag at-plc:latest localhost:${dport}/plc:latest
docker tag at-social-app:latest localhost:${dport}/social-app:latest
}
docker push localhost:${dport}/pds:latest
docker push localhost:${dport}/ozone-web:latest
docker push localhost:${dport}/bgs:latest
docker push localhost:${dport}/jetstream:latest
docker push localhost:${dport}/bsky:latest
docker push localhost:${dport}/ozone-daemon:latest
docker push localhost:${dport}/ozone:latest
docker push localhost:${dport}/plc:latest
docker push localhost:${dport}/social-app:latest
cd $d
docker compose down
function at-repos-push-docker() {
if [ -z "$1" ];then
for ((i=1; i<=${#img}; i++)); do
img=${imgs[$i]}
docker tag at-${img}:latest localhost:${dport}/${img}:latest
docker push localhost:${dport}/${img}:latest
done
else
docker tag at-${1}:latest localhost:${dport}/${1}:latest
docker push localhost:${dport}/${1}:latest
fi
}
function at-repos-pull-docker() {
@@ -230,24 +280,37 @@ function at-repos-pull-docker() {
docker compose up -d --pull always
}
function at-origin-social-app() {
cp -rf $d/social-app-custom $d/repos/social-app
}
at-repos-env
case "`cat /etc/hostname`" in
at)
at-repos-pull-docker
exit
;;
*)
at-repos-push-reset
at-repos-clone
at-repos-pull
at-repos-social-app-icon
at-repos-social-app-icon-origin
at-repos-social-app-avatar-write
at-repos-social-app-agent-patch
at-repos-social-app-disable-external-services-patch
at-repos-atproto-service-bsky-api-patch
at-repos-atproto-service-pds-index-patch
at-repos-social-app-agent-patch
at-repos-ozone-patch
if [ -n "$1" ];then
at-repos-build-docker-atproto $1
at-repos-push-docker $1
exit
fi
at-repos-build-docker-atproto
at-repos-build-docker-social
at-repos-push-docker
cd $d; docker compose down
;;
esac