From 9533aea792302ada9c89188483a4953662855499 Mon Sep 17 00:00:00 2001 From: Eric Bailey Date: Wed, 22 Jan 2025 17:45:12 -0600 Subject: [PATCH] Clean up --- .env.example | 37 +++++++++++++-------------- Dockerfile.small | 66 ++++++++++++++++++++++++++---------------------- src/env.ts | 3 ++- 3 files changed, 55 insertions(+), 51 deletions(-) diff --git a/.env.example b/.env.example index b71113f52a..7dbf94070a 100644 --- a/.env.example +++ b/.env.example @@ -1,25 +1,5 @@ -# Copy this to `.env.local` and `.env.test` files - # The env the app is running in e.g. development, testflight, production EXPO_PUBLIC_ENV=development - -# App view DID -EXPO_PUBLIC_APPVIEW_DID= - -# Chat service DID -EXPO_PUBLIC_CHAT_DID= - -# Bitdrift -BITDRIFT_API_KEY= - -# Sentry (deprecated) -SENTRY_AUTH_TOKEN= - -# The log level for the app. -EXPO_PUBLIC_LOG_LEVEL=debug -# Currently unused. Enable debug for a subset of the debug logs. -EXPO_PUBLIC_LOG_DEBUG= - # 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. @@ -28,3 +8,20 @@ EXPO_PUBLIC_BUNDLE_IDENTIFIER= # 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= diff --git a/Dockerfile.small b/Dockerfile.small index dbde4cf809..5e4e5f1b6f 100644 --- a/Dockerfile.small +++ b/Dockerfile.small @@ -1,58 +1,71 @@ FROM golang:1.23-bullseye AS build-env - WORKDIR /usr/src/social-app - ENV DEBIAN_FRONTEND=noninteractive -# Node +# +# Environment: node +# ENV NODE_VERSION=20 ENV NVM_DIR=/usr/share/nvm -# Go + +# +# Environment: golang +# ENV GODEBUG="netdns=go" ENV GOOS="linux" ENV GOARCH="amd64" ENV CGO_ENABLED=1 ENV GOEXPERIMENT="loopvar" -# App -ARG EXPO_PUBLIC_BUNDLE_IDENTIFIER -ARG EXPO_PUBLIC_APPVIEW_DID -ARG BSKYWEB_APPVIEW_HOST -ENV EXPO_PUBLIC_BUNDLE_IDENTIFIER=${EXPO_PUBLIC_BUNDLE_IDENTIFIER:-dev} -ENV BSKYWEB_APPVIEW_HOST=${BSKYWEB_APPVIEW_HOST:-https://public.api.bsky.app} +# +# 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 - -# Install Node and dependencies -RUN \. "$NVM_DIR/nvm.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_APPVIEW_DID=$EXPO_PUBLIC_APPVIEW_DID \ 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 -# Debug -RUN find ./bskyweb/static && find ./web-build/static - -# Generate the bskyweb Go binary. +# +# Build the Go webserver binary +# RUN cd bskyweb/ && \ go mod download && \ go mod verify && \ - echo "GOLOG_LOG_LEVEL=info" >> .env && \ - echo "ATP_APPVIEW_HOST=$BSKYWEB_APPVIEW_HOST" >> .env - -RUN cd bskyweb/ && \ go build \ -v \ -trimpath \ @@ -63,24 +76,17 @@ RUN cd 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 diff --git a/src/env.ts b/src/env.ts index 2ed5fdd6bf..03f1c45283 100644 --- a/src/env.ts +++ b/src/env.ts @@ -14,7 +14,8 @@ export const IS_INTERNAL = __DEV__ || IS_TESTFLIGHT * The DID of the appview service to proxy to. If undefined, use Bluesky's * default app view. */ -export const APPVIEW_DID: Did | undefined = process.env.EXPO_PUBLIC_APPVIEW_DID +export const APPVIEW_DID: Did | undefined = + process.env.EXPO_PUBLIC_APPVIEW_PROXY_DID /** * The DID of the chat service to proxy to. If undefined, chat should be