π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Simplify albums web self-host config
Manav Rathi1426eae334b9
diff --git a/.github/workflows/web-deploy.yml b/.github/workflows/web-deploy.ymlindex 000e7e9120..9a483af2e1 100644--- a/.github/workflows/web-deploy.yml+++ b/.github/workflows/web-deploy.yml@@ -71,8 +71,6 @@ jobs:- name: Build custom-albumsrun: yarn build:albums- env:- NEXT_PUBLIC_ENTE_OFFICIAL_ALBUMS_APP: 1- name: Publish custom-albumsuses: cloudflare/wrangler-action@v3diff --git a/docs/docs/self-hosting/guides/windows.md b/docs/docs/self-hosting/guides/windows.mdindex ade8c96024..76feb83260 100644--- a/docs/docs/self-hosting/guides/windows.md+++ b/docs/docs/self-hosting/guides/windows.md@@ -188,12 +188,6 @@ services:ENTE_API_ORIGIN: http://localhost:8080# ENTE_API_ORIGIN: http://192.168.1.42:8080# ENTE_API_ORIGIN: https://api.mydomain.com- ENTE_ALBUMS_ORIGIN: http://localhost:3002- # ENTE_ALBUMS_ORIGIN: http://192.168.1.42:3002- # ENTE_ALBUMS_ORIGIN: https://albums.mydomain.com- ENTE_PHOTOS_ORIGIN: http://localhost:3000- # ENTE_PHOTOS_ORIGIN: http://192.168.1.42:3000- # ENTE_PHOTOS_ORIGIN: https://photos.mydomain.comhealthcheck:test: ["CMD", "curl", "-f", "http://localhost:3000"]@@ -311,7 +305,7 @@ Follow https://ente.com/help/self-hosting/installation/post-install and enjoy th- For non-Windows setups, find the recommended service manager for your OS (e.g. `systemd`), and configure it to use the following startup command: `cd /path/to/ente && docker stack deploy -c docker-compose.yaml ente`-2. To expose ente on your local network or custom domain, update the relevant app endpoints in `museum.yaml` and the three ORIGIN values in `docker-compose.yaml` (if you want web support).+2. To expose ente on your local network or custom domain, update `ENTE_API_ORIGIN` in `docker-compose.yaml` and the relevant app endpoints in `museum.yaml`.- For custom domains, I use a Cloudflare tunnel. Cloudflare client comes with a reverse proxy.- If you don't want to use a custom domain, but still want your ente service exposed publicly, Tailscale is a good choice. However, their "funnel" only routes to a single port, so you will need to set up your own reverse proxy. Caddy and Nginx are both great options which can be deployed as part of your existing `docker-compose.yaml`.- If you just want to connect through a VPN, Tailscale is the ideal choice, no reverse proxy necessary.diff --git a/docs/docs/self-hosting/installation/env-var.md b/docs/docs/self-hosting/installation/env-var.mdindex 11807dd893..f02e50ae4a 100644--- a/docs/docs/self-hosting/installation/env-var.md+++ b/docs/docs/self-hosting/installation/env-var.md@@ -12,24 +12,21 @@ are documented below:## Environment Variables-A self-hosted Ente instance has to specify endpoints for both Museum (the-server) and web apps.+A self-hosted Ente web app only needs the Museum API endpoint. Web app origins are configured in `museum.yaml` under `apps`.This document outlines the essential environment variables and port mappings ofthe web apps.Here's the list of environment variables that is used by the cluster:-| Service | Environment Variable | Description | Default Value |-| ---------- | ---------------------- | ------------------------------------------------------------------------------------------------------------------ | ------------------------------- |-| `web` | `ENTE_API_ORIGIN` | Alias for `NEXT_PUBLIC_ENTE_ENDPOINT`. API Endpoint for Ente's API (Museum). | http://localhost:8080 |-| `web` | `ENTE_ALBUMS_ORIGIN` | Alias for `NEXT_PUBLIC_ENTE_ALBUMS_ENDPOINT`. Base URL for the Ente Albums app, used for public sharing. | http://localhost:3002 |-| `web` | `ENTE_PHOTOS_ORIGIN` | Alias for `NEXT_PUBLIC_ENTE_PHOTOS_ENDPOINT`. Base URL for Ente Photos web app. | http://localhost:3000 |-| `postgres` | `POSTGRES_USER` | Username for PostgreSQL database | `pguser` |-| `postgres` | `POSTGRES_DB` | Name of database for use with Ente | `ente_db` |-| `postgres` | `POSTGRES_PASSWORD` | Password for PostgreSQL database's user | Randomly generated (quickstart) |-| `minio` | `MINIO_ROOT_USER` | Username for MinIO | Randomly generated (quickstart) |-| `minio` | `MINIO_ROOT_PASSWORD` | Password for MinIO | Randomly generated (quickstart) |+| Service | Environment Variable | Description | Default Value |+| ---------- | --------------------- | ---------------------------------------------------------------------------- | ------------------------------- |+| `web` | `ENTE_API_ORIGIN` | Alias for `NEXT_PUBLIC_ENTE_ENDPOINT`. API Endpoint for Ente's API (Museum). | http://localhost:8080 |+| `postgres` | `POSTGRES_USER` | Username for PostgreSQL database | `pguser` |+| `postgres` | `POSTGRES_DB` | Name of database for use with Ente | `ente_db` |+| `postgres` | `POSTGRES_PASSWORD` | Password for PostgreSQL database's user | Randomly generated (quickstart) |+| `minio` | `MINIO_ROOT_USER` | Username for MinIO | Randomly generated (quickstart) |+| `minio` | `MINIO_ROOT_PASSWORD` | Password for MinIO | Randomly generated (quickstart) |## Default Configurationdiff --git a/docs/docs/self-hosting/installation/manual.md b/docs/docs/self-hosting/installation/manual.mdindex 2fa0d585fb..f29a6385af 100644--- a/docs/docs/self-hosting/installation/manual.md+++ b/docs/docs/self-hosting/installation/manual.md@@ -188,10 +188,6 @@ Values you used for `database name` and `username` correspond to the values you```shell# Replace this with actual endpoint for Museumexport NEXT_PUBLIC_ENTE_ENDPOINT=http://localhost:8080- # Replace this with actual endpoint for Albums- export NEXT_PUBLIC_ENTE_ALBUMS_ENDPOINT=http://localhost:3002- # Replace this with actual endpoint for Photos- export NEXT_PUBLIC_ENTE_PHOTOS_ENDPOINT=http://localhost:3000```3. Build the needed applications (Photos, Albums, Accounts, Auth, Cast, PublicLocker, Embed, Memories) as per your needs:diff --git a/server/config/example.env b/server/config/example.envindex 71860689f9..cce51cc3c5 100644--- a/server/config/example.env+++ b/server/config/example.env@@ -23,9 +23,5 @@ MINIO_ROOT_USER=-MINIO_ROOT_PASSWORD=<secret># Service: Web-# This is used for configuring the self-hosted web app origins and API-# endpoint.-# Replace the below endpoints to the correct subdomains of your choice.+# Replace this with the API endpoint for Museum.ENTE_API_ORIGIN=http://localhost:8080-ENTE_ALBUMS_ORIGIN=http://localhost:3002-ENTE_PHOTOS_ORIGIN=http://localhost:3000diff --git a/server/quickstart.sh b/server/quickstart.shindex c6fdbba0c8..1df161a145 100755--- a/server/quickstart.sh+++ b/server/quickstart.sh@@ -108,8 +108,6 @@ services:# Modify these values to your custom subdomains, if using anyenvironment:ENTE_API_ORIGIN: http://localhost:8080- ENTE_ALBUMS_ORIGIN: http://localhost:3002- ENTE_PHOTOS_ORIGIN: http://localhost:3000postgres:image: postgres:15diff --git a/web/Dockerfile b/web/Dockerfileindex 626e5cc127..4235a59d6e 100644--- a/web/Dockerfile+++ b/web/Dockerfile@@ -15,8 +15,6 @@ COPY rust/contacts ./rust/contactsWORKDIR /build/webENV NEXT_PUBLIC_ENTE_ENDPOINT=ENTE_API_ORIGIN_PLACEHOLDER-ENV NEXT_PUBLIC_ENTE_ALBUMS_ENDPOINT=ENTE_ALBUMS_ORIGIN_PLACEHOLDER-ENV NEXT_PUBLIC_ENTE_PHOTOS_ENDPOINT=ENTE_PHOTOS_ORIGIN_PLACEHOLDER# `yarn install` is flaky on the GitHub arm64 runners otherwise.RUN yarn config set network-timeout 900000 -g@@ -97,20 +95,10 @@ EXPOSE 3008EXPOSE 3010ENV ENTE_API_ORIGIN=http://localhost:8080-ENV ENTE_ALBUMS_ORIGIN=http://localhost:3002-ENV ENTE_PHOTOS_ORIGIN=http://localhost:3000COPY <<EOF /docker-entrypoint.d/90-replace-ente-env.shfind /out -name '*.js' |xargs sed -i'' "s#ENTE_API_ORIGIN_PLACEHOLDER#\$ENTE_API_ORIGIN#g"-find /out/photos -name '*.js' |- xargs sed -i'' "s#ENTE_ALBUMS_ORIGIN_PLACEHOLDER#\$ENTE_ALBUMS_ORIGIN#g"-find /out/albums -name '*.js' |- xargs sed -i'' "s#ENTE_ALBUMS_ORIGIN_PLACEHOLDER#\$ENTE_ALBUMS_ORIGIN#g"-find /out/photos -name '*.js' |- xargs sed -i'' "s#ENTE_PHOTOS_ORIGIN_PLACEHOLDER#\$ENTE_PHOTOS_ORIGIN#g"-find /out/albums -name '*.js' |- xargs sed -i'' "s#ENTE_PHOTOS_ORIGIN_PLACEHOLDER#\$ENTE_PHOTOS_ORIGIN#g"EOFRUN chmod +x /docker-entrypoint.d/90-replace-ente-env.shdiff --git a/web/apps/albums/src/public-album/page/PublicAlbumPage.tsx b/web/apps/albums/src/public-album/page/PublicAlbumPage.tsxindex f9e6b01d37..0d032be0f4 100644--- a/web/apps/albums/src/public-album/page/PublicAlbumPage.tsx+++ b/web/apps/albums/src/public-album/page/PublicAlbumPage.tsx@@ -75,10 +75,8 @@ import {} from "ente-base/http";import log from "ente-base/log";import {- albumsAppOrigin,apiOrigin,- isCustomAlbumsAppOrigin,- isOfficialAlbumsApp,+ isCustomAPIOrigin,photosAppOrigin,} from "ente-base/origins";import type { Collection } from "ente-media/collection";@@ -242,11 +240,11 @@ export default function PublicAlbumPage() {continue: {text: t("login"),action: async () => {- if (isOfficialAlbumsApp) {+ if (isCustomAPIOrigin) {+ await router.push("/");+ } else {window.location.href = photosAppOrigin();- return;}- await router.push("/");},},cancel: false,@@ -259,23 +257,26 @@ export default function PublicAlbumPage() {*/const checkAndRedirectForTripAlbum = (collection: Collection): boolean => {if (- collection.pubMagicMetadata?.data.layout === "trip" &&- isOfficialAlbumsApp+ isCustomAPIOrigin ||+ collection.pubMagicMetadata?.data.layout !== "trip") {- const currentURL = new URL(window.location.href);- const albumsURL = new URL(albumsAppOrigin());-- if (currentURL.host !== albumsURL.host) {- isRedirectingToAlbumsAppRef.current = true;+ return false;+ }- albumsURL.search = currentURL.search;- albumsURL.hash = currentURL.hash;+ const currentURL = new URL(window.location.href);+ const albumsURL = new URL("https://albums.ente.com");- window.location.href = albumsURL.href;- return true;- }+ if (currentURL.host === albumsURL.host) {+ return false;}- return false;++ isRedirectingToAlbumsAppRef.current = true;++ albumsURL.search = currentURL.search;+ albumsURL.hash = currentURL.hash;++ window.location.href = albumsURL.href;+ return true;};useEffect(() => {@@ -302,8 +303,8 @@ export default function PublicAlbumPage() {]);const ck = await extractCollectionKeyFromShareURL(currentURL);if (!t && !ck) {- // Only redirect to ente.com if this is NOT a custom/self-hosted instance- if (!isCustomAlbumsAppOrigin) {+ // Only redirect to ente.com if this is not a self-hosted instance.+ if (!isCustomAPIOrigin) {window.location.href = "https://ente.com";redirectingToWebsite = true;}@@ -627,7 +628,9 @@ export default function PublicAlbumPage() {const commentsEnabled =publicCollection?.publicURLs[0]?.enableComment ?? false;- const joinEnabled = publicCollection?.publicURLs[0]?.enableJoin ?? false;+ const joinEnabled =+ !isCustomAPIOrigin &&+ (publicCollection?.publicURLs[0]?.enableJoin ?? false);const handleDrop = useCallback((files: FileWithPath[]) => {setShouldRenderUpload(true);setDragAndDropFiles(files);@@ -744,7 +747,7 @@ export default function PublicAlbumPage() {collectionKey={collectionKey.current!}enableDownload={downloadEnabled}enableComment={commentsEnabled}- enableJoin={publicCollection.publicURLs[0]?.enableJoin}+ enableJoin={joinEnabled}onJoinAlbum={handleJoinAlbum}onVisualFeedback={handleVisualFeedback}onAddSaveGroup={onAddSaveGroup}@@ -767,7 +770,7 @@ export default function PublicAlbumPage() {collectionKey={collectionKey.current}credentials={credentials}enableComment={commentsEnabled}- enableJoin={publicCollection?.publicURLs[0]?.enableJoin}+ enableJoin={joinEnabled}/>) : (<>@@ -826,7 +829,7 @@ export default function PublicAlbumPage() {collectionKey={collectionKey.current}onJoinAlbum={handleJoinAlbum}enableComment={commentsEnabled}- enableJoin={publicCollection?.publicURLs[0]?.enableJoin}+ enableJoin={joinEnabled}pendingFileIndex={pendingFileNavigation?.fileIndex}pendingFileSidebar={pendingFileNavigation?.sidebar}pendingHighlightCommentID={diff --git a/web/apps/embed/src/pages/index.tsx b/web/apps/embed/src/pages/index.tsxindex 74bbc9b18b..34c6e7609a 100644--- a/web/apps/embed/src/pages/index.tsx+++ b/web/apps/embed/src/pages/index.tsx@@ -13,7 +13,7 @@ import {type PublicAlbumsCredentials,} from "ente-base/http";import log from "ente-base/log";-import { apiOrigin, isCustomAlbumsAppOrigin } from "ente-base/origins";+import { apiOrigin, isCustomAPIOrigin } from "ente-base/origins";import { downloadManager } from "ente-gallery/services/download";import { extractCollectionKeyFromShareURL } from "ente-gallery/services/share";import { sortFiles } from "ente-gallery/utils/file";@@ -148,8 +148,8 @@ export default function EmbedGallery() {const t = currentURL.searchParams.get("t");const ck = await extractCollectionKeyFromShareURL(currentURL);if (!t && !ck) {- // Only redirect to ente.com if this is NOT a custom/self-hosted instance- if (!isCustomAlbumsAppOrigin) {+ // Only redirect to ente.com if this is not a self-hosted instance.+ if (!isCustomAPIOrigin) {window.location.href = "https://ente.com";redirectingToWebsite = true;}diff --git a/web/docs/docker.md b/web/docs/docker.mdindex 73cbe7ae73..ea6260b8c6 100644--- a/web/docs/docker.md+++ b/web/docs/docker.md@@ -22,19 +22,11 @@ you could:docker run -it --rm -p 8000:3000 ghcr.io/ente-io/web```-These images accept four environment variables to allow you to customize them:+These images accept one environment variable:- `ENTE_API_ORIGIN` - The API origin (scheme://host:port) for your API server.Default: "http://localhost:8080".-- `ENTE_ALBUMS_ORIGIN` - The externally visible origin where the albums app is- hosted. This is used for public album links and handoffs between the photos- and albums apps. Default: "http://localhost:3002".--- `ENTE_PHOTOS_ORIGIN` - The externally visible origin where the photos app is- hosted. This is used for features like join album links. Default:- "http://localhost:3000".-For example, if your API server is running at `https://api.example.org`, you canconfigure your Docker image to connect to it:@@ -42,6 +34,10 @@ configure your Docker image to connect to it:docker run -it --rm -e ENTE_API_ORIGIN=https://api.example.org ghcr.io/ente-io/web```+> [!TIP]+>+> Configure web app origins, such as Photos and Albums, in Museum's `apps` section.+### DockerfileIf you're manually building the Docker image using `web/Dockerfile` instead of using prebuilt `ghcr.io/ente-io/web` image, remember to run the build from the repo root since the context requires both the `web` and `rust` folders.diff --git a/web/packages/base/components/Head.tsx b/web/packages/base/components/Head.tsxindex 2d72c2cde8..fc3adea0f0 100644--- a/web/packages/base/components/Head.tsx+++ b/web/packages/base/components/Head.tsx@@ -2,8 +2,7 @@ import Head from "next/head";import React from "react";import { haveWindow } from "../env";import {- albumsAppOrigin,- isCustomAlbumsAppOrigin,+ isCustomAPIOrigin,isCustomShareAppOrigin,shareAppOrigin,} from "../origins";@@ -59,8 +58,8 @@ export const CustomHead: React.FC<React.PropsWithChildren<CustomHeadProps>> = ({** - "og:image" needs to be an absolute URL.*- * To avoid getting in the way of self hosters, we do a deployment URL check- * before inlining this into the build.+ * To avoid getting in the way of self hosters, only inline this into builds+ * that use Ente's production API.*/export const CustomHeadAlbumsStatic: React.FC = () => (<Head>@@ -89,14 +88,12 @@ export const CustomHeadAlbumsStatic: React.FC = () => (* A convenience fan out to conditionally show one of {@link CustomHead} or* {@link CustomHeadAlbumsStatic}.*- * This component defaults to {@link CustomHeadAlbumsStatic} during SSR unless a- * custom endpoint is defined, and then does a client side update when it- * detects that the origin it is being served on is not the albums origin.+ * Use static production preview tags only when using Ente's production API.+ * Custom API builds should not inline production preview metadata into the+ * static HTML.*/export const CustomHeadAlbums: React.FC<CustomHeadProps> = ({ title }) =>- isCustomAlbumsAppOrigin ||- (haveWindow() &&- new URL(window.location.href).origin != albumsAppOrigin()) ? (+ isCustomAPIOrigin ? (<CustomHead {...{ title }}><AlbumsFontPreloads /></CustomHead>diff --git a/web/packages/base/next.config.base.js b/web/packages/base/next.config.base.jsindex 9be7ac92e3..938e3ba47b 100644--- a/web/packages/base/next.config.base.js+++ b/web/packages/base/next.config.base.js@@ -73,7 +73,7 @@ const desktopAppVersion = isDesktop.version: undefined;-// Fail the build if the user is setting any of the legacy environment variables+// Fail the build if the user is setting legacy environment variables// which have now been replaced with museum configuration. This is meant to help// self hosters find the new setting instead of being caught unawares.@@ -93,6 +93,26 @@ if (process.env.NEXT_PUBLIC_ENTE_FAMILY_URL) {process.exit(1);}+// Print a notice if the user is setting legacy environment variables which+// were only client-side handoff hints, and now no-ops. The functional effects+// (previously and now) require setting Museum's app config.++if (process.env.NEXT_PUBLIC_ENTE_ALBUMS_ENDPOINT) {+ console.log(+ "The NEXT_PUBLIC_ENTE_ALBUMS_ENDPOINT environment variable is not used anymore and is ignored.",+ );+ console.log("Use apps.public-albums in the museum configuration instead.");+}++if (process.env.NEXT_PUBLIC_ENTE_PHOTOS_ENDPOINT) {+ console.log(+ "The NEXT_PUBLIC_ENTE_PHOTOS_ENDPOINT environment variable is not used anymore and is ignored.",+ );+ console.log(+ "It only affected client-side handoffs; public link behavior is configured through Museum.",+ );+}+/*** Configuration for the Next.js build*diff --git a/web/packages/base/origins.ts b/web/packages/base/origins.tsindex f46677afee..1d215aa9f9 100644--- a/web/packages/base/origins.ts+++ b/web/packages/base/origins.ts@@ -59,6 +59,12 @@ export const customAPIOrigin = async () =>process.env.NEXT_PUBLIC_ENTE_ENDPOINT ??undefined;+/**+ * A static build time constant that is `true` if the API origin has been+ * customized through the environment.+ */+export const isCustomAPIOrigin = !!process.env.NEXT_PUBLIC_ENTE_ENDPOINT;+/*** A convenience wrapper over {@link customAPIOrigin} that returns the only the* host part of the custom origin (if any).@@ -81,29 +87,6 @@ export const customAPIHost = async () => {export const uploaderOrigin = async () =>(await customAPIOrigin()) ?? "https://uploader.ente.com";-/**- * A static build time constant that is `true` if {@link albumsAppOrigin} has- * been customized.- */-export const isCustomAlbumsAppOrigin =- !!process.env.NEXT_PUBLIC_ENTE_ALBUMS_ENDPOINT;--/**- * Return the origin that serves public albums.- *- * Defaults to our production instance, "https://albums.ente.com", but can be- * overridden by setting the `NEXT_PUBLIC_ENTE_ALBUMS_ENDPOINT` environment- * variable.- */-export const albumsAppOrigin = () =>- process.env.NEXT_PUBLIC_ENTE_ALBUMS_ENDPOINT ?? "https://albums.ente.com";--/**- * Return true if this build is Ente's official public albums deployment.- */-export const isOfficialAlbumsApp =- !!process.env.NEXT_PUBLIC_ENTE_OFFICIAL_ALBUMS_APP;-/*** A static build time constant that is `true` if {@link shareAppOrigin} has* been customized.@@ -122,11 +105,6 @@ export const shareAppOrigin = (): string =>process.env.NEXT_PUBLIC_ENTE_SHARE_ENDPOINT ?? "https://share.ente.com";/**- * Return the origin that serves the photos app.- *- * Defaults to our production instance, "https://photos.ente.com", but can be- * overridden by setting the `NEXT_PUBLIC_ENTE_PHOTOS_ENDPOINT` environment- * variable.+ * Return the origin that serves Ente's official photos app.*/-export const photosAppOrigin = (): string =>- process.env.NEXT_PUBLIC_ENTE_PHOTOS_ENDPOINT ?? "https://photos.ente.com";+export const photosAppOrigin = (): string => "https://photos.ente.com";