WIP
This commit is contained in:
parent
badece4cce
commit
c921399540
3 changed files with 82 additions and 62 deletions
|
@ -1,43 +1,36 @@
|
|||
# Sample configuration file
|
||||
#
|
||||
# All variables are commented out by default. Copy paste this into a new file
|
||||
# called `.env.local`, or create a new file with that name and add the
|
||||
# environment variables you need into it. That `.env.local` file will be
|
||||
# .gitignored, so you can freely customize how the app runs in your local setup.
|
||||
# called `.env.local` (or create a new file with that name) and add the
|
||||
# environment variables you want to apply during development. `.env.local` is
|
||||
# gitignored, so you can freely customize it for your local setup.
|
||||
#
|
||||
# - `.env.local` is picked up by next when NODE_ENV is development
|
||||
# `.env.local` is picked up by Next.js when NODE_ENV is 'development' (it is
|
||||
# 'production' by default, but gets set to 'development' when we run `next dev`)
|
||||
#
|
||||
# - `.env` is picked up always
|
||||
#
|
||||
# You don't necessarily need to use these files, these variables can be provided
|
||||
# as environment variables when running yarn dev too. e.g.
|
||||
# Alternatively, these variables can be provided as environment variables e.g.
|
||||
#
|
||||
# NEXT_PUBLIC_ENTE_ENDPOINT=http://localhost:3000 yarn dev:photos
|
||||
#
|
||||
# Variables prefixed with NEXT_PUBLIC_ (in our case, all of them) are made
|
||||
# available when next runs our code in the browser (Behind the scenes, Next just
|
||||
# hardcodes occurrences of `process.env.NEXT_PUBLIC_FOO` with the value of the
|
||||
# `NEXT_PUBLIC_FOO` env var when the bundle is built). For more details, see
|
||||
# Variables prefixed with NEXT_PUBLIC_ are made available when Next.js runs our
|
||||
# code in the browser (Behind the scenes, Next.js just hardcodes occurrences of
|
||||
# `process.env.NEXT_PUBLIC_FOO` with the value of the `NEXT_PUBLIC_FOO` env var
|
||||
# when the bundle is built). See
|
||||
# https://nextjs.org/docs/pages/building-your-application/configuring/environment-variables
|
||||
#
|
||||
# By default, the app is configured to connect to the production instance etc.
|
||||
# This is usually a good default, for example someone might want to run the
|
||||
# client locally but still use their actual ente account.
|
||||
# By default, the app is configured to connect to the production APIs. This is
|
||||
# usually a good default, for example someone might want to run the client
|
||||
# locally but still use their actual ente account.
|
||||
#
|
||||
# Even though it connects to the production instances, when invoked with `yarn
|
||||
# dev:*`, next will behave as if NODE_ENV was set to 'development' (otherwise
|
||||
# this is assumed to be 'production'). There are some other cases too when we
|
||||
# assume we're in a dev environment (e.g. the NEXT_PUBLIC_APP_ENV env var below.
|
||||
# For the full list of rules that decide what counts as a dev build, see the
|
||||
# `isDevDeployment` function).
|
||||
# However, in other aspects it (by default) behaves like a development build
|
||||
# when executed using `yarn dev:foo`:
|
||||
#
|
||||
# We have some development related conveniences tied to the dev build:
|
||||
# 1. Logs go to the browser console instead of the log file
|
||||
#
|
||||
# 2. Sentry crash reporting etc is disabled
|
||||
#
|
||||
# The variables below thus serve as ways to customize which API instance we
|
||||
# connect to for various purposes. These variables are only honoured when we're
|
||||
# in a development environment.
|
||||
# See `isDevDeployment` for the exact rules for determining what counts as a
|
||||
# development build.
|
||||
|
||||
# The ente API endpoint
|
||||
# NEXT_PUBLIC_ENTE_ENDPOINT=http://localhost:3000
|
||||
|
@ -62,39 +55,24 @@
|
|||
# Enhancement: Consider moving that into the app/ folder in this repository.
|
||||
# NEXT_PUBLIC_ENTE_FAMILY_PORTAL_ENDPOINT = http://localhost:3003
|
||||
|
||||
# This in not useful when running locally. It is used to provide us a way to
|
||||
# mark certain deployments as "staging" by setting environment variables in the
|
||||
# CI job that deploys them on a remote server. See the `isDevDeployment`
|
||||
# function.
|
||||
#
|
||||
# By default, the photos web app gets deployed to "web.ente.io".
|
||||
# NEXT_PUBLIC_ENTE_WEB_ENDPOINT = http://localhost:3000
|
||||
|
||||
# Set this to true to disable reporting of crashes to Sentry.
|
||||
#
|
||||
# Crash reporting is disabled if the user has opted out. This provides another
|
||||
# way to disable crash reporting, say for local test branches.
|
||||
# NEXT_PUBLIC_DISABLE_SENTRY=true
|
||||
|
||||
# Set this to disable the upload of files via CF Workers
|
||||
# Set this to true to disable the upload of files via CF Workers
|
||||
#
|
||||
# CF workers provide us with a way of make the file uploads faster. The why and
|
||||
# how is explained here: https://ente.io/blog/tech/making-uploads-faster/
|
||||
#
|
||||
# By default, that's the route we take. This flag can be set to true to disable
|
||||
# that route, and instead directly upload to the S3-compatible URLs provided by
|
||||
# our API server.
|
||||
# that and instead directly upload to the S3-compatible URLs returned by the
|
||||
# ente API.
|
||||
#
|
||||
# Note the double negative.
|
||||
# Mind the double negative.
|
||||
# NEXT_PUBLIC_DISABLE_CF_UPLOAD_PROXY = true
|
||||
|
||||
# This is an alternative to run as a development build.
|
||||
#
|
||||
# You likely don't need this if you're running on your machine, because when
|
||||
# invoked with `next dev` (as is the case for `yarn dev:photos` etc), next will
|
||||
# behave as if NODE_ENV was set to 'development'.
|
||||
# NEXT_PUBLIC_APP_ENV = development
|
||||
|
||||
# The path of the JSON file which contains the expected results of our
|
||||
# integration tests. See `upload.test.ts` for more details.
|
||||
# NEXT_PUBLIC_EXPECTED_JSON_PATH = /path/to/dataset/expected.json
|
||||
|
|
|
@ -72,8 +72,37 @@ export const getFamilyPortalURL = () => {
|
|||
return `https://family.ente.io`;
|
||||
};
|
||||
|
||||
/*
|
||||
It's a dev deployment (and should use the environment override for endpoints ) in three cases:
|
||||
/**
|
||||
* A build is considered as a development build if one of the following holds:
|
||||
*
|
||||
* 1. The NODE_ENV environment variable is set to 'development'. This
|
||||
* automatically happens when we run `yarn dev:foo`, but we can also
|
||||
* explictly set this to development before invoking the build. From the
|
||||
* Next.js docs:
|
||||
*
|
||||
* > If the environment variable NODE_ENV is unassigned, Next.js
|
||||
* > automatically assigns development when running the `next dev` command,
|
||||
* > or production for all other commands.
|
||||
*
|
||||
* 2. Sometimes we're building for a remote deployment, but we want the deployed
|
||||
site to behave as a development build. For example, when deploying the
|
||||
main branch to `testing.ente.io`. In these cases, since the build was done
|
||||
using `yarn export` (which in turn invokes `next build`), the NODE_ENV
|
||||
will not get set to 'development'. To handle such cases, we introduce
|
||||
another variable, NEXT_PUBLIC_ENTE_ENV, which has the same semantics as
|
||||
*
|
||||
*
|
||||
* If the environment variable NODE_ENV is unassigned, Next.js automatically
|
||||
assigns development when running the next dev command, or production for all
|
||||
other commands.
|
||||
* next sets NODE_ENV to `production`.
|
||||
* When we run
|
||||
* `yarn dev:foo`, it invokes `next dev`, which sets NODE_ENV to
|
||||
* 'development'. In all other cases (say, `next build`),
|
||||
*
|
||||
|
||||
It's a dev deployment (and should use the environment override for endpoints )
|
||||
in three cases:
|
||||
1. when the URL opened is that of the staging web app, or
|
||||
2. when the URL opened is that of the staging album app, or
|
||||
3. if the app is running locally (hence node_env is development)
|
||||
|
|
|
@ -1,33 +1,46 @@
|
|||
#!/bin/sh
|
||||
|
||||
# This script is run by the Cloudflare Pages integration when deploying the apps
|
||||
# in this repository. The app to build is decided based on the the value of the
|
||||
# CF_PAGES_BRANCH environment variable.
|
||||
# in this repository. The app to build and the environment variables to use is
|
||||
# decided based on the the value of the CF_PAGES_BRANCH environment variable.
|
||||
#
|
||||
# Ref: https://developers.cloudflare.com/pages/how-to/build-commands-branches/
|
||||
#
|
||||
# The CF Pages configuration is set to use `out/` as the build output directory,
|
||||
# so once we're done building we copy the app specific output to `out/`.
|
||||
|
||||
set -o errexit
|
||||
set -o xtrace
|
||||
|
||||
# The Cloudflare Pages build configuration is set to use `out/` as the build
|
||||
# output directory, so once we're done building we copy the app specific output
|
||||
# to `out/` (symlinking didn't work).
|
||||
|
||||
rm -rf out
|
||||
|
||||
if test "$CF_PAGES_BRANCH" = "auth-release"
|
||||
then
|
||||
# By default, for preview deployments the NEXT_PUBLIC_APP_ENV is set to
|
||||
# "test" in the CF environment variables. For production deployments of the
|
||||
# auth app, reset this to "production".
|
||||
#
|
||||
# This is not needed for the default `yarn export:photos` case, because
|
||||
# there the actual production deployment runs without NEXT_PUBLIC_APP_ENV
|
||||
# being set to anything (and the other preview deployments have
|
||||
# NEXT_PUBLIC_APP_ENV set to "test", as is correct).
|
||||
export NEXT_PUBLIC_APP_ENV=production
|
||||
# Cloudflare Pages has two separate environments - Production and Preview.
|
||||
#
|
||||
# Each of these have their separate environment variables. However, we need to
|
||||
# deploy multiple production apps - so while for the "photos-release" branch
|
||||
# (which corresponds to Cloudflare's "Production" environment) can have separate
|
||||
# environment variables, the rest of the production deployments share the same
|
||||
# environment variables (those that are set for the Preview environment in CF).
|
||||
#
|
||||
# So we instead tune environment variables for specific deployments here.
|
||||
|
||||
if test "$CF_PAGES_BRANCH" = "photos-release"; then
|
||||
yarn export:photos
|
||||
cp -R apps/photos/out .
|
||||
elif test "$CF_PAGES_BRANCH" = "auth-release"; then
|
||||
yarn export:auth
|
||||
cp -R apps/auth/out .
|
||||
else
|
||||
# Apart from the named branches, everything else gets treated as a
|
||||
# development deployment.
|
||||
export NODE_ENV=development
|
||||
# Also, we connect all of them to the dev APIs.
|
||||
export NEXT_PUBLIC_APP_ENV=development
|
||||
export NEXT_PUBLIC_ENTE_ENDPOINT=https://dev-api.ente.io
|
||||
export NEXT_PUBLIC_ENTE_WEB_ENDPOINT=https://dev-web.ente.io
|
||||
export NEXT_PUBLIC_ENTE_ALBUM_ENDPOINT=https://dev-albums.ente.io
|
||||
|
||||
yarn export:photos
|
||||
cp -R apps/photos/out .
|
||||
fi
|
||||
|
|
Loading…
Add table
Reference in a new issue