From 7a5f9ae474b7dee15b25e82cd1473ed668e9dd39 Mon Sep 17 00:00:00 2001 From: Luke Vella Date: Mon, 11 Sep 2023 15:34:55 +0100 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20Self-Hosting=20Update=20(#842)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/docker-image-manual.yml | 1 + .../docker-image-version-release.yml | 1 + apps/docs/contribute/donations.mdx | 11 +- apps/docs/mint.json | 9 +- .../self-hosting/configuration-options.mdx | 39 +- apps/docs/self-hosting/introduction.mdx | 26 +- apps/docs/self-hosting/managed-hosting.mdx | 1 + apps/docs/self-hosting/pricing.mdx | 55 ++ apps/landing/declarations/environment.d.ts | 4 - apps/landing/package.json | 6 +- apps/web/Dockerfile | 6 + apps/web/declarations/environment.d.ts | 8 - apps/web/package.json | 5 +- apps/web/public/locales/en/app.json | 16 +- apps/web/src/components/auth/auth-layout.tsx | 18 +- .../src/components/billing/billing-plans.tsx | 2 +- apps/web/src/components/featurebase.tsx | 4 +- .../src/components/layouts/profile-layout.tsx | 85 ++- .../components/layouts/standard-layout.tsx | 58 +- apps/web/src/components/logo.tsx | 42 +- apps/web/src/components/open-beta-modal.tsx | 70 --- .../components/settings/settings-section.tsx | 15 - apps/web/src/components/settings/settings.tsx | 70 +++ apps/web/src/components/text-summary.tsx | 39 -- apps/web/src/components/upgrade-button.tsx | 40 +- apps/web/src/components/user-dropdown.tsx | 49 +- apps/web/src/components/user-provider.tsx | 11 +- apps/web/src/contexts/environment.tsx | 9 + apps/web/src/contexts/plan.tsx | 27 +- apps/web/src/middleware.ts | 39 +- apps/web/src/pages/admin/[urlId].tsx | 2 +- apps/web/src/pages/api/stripe/checkout.ts | 27 +- apps/web/src/pages/api/stripe/portal.ts | 6 +- apps/web/src/pages/api/stripe/webhook.ts | 12 +- apps/web/src/pages/settings/billing.tsx | 150 +++-- apps/web/src/pages/settings/preferences.tsx | 66 +- apps/web/src/pages/settings/profile.tsx | 15 +- apps/web/src/utils/constants.ts | 7 +- docker-compose.yml | 2 + package.json | 6 +- packages/backend/session-config.ts | 2 +- packages/backend/trpc/context.ts | 8 +- packages/backend/trpc/routers/polls.ts | 27 +- packages/backend/trpc/trpc.ts | 8 +- packages/backend/utils/auth.ts | 14 +- packages/database/package.json | 3 +- packages/tsconfig/environment.d.ts | 4 - sample.env | 4 - scripts/vercel.sh | 2 - turbo.json | 3 +- yarn.lock | 592 +++++++++--------- 51 files changed, 945 insertions(+), 781 deletions(-) create mode 100644 apps/docs/self-hosting/pricing.mdx delete mode 100644 apps/web/src/components/open-beta-modal.tsx delete mode 100644 apps/web/src/components/settings/settings-section.tsx create mode 100644 apps/web/src/components/settings/settings.tsx delete mode 100644 apps/web/src/components/text-summary.tsx create mode 100644 apps/web/src/contexts/environment.tsx diff --git a/.github/workflows/docker-image-manual.yml b/.github/workflows/docker-image-manual.yml index ff655cb15..870fe1b1d 100644 --- a/.github/workflows/docker-image-manual.yml +++ b/.github/workflows/docker-image-manual.yml @@ -37,3 +37,4 @@ jobs: labels: ${{ steps.meta.outputs.labels }} build-args: | APP_VERSION=${{ github.ref_name }} + SELF_HOSTED=true diff --git a/.github/workflows/docker-image-version-release.yml b/.github/workflows/docker-image-version-release.yml index cf6252f82..38b0a2818 100644 --- a/.github/workflows/docker-image-version-release.yml +++ b/.github/workflows/docker-image-version-release.yml @@ -39,3 +39,4 @@ jobs: labels: ${{ steps.meta.outputs.labels }} build-args: | APP_VERSION=${{ github.ref_name }} + SELF_HOSTED=true diff --git a/apps/docs/contribute/donations.mdx b/apps/docs/contribute/donations.mdx index a14065844..62e9cf21f 100644 --- a/apps/docs/contribute/donations.mdx +++ b/apps/docs/contribute/donations.mdx @@ -6,18 +6,15 @@ description: Help fund this project and keep it ad-free ## Why should I donate? -> Rallly is available free and without ads. -> But free software doesn't mean it's without cost. -> Someone has to develop, maintain, and support it. -> With the help of generous people like you, we can keep Rallly ad-free for everyone and continue to make it even better. -> -> -- [Luke Vella](https://twitter.com/imlukevella), Creator of Rallly +Most users of Rallly use it for free, and that's great! +However, running Rallly costs money. +By donating, you can help keep Rallly running and ad-free. ## How can I donate? You can donate using any of the following methods: - + + Postgres database connection string - + The base url where this instance is accessible, including the scheme (eg. `http://` or `https://`), the domain name, and optionally a port. - + A random 32-character secret key used to encrypt user sessions + + Comma separated list of email addresses that are allowed to register and + login. Wildcard characters are supported. Example: Setting it to + `*@example.com` to allow anyone with a `@example.com` email address. + + ### Email Configuration These variables need to be configured to let Rallly send out transactional emails. - + This email is used as the sender for all transactional emails. If not set, `SUPPORT_EMAIL` will be used instead. - + This email will be shown as the contact email for support queries. - + The host address of your SMTP server @@ -46,7 +53,7 @@ These variables need to be configured to let Rallly send out transactional email The port of your SMTP server - + Set to "true" if SSL is enabled for your SMTP connection @@ -61,21 +68,3 @@ These variables need to be configured to let Rallly send out transactional email Enable TLS for your SMTP connection - -### Custom Configuration - -These variables allow you to change Rallly's default behavior. - - - Comma separated list of email addresses that are allowed to register and - login. Wildcard characters are supported. Example: `*@yourcompany.com` - - - - Set to `true` to require authentication for creating new polls and accessing - admin pages - - - - Whether or not to disable the landing page - diff --git a/apps/docs/self-hosting/introduction.mdx b/apps/docs/self-hosting/introduction.mdx index 2a1863ee5..4a6a7fb1e 100644 --- a/apps/docs/self-hosting/introduction.mdx +++ b/apps/docs/self-hosting/introduction.mdx @@ -1,13 +1,29 @@ --- +icon: server title: Introduction -description: How to run your own instance of Rallly. +description: How to Self-Host Rallly --- -## What is Self-Hosting? +Rallly is 100% open-source and available under the [GNU Affero General Public License v3.0 (AGPL-3.0)](https://github.com/lukevella/rallly/blob/main/LICENSE) +which allows you to run your own instance of Rallly for free for both personal and commercial use. -Self-hosting refers to the practice of running your own instance of Rallly on your own server. +## Official Docker Image -The main advantage of self-hosting is the autonomy it affords, but it also requires more technical knowledge and maintenance, as well as the potential security risks of managing your own infrastructure. +The best way to self-host Rallly is using the [official Docker image](https://hub.docker.com/r/lukevella/rallly). +This image contains a build that is specifically intended for self-hosting. +It is updated regularly but it is _not_ guaranteed to be up-to-date with the latest version of Rallly. +If you want to have access to the latest features and bug fixes, you should consider using the [official managed service](https://rallly.co). + + + Though it is technically possible to build and run Rallly from its + [source-code](https://github.com/lukevella/rallly), it is not recommended and + we do not provide support for this. + + +## Pricing + +Rallly is **completely free** to self-host but for users who wish to contribute to the project, +please check out the [pricing](/self-hosting/pricing) page. ## Get Started @@ -22,7 +38,7 @@ Depending on how comfortable you are with technical things, you can either run R Host your own instance of Rallly on your own server using Docker. diff --git a/apps/docs/self-hosting/managed-hosting.mdx b/apps/docs/self-hosting/managed-hosting.mdx index f8ee712f8..83ee018ca 100644 --- a/apps/docs/self-hosting/managed-hosting.mdx +++ b/apps/docs/self-hosting/managed-hosting.mdx @@ -1,4 +1,5 @@ --- +icon: cloud title: Managed Hosting description: Using a managed hosting service to self-host Rallly. --- diff --git a/apps/docs/self-hosting/pricing.mdx b/apps/docs/self-hosting/pricing.mdx new file mode 100644 index 000000000..6d46752c0 --- /dev/null +++ b/apps/docs/self-hosting/pricing.mdx @@ -0,0 +1,55 @@ +--- +icon: coins +title: Pricing +description: How much does it cost to self-host Rallly? +--- + +Rallly is **completely free** to self-host. +But free software doesn’t mean it’s without cost. +Someone has to develop, maintain, and support it. +If you find Rallly useful you can help support further development by paying a one-time fee. + +## Suggested Price + +We believe $42 USD is a very fair price for the time and effort that's gone into making this product. +It's also the cost of a yearly subscription to the [official managed service](https://rallly.co). +If you find Rallly useful and can afford to pay, please consider paying this amount. + + + + One-time payment for Rallly Self-Hosted + + + +## Pay What You Want + +Alternatively, you can choose to pay **any amount** you want. Your support is appreciated regardless of how much you are able to pay. + + + + One-time payment + + + One-time payment + + + One-time payment + + + diff --git a/apps/landing/declarations/environment.d.ts b/apps/landing/declarations/environment.d.ts index 9a8ee49de..2258f7b3b 100644 --- a/apps/landing/declarations/environment.d.ts +++ b/apps/landing/declarations/environment.d.ts @@ -64,10 +64,6 @@ declare global { * Example: "user@example.com, *@example.com, *@*.example.com" */ ALLOWED_EMAILS?: string; - /** - * "true" to require authentication for creating new polls and accessing admin pages - */ - AUTH_REQUIRED?: string; /** * Determines what email provider to use. "smtp" or "ses" */ diff --git a/apps/landing/package.json b/apps/landing/package.json index 84e81b7b0..c2c9ce8e6 100644 --- a/apps/landing/package.json +++ b/apps/landing/package.json @@ -36,8 +36,7 @@ "react-i18next": "^12.1.4", "react-use": "^17.4.0", "remark": "^14.0.3", - "remark-html": "^15.0.2", - "typescript": "^4.9.4" + "remark-html": "^15.0.2" }, "devDependencies": { "@next/bundle-analyzer": "^12.3.4", @@ -50,11 +49,8 @@ "@types/react-dom": "^18.0.11", "@types/react-linkify": "^1.0.1", "@types/smoothscroll-polyfill": "^0.3.1", - "@typescript-eslint/eslint-plugin": "^5.21.0", - "@typescript-eslint/parser": "^5.50.0", "cheerio": "^1.0.0-rc.12", "cross-env": "^7.0.3", - "eslint": "^7.26.0", "eslint-config-next": "^13.0.1", "eslint-config-turbo": "^0.0.9", "eslint-import-resolver-typescript": "^2.7.0", diff --git a/apps/web/Dockerfile b/apps/web/Dockerfile index 86f1769a3..db6a231e7 100644 --- a/apps/web/Dockerfile +++ b/apps/web/Dockerfile @@ -21,6 +21,9 @@ RUN yarn db:generate ARG APP_VERSION ENV NEXT_PUBLIC_APP_VERSION=$APP_VERSION +ARG SELF_HOSTED +ENV NEXT_PUBLIC_SELF_HOSTED=$SELF_HOSTED + RUN yarn build FROM node:18 AS runner @@ -48,4 +51,7 @@ COPY --from=installer --chown=nextjs:nodejs /app/apps/web/.next/standalone ./ COPY --from=installer --chown=nextjs:nodejs /app/apps/web/.next/static ./apps/web/.next/static COPY --from=installer --chown=nextjs:nodejs /app/apps/web/public ./apps/web/public +ARG SELF_HOSTED +ENV NEXT_PUBLIC_SELF_HOSTED=$SELF_HOSTED + CMD ["./docker-start.sh"] diff --git a/apps/web/declarations/environment.d.ts b/apps/web/declarations/environment.d.ts index 770ce9be5..02a71d140 100644 --- a/apps/web/declarations/environment.d.ts +++ b/apps/web/declarations/environment.d.ts @@ -33,10 +33,6 @@ declare global { * Crisp website ID */ NEXT_PUBLIC_CRISP_WEBSITE_ID?: string; - /** - * When `true` it will show the feedback button and pull the changelog from featurebase - */ - NEXT_PUBLIC_FEEDBACK_ENABLED?: string; /** * Users of your instance will see this as their support email */ @@ -68,10 +64,6 @@ declare global { * Example: "user@example.com, *@example.com, *@*.example.com" */ ALLOWED_EMAILS?: string; - /** - * "true" to require authentication for creating new polls and accessing admin pages - */ - AUTH_REQUIRED?: string; /** * Determines what email provider to use. "smtp" or "ses" */ diff --git a/apps/web/package.json b/apps/web/package.json index d2d33ad35..313bd229a 100644 --- a/apps/web/package.json +++ b/apps/web/package.json @@ -33,6 +33,7 @@ "@tailwindcss/typography": "^0.5.9", "@tanstack/react-table": "^8.9.1", "@vercel/analytics": "^0.1.8", + "@vercel/og": "^0.5.13", "accept-language-parser": "^1.5.0", "autoprefixer": "^10.4.13", "class-variance-authority": "^0.6.0", @@ -67,7 +68,6 @@ "spacetime": "^7.4.7", "superjson": "^1.12.2", "timezone-soft": "^1.4.1", - "typescript": "^4.9.4", "zod": "^3.20.2" }, "devDependencies": { @@ -81,11 +81,8 @@ "@types/react-dom": "^18.0.11", "@types/react-linkify": "^1.0.1", "@types/smoothscroll-polyfill": "^0.3.1", - "@typescript-eslint/eslint-plugin": "^5.21.0", - "@typescript-eslint/parser": "^5.50.0", "cheerio": "^1.0.0-rc.12", "cross-env": "^7.0.3", - "eslint": "^7.26.0", "eslint-config-next": "^13.0.1", "eslint-config-turbo": "^0.0.9", "eslint-import-resolver-typescript": "^2.7.0", diff --git a/apps/web/public/locales/en/app.json b/apps/web/public/locales/en/app.json index be68dd528..d83a7a0d1 100644 --- a/apps/web/public/locales/en/app.json +++ b/apps/web/public/locales/en/app.json @@ -103,7 +103,6 @@ "addComment": "Add Comment", "profile": "Profile", "polls": "Polls", - "showLess": "Show less…", "showMore": "Show more…", "timeZoneSelect__defaultValue": "Select time zone…", "timeZoneSelect__noOption": "No option found", @@ -205,14 +204,8 @@ "duplicateTitleDescription": "Hint: Give your new poll a unique title", "proFeature": "Pro Feature", "upgradeOverlaySubtitle2": "Please upgrade to a paid plan to use this feature. This is how we keep the lights on :)", - "savePercent": "Save {percent}%", - "priceIncreaseSoon": "Price increase soon.", - "lockPrice": "Upgrade today to keep this price forever.", - "noAds": "No ads", "upgrade": "Upgrade", "notToday": "Not Today", - "supportProject": "Support this project", - "features": "Get access to all current and future Pro features!", "continueAsGuest": "Continue as Guest", "scrollLeft": "Scroll Left", "scrollRight": "Scroll Right", @@ -231,5 +224,12 @@ "accessAllFeatures": "Access all features", "earlyAccess": "Get early access to new features", "earlyAdopterDescription": "As an early adopter, you'll lock in your subscription rate and won't be affected by future price increases.", - "upgradeNowSaveLater": "Upgrade now, save later" + "upgradeNowSaveLater": "Upgrade now, save later", + "savePercent": "Save {percent}%", + "priceIncreaseSoon": "Price increase soon.", + "lockPrice": "Upgrade today to keep this price forever.", + "features": "Get access to all current and future Pro features!", + "noAds": "No ads", + "supportProject": "Support this project", + "pricing": "Pricing" } diff --git a/apps/web/src/components/auth/auth-layout.tsx b/apps/web/src/components/auth/auth-layout.tsx index b2110783c..2b1ef8ba1 100644 --- a/apps/web/src/components/auth/auth-layout.tsx +++ b/apps/web/src/components/auth/auth-layout.tsx @@ -1,25 +1,21 @@ -import Image from "next/image"; import Link from "next/link"; import { Trans } from "next-i18next"; import React from "react"; +import { Logo } from "@/components/logo"; +import { IfCloudHosted } from "@/contexts/environment"; + export const AuthLayout = ({ children }: { children?: React.ReactNode }) => { return (
-
- Rallly +
+
{children}
- {process.env.AUTH_REQUIRED === "true" ? null : ( +

{

- )} +
); diff --git a/apps/web/src/components/billing/billing-plans.tsx b/apps/web/src/components/billing/billing-plans.tsx index 4858c81d5..75e627920 100644 --- a/apps/web/src/components/billing/billing-plans.tsx +++ b/apps/web/src/components/billing/billing-plans.tsx @@ -141,7 +141,7 @@ export const BillingPlans = () => {
-
+
diff --git a/apps/web/src/components/featurebase.tsx b/apps/web/src/components/featurebase.tsx index b83d97c7d..38be6b20f 100644 --- a/apps/web/src/components/featurebase.tsx +++ b/apps/web/src/components/featurebase.tsx @@ -13,7 +13,7 @@ const FeaturebaseScript = () => (