Compare commits

...

26 Commits

Author SHA1 Message Date
Eric Bailey f056b81e32 Better proxy handling 2025-02-03 10:24:40 -06:00
Eric Bailey 0fc2668b5a Rename, update var in dev 2025-01-22 17:50:54 -06:00
Eric Bailey 9533aea792 Clean up 2025-01-22 17:45:12 -06:00
Eric Bailey 6fb52fabcc Ok maybe fix env 2025-01-22 17:00:19 -06:00
Eric Bailey 52bb9b04f1 Retain context in command 2025-01-22 15:56:21 -06:00
Eric Bailey 5911aebdf2 Cleanup dockerfile 2025-01-22 15:50:55 -06:00
Eric Bailey 868a991c55 Fix env 2025-01-22 15:08:35 -06:00
Eric Bailey eaddf13f05 Fix env 2025-01-22 15:07:57 -06:00
Eric Bailey 100d879713 Clean up env vars 2025-01-22 14:53:43 -06:00
Eric Bailey b308f09d4f Forgot to add proxy did 2025-01-22 14:38:57 -06:00
Eric Bailey 87ae4533d4 Add serve command 2025-01-22 13:59:20 -06:00
Eric Bailey d5ea9e0011 Ope fix path 2025-01-22 13:15:00 -06:00
Eric Bailey 386d04b098 Output env, fix dir 2025-01-22 12:45:29 -06:00
Eric Bailey 298f398a75 Add smallworld dockerfile 2025-01-22 11:37:16 -06:00
Eric Bailey 4f2f96c994 WIP rework env file 2025-01-22 11:15:26 -06:00
Eric Bailey e4af97f80d Update .env.example 2025-01-22 11:15:26 -06:00
rafael aa9f622f04 rename APPVIEW_PROXY -> APPVIEW_DID 2025-01-22 11:15:26 -06:00
Eric Bailey cad07f5dc2 Rm trending passthrough in dev 2025-01-22 11:15:26 -06:00
Eric Bailey 686b055d03 Add back locale compilation 2025-01-22 11:15:26 -06:00
Eric Bailey d376969a0d Configure proxy 2025-01-22 11:15:26 -06:00
Eric Bailey cea35fafd5 Add env to Dockerfile.dev 2025-01-22 11:15:26 -06:00
Eric Bailey 19fc4535b2 Use new env var 2025-01-22 11:15:26 -06:00
Eric Bailey 2eb19981ba Remove lingui postinstall for now 2025-01-22 11:15:26 -06:00
Eric Bailey 7aa97e244c Add Dockerfile.dev 2025-01-22 11:15:26 -06:00
Eric Bailey 7afefccdd0 Test commit 2025-01-22 11:15:26 -06:00
Eric Bailey f421821b06 Override service 2025-01-22 11:15:26 -06:00
6 changed files with 218 additions and 13 deletions
+25 -6
View File
@@ -1,8 +1,27 @@
# Copy this to `.env` and `.env.test` files
BITDRIFT_API_KEY=
SENTRY_AUTH_TOKEN=
EXPO_PUBLIC_LOG_LEVEL=debug
EXPO_PUBLIC_LOG_DEBUG=
# The env the app is running in e.g. development, testflight, production
EXPO_PUBLIC_ENV=development
# This is the commit hash that the current bundle was made from. The user can
# see the commit hash in the app's settings along with the other version info.
# Useful for debugging/reporting.
EXPO_PUBLIC_BUNDLE_IDENTIFIER=
# This will always be in the format of YYMMDD, so that it always increases for
# each build. This should only be used for Statsig reporting and shouldn't be
# used to identify a specific bundle.
EXPO_PUBLIC_BUNDLE_DATE=0
# Optional app view proxy DID
EXPO_PUBLIC_APPVIEW_PROXY_DID=
# The log level for the app's logger transports
EXPO_PUBLIC_LOG_LEVEL=info
# Currently unused. Enable debug for a subset of the debug logs.
EXPO_PUBLIC_LOG_DEBUG=
#
# Bluesky specific
#
# Chat service DID
EXPO_PUBLIC_CHAT_DID=
# Bitdrift
BITDRIFT_API_KEY=
# Sentry (deprecated)
SENTRY_AUTH_TOKEN=
+92
View File
@@ -0,0 +1,92 @@
FROM golang:1.23-bullseye AS build-env
WORKDIR /usr/src/social-app
ENV DEBIAN_FRONTEND=noninteractive
#
# Environment: node
#
ENV NODE_VERSION=20
ENV NVM_DIR=/usr/share/nvm
#
# Environment: golang
#
ENV GODEBUG="netdns=go"
ENV GOOS="linux"
ENV GOARCH="amd64"
ENV CGO_ENABLED=1
ENV GOEXPERIMENT="loopvar"
#
# Evironment: app
#
# Optional app view proxy DID
ARG EXPO_PUBLIC_APPVIEW_PROXY_DID
# This is the commit hash that the current bundle was made from. The user can
# see the commit hash in the app's settings along with the other version info.
# Useful for debugging/reporting.
ARG EXPO_PUBLIC_BUNDLE_IDENTIFIER
ENV EXPO_PUBLIC_BUNDLE_IDENTIFIER=${EXPO_PUBLIC_BUNDLE_IDENTIFIER:-self-hosted-bluesky}
# The log level for the app's logger transports
ARG EXPO_PUBLIC_LOG_LEVEL
ENV EXPO_PUBLIC_LOG_LEVEL=${EXPO_PUBLIC_LOG_LEVEL:-info}
#
# Copy everything into the container.
#
COPY . .
#
# Install NVM
# Install Node
# Install Yarn
# Install dependencies
#
RUN mkdir --parents $NVM_DIR && \
wget \
--output-document=/tmp/nvm-install.sh \
https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh && \
bash /tmp/nvm-install.sh && \
\. "$NVM_DIR/nvm.sh" && \
nvm install $NODE_VERSION && \
nvm use $NODE_VERSION && \
npm install --global yarn && \
yarn && \
yarn intl:build && \
EXPO_PUBLIC_ENV=production \
EXPO_PUBLIC_BUNDLE_IDENTIFIER=$EXPO_PUBLIC_BUNDLE_IDENTIFIER \
EXPO_PUBLIC_BUNDLE_DATE=$(date -u +"%y%m%d%H") \
EXPO_PUBLIC_APPVIEW_PROXY_DID=$EXPO_PUBLIC_APPVIEW_PROXY_DID \
EXPO_PUBLIC_LOG_LEVEL=$EXPO_PUBLIC_LOG_LEVEL \
yarn build-web
#
# Build the Go webserver binary
#
RUN cd bskyweb/ && \
go mod download && \
go mod verify && \
go build \
-v \
-trimpath \
-tags timetzdata \
-o /bskyweb \
./cmd/bskyweb
#
# Build the final image.
#
FROM debian:bullseye-slim
ENV GODEBUG=netdns=go
ENV TZ=Etc/UTC
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update && apt-get install --yes \
dumb-init \
ca-certificates
ENTRYPOINT ["dumb-init", "--"]
WORKDIR /bskyweb
COPY --from=build-env /bskyweb /usr/bin/bskyweb
CMD ["/usr/bin/bskyweb", "serve"]
LABEL org.opencontainers.image.source=https://github.com/bluesky-social/social-app
LABEL org.opencontainers.image.description="Self-hosted Bluesky web app"
LABEL org.opencontainers.image.licenses=MIT
+19
View File
@@ -0,0 +1,19 @@
FROM node:22.13-alpine3.20
WORKDIR /app
COPY package.json /app/package.json
COPY yarn.lock /app/yarn.lock
COPY /patches /app/patches
COPY /lingui.config.js /app/lingui.config.js
COPY /src/locale/locales /app/src/locale/locales
RUN pwd
RUN cd /app
RUN yarn
COPY . /app
ENV EXPO_PUBLIC_APPVIEW_PROXY_DID=${EXPO_PUBLIC_APPVIEW_PROXY_DID}
CMD ["yarn", "web"]
+75 -1
View File
@@ -1,6 +1,80 @@
export const LOG_DEBUG = process.env.EXPO_PUBLIC_LOG_DEBUG || ''
import {Did} from '@atproto/api'
/**
* The env the app is running in e.g. development, testflight, production
*/
export const EXPO_PUBLIC_ENV = process.env.EXPO_PUBLIC_ENV
/**
* Indicates whether the app is running in TestFlight mode
*/
export const IS_TESTFLIGHT = EXPO_PUBLIC_ENV === 'testflight'
/**
* Indicates whether the app is __DEV__ or TestFlight
*/
export const IS_INTERNAL = __DEV__ || IS_TESTFLIGHT
/**
* The commit hash that the current bundle was made from. The user can see the
* commit hash in the app's settings along with the other version info. Useful
* for debugging/reporting.
*/
export const BUNDLE_IDENTIFIER: string =
process.env.EXPO_PUBLIC_BUNDLE_IDENTIFIER ?? ''
/**
* This will always be in the format of YYMMDD, so that it always increases for
* each build. This should only be used for Statsig reporting and shouldn't be
* used to identify a specific bundle.
*/
export const BUNDLE_DATE: number = IS_INTERNAL
? 0
: Number(process.env.EXPO_PUBLIC_BUNDLE_DATE)
/**
* The DID of the appview service to proxy to. If undefined, use Bluesky's
* default app view.
*/
export const APPVIEW_PROXY_DID: Did =
process.env.EXPO_PUBLIC_APPVIEW_PROXY_DID || 'did:web:api.bsky.app'
/**
* The appview service to proxy to, derived from the APPVIEW_PROXY_DID.
* Otherwise defaults to Bluesky's default app view.
*/
export const PUBLIC_APPVIEW_SERVICE: string = APPVIEW_PROXY_DID
? 'https://' + APPVIEW_PROXY_DID.split(':')[2]
: 'https://public.api.bsky.app'
/**
* The log level for the app.
*/
export const LOG_LEVEL = (process.env.EXPO_PUBLIC_LOG_LEVEL || 'info') as
| 'debug'
| 'info'
| 'warn'
| 'error'
/**
* Currently unused. Enable debug for a subset of the debug logs.
*/
export const LOG_DEBUG: string = process.env.EXPO_PUBLIC_LOG_DEBUG || ''
/**
* The DID of the chat service to proxy to. If undefined, chat should be
* disabled.
*/
export const CHAT_DID: Did | undefined = process.env.EXPO_PUBLIC_CHAT_DID
/**
* Bitdrift API key. If undefined, Bitdrift should be disabled.
*/
export const BITDRIFT_API_KEY: string | undefined =
process.env.EXPO_PUBLIC_BITDRIFT_API_KEY
/**
* Sentry API key. If undefined, Sentry should be disabled.
*/
export const SENTRY_API_KEY: string | undefined =
process.env.EXPO_PUBLIC_SENTRY_API_KEY
+7 -2
View File
@@ -6,13 +6,14 @@ import {
BSKY_SERVICE,
DISCOVER_SAVED_FEED,
IS_PROD_SERVICE,
PUBLIC_BSKY_SERVICE,
TIMELINE_SAVED_FEED,
} from '#/lib/constants'
import {tryFetchGates} from '#/lib/statsig/statsig'
import {getAge} from '#/lib/strings/time'
import {logger} from '#/logger'
import {snoozeEmailConfirmationPrompt} from '#/state/shell/reminders'
import {PUBLIC_APPVIEW_SERVICE} from '#/env'
import {APPVIEW_PROXY_DID} from '#/env'
import {emitNetworkConfirmed, emitNetworkLost} from '../events'
import {addSessionErrorLog} from './logging'
import {
@@ -24,7 +25,8 @@ import {isSessionExpired, isSignupQueued} from './util'
export function createPublicAgent() {
configureModerationForGuest() // Side effect but only relevant for tests
return new BskyAppAgent({service: PUBLIC_BSKY_SERVICE})
// TODO logged out view
return new BskyAppAgent({service: PUBLIC_APPVIEW_SERVICE})
}
export async function createAgentAndResume(
@@ -36,6 +38,7 @@ export async function createAgentAndResume(
) => void,
) {
const agent = new BskyAppAgent({service: storedAccount.service})
agent.configureProxy(`${APPVIEW_PROXY_DID}#bsky_appview`)
if (storedAccount.pdsUrl) {
agent.sessionManager.pdsUrl = new URL(storedAccount.pdsUrl)
}
@@ -83,6 +86,7 @@ export async function createAgentAndLogin(
) => void,
) {
const agent = new BskyAppAgent({service})
agent.configureProxy(`${APPVIEW_PROXY_DID}#bsky_appview`)
await agent.login({identifier, password, authFactorToken})
const account = agentToSessionAccountOrThrow(agent)
@@ -118,6 +122,7 @@ export async function createAgentAndCreateAccount(
) => void,
) {
const agent = new BskyAppAgent({service})
agent.configureProxy(`${APPVIEW_PROXY_DID}#bsky_appview`)
await agent.createAccount({
email,
password,
-4
View File
@@ -18,10 +18,6 @@ export function Provider({children}: React.PropsWithChildren<{}>) {
const langPrefs = useLanguagePrefs()
const {data: config, isLoading: isInitialLoad} = useServiceConfigQuery()
const ctx = React.useMemo<Context>(() => {
if (__DEV__) {
return {enabled: true}
}
/*
* Only English during beta period
*/