Spaces:
Running
Running
Update Dockerfile
Browse files- Dockerfile +15 -48
Dockerfile
CHANGED
|
@@ -2,68 +2,35 @@
|
|
| 2 |
# =============================================================================
|
| 3 |
# Rochester-restricted Bluesky PDS + full Bluesky web app - single Dockerfile.
|
| 4 |
#
|
| 5 |
-
#
|
| 6 |
-
#
|
| 7 |
-
#
|
| 8 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
#
|
| 10 |
# Listens on port 7860 (HF forwards the public Space URL to it automatically).
|
| 11 |
# =============================================================================
|
| 12 |
|
| 13 |
-
# ---------------------------------------------------------------- build stage
|
| 14 |
FROM node:24-bookworm-slim AS webapp
|
| 15 |
|
| 16 |
-
# Pin pnpm explicitly: package.json's packageManager field is not the classic
|
| 17 |
-
# "pnpm@x.y.z" string, so corepack would otherwise pick the latest pnpm,
|
| 18 |
-
# which cannot read this repo's lockfile. 11.21.0 is the version declared in
|
| 19 |
-
# devEngines and verified against pnpm-lock.yaml.
|
| 20 |
-
RUN corepack enable && corepack prepare pnpm@11.21.0 --activate
|
| 21 |
RUN apt-get update && apt-get install -y --no-install-recommends git ca-certificates && rm -rf /var/lib/apt/lists/*
|
| 22 |
|
| 23 |
-
WORKDIR /
|
| 24 |
|
| 25 |
-
# The
|
| 26 |
-
#
|
| 27 |
-
#
|
| 28 |
-
# want them live, update SOURCE_REF (or override it as a Space build arg).
|
| 29 |
ARG SOURCE_REPO=https://github.com/CloudCompile/social-app.git
|
| 30 |
-
ARG SOURCE_REF=
|
| 31 |
-
# Fetch by SHA (clone --branch only accepts refs). GitHub allows fetching
|
| 32 |
-
# reachable commit SHAs directly.
|
| 33 |
RUN git init . \
|
| 34 |
&& git remote add origin ${SOURCE_REPO} \
|
| 35 |
&& git fetch --depth 1 origin ${SOURCE_REF} \
|
| 36 |
&& git checkout FETCH_HEAD
|
| 37 |
|
| 38 |
-
|
| 39 |
-
# intl:compile, which the webpack build needs. If the clone lost the lockfile
|
| 40 |
-
# (unlikely), fall back to a plain install.
|
| 41 |
-
RUN if [ -f pnpm-lock.yaml ]; then \
|
| 42 |
-
pnpm install --frozen-lockfile || pnpm install --no-frozen-lockfile; \
|
| 43 |
-
else \
|
| 44 |
-
echo "[build] pnpm-lock.yaml missing - regenerating" && \
|
| 45 |
-
pnpm install --no-frozen-lockfile; \
|
| 46 |
-
fi
|
| 47 |
-
|
| 48 |
-
# postinstall generated lexicons + i18n catalogs; verify they exist (the
|
| 49 |
-
# intl:compile-if-needed guard is skipped outside CI, so compile explicitly
|
| 50 |
-
# if the catalog is missing)
|
| 51 |
-
RUN test -d src/lexicons && echo "[build] lexicons OK" \
|
| 52 |
-
&& (test -f src/locale/locales/en/messages.ts || pnpm intl:compile) \
|
| 53 |
-
&& echo "[build] i18n OK"
|
| 54 |
-
|
| 55 |
-
# Build the static web app with this PDS baked in as the default service,
|
| 56 |
-
# so sign-in/sign-up default to this server (users can still pick another).
|
| 57 |
-
# On HF Spaces, set a Space variable PDS_HOSTNAME and rebuild so this matches.
|
| 58 |
-
ARG PDS_HOSTNAME=hf.space
|
| 59 |
-
ENV EXPO_PUBLIC_DEFAULT_SERVICE=https://${PDS_HOSTNAME}
|
| 60 |
-
ENV EXPO_PUBLIC_BUNDLE_IDENTIFIER=rochester-pds
|
| 61 |
-
ENV NODE_ENV=production
|
| 62 |
-
RUN pnpm run build-web || (npx expo export:web && node ./scripts/post-web-build.js)
|
| 63 |
-
|
| 64 |
-
# post-web-build copies assets into bskyweb/static; for static hosting we serve
|
| 65 |
-
# web-build directly, so just make sure it exists
|
| 66 |
-
RUN test -d web-build
|
| 67 |
|
| 68 |
# --------------------------------------------------------------- server stage
|
| 69 |
FROM ghcr.io/bluesky-social/pds:0.4
|
|
@@ -71,7 +38,7 @@ FROM ghcr.io/bluesky-social/pds:0.4
|
|
| 71 |
USER root
|
| 72 |
|
| 73 |
# Web app bundle
|
| 74 |
-
COPY --from=webapp /
|
| 75 |
|
| 76 |
# Write the email-allowlist patcher into the image.
|
| 77 |
RUN <<'PATCH'
|
|
|
|
| 2 |
# =============================================================================
|
| 3 |
# Rochester-restricted Bluesky PDS + full Bluesky web app - single Dockerfile.
|
| 4 |
#
|
| 5 |
+
# The web client (bsky.app React Native Web SPA) is prebuilt by GitHub Actions
|
| 6 |
+
# (workflow: .github/workflows/prebuild-web.yml) and force-pushed to the
|
| 7 |
+
# `prebuilt-web` branch. This image simply copies that static bundle into the
|
| 8 |
+
# official PDS image and patches it at boot to (a) restrict registration to
|
| 9 |
+
# @rochesterschools.org and (b) serve the web app at / with an SPA fallback.
|
| 10 |
+
#
|
| 11 |
+
# No Node build happens here - so this builds fast and fits in low-memory
|
| 12 |
+
# builders like HF Spaces free tier.
|
| 13 |
#
|
| 14 |
# Listens on port 7860 (HF forwards the public Space URL to it automatically).
|
| 15 |
# =============================================================================
|
| 16 |
|
|
|
|
| 17 |
FROM node:24-bookworm-slim AS webapp
|
| 18 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
RUN apt-get update && apt-get install -y --no-install-recommends git ca-certificates && rm -rf /var/lib/apt/lists/*
|
| 20 |
|
| 21 |
+
WORKDIR /bundle
|
| 22 |
|
| 23 |
+
# The prebuilt bundle lives on the `prebuilt-web` branch (pushed by
|
| 24 |
+
# prebuild-web.yml). Update SOURCE_REF to the commit of that branch whenever
|
| 25 |
+
# the web app changes and the workflow has run.
|
|
|
|
| 26 |
ARG SOURCE_REPO=https://github.com/CloudCompile/social-app.git
|
| 27 |
+
ARG SOURCE_REF=prebuilt-web
|
|
|
|
|
|
|
| 28 |
RUN git init . \
|
| 29 |
&& git remote add origin ${SOURCE_REPO} \
|
| 30 |
&& git fetch --depth 1 origin ${SOURCE_REF} \
|
| 31 |
&& git checkout FETCH_HEAD
|
| 32 |
|
| 33 |
+
RUN test -f index.html || { echo "prebuilt-web branch has no index.html - run the prebuild-web workflow first"; exit 1; }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 34 |
|
| 35 |
# --------------------------------------------------------------- server stage
|
| 36 |
FROM ghcr.io/bluesky-social/pds:0.4
|
|
|
|
| 38 |
USER root
|
| 39 |
|
| 40 |
# Web app bundle
|
| 41 |
+
COPY --from=webapp /bundle /app/web
|
| 42 |
|
| 43 |
# Write the email-allowlist patcher into the image.
|
| 44 |
RUN <<'PATCH'
|