From 06d00614482fe58b0dc9625a7fbcfe1df6970510 Mon Sep 17 00:00:00 2001 From: moeny-matt Date: Tue, 5 Nov 2024 14:01:52 -0500 Subject: [PATCH] Initial commit --- .gitignore | 2 + README.md | 95 ++++++++++++++++++++++++++++++ deploy.env | 169 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 266 insertions(+) create mode 100644 .gitignore create mode 100644 README.md create mode 100644 deploy.env diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..4c842e4 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +.env +.DS_Store \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..a1c2df7 --- /dev/null +++ b/README.md @@ -0,0 +1,95 @@ +# Self-Hosted AppFlowy Cloud Setup Guide + +This guide will help you set up your own instance of AppFlowy Cloud. + +## Prerequisites + +- Docker and Docker Compose +- PostgreSQL 14 or higher +- Redis +- Minimum 2GB RAM +- Git + +## Quick Start + +1. Clone the Appflowy-Cloud repository: + +```bash +git clone https://github.com/AppFlowy-IO/AppFlowy-Cloud.git +cd AppFlowy-Cloud +``` + +2. Configure environment variables: + +```bash +cp deploy.env .env +``` + +Edit the following variables in the `.env` file to reflect your setup: + +```env +# PostgreSQL Settings +POSTGRES_PASSWORD= + +# Supabase user settings +SUPABASE_PASSWORD= + +# authentication key, change this and keep the key safe and secret +# self defined key, you can use any string +GOTRUE_JWT_SECRET= + +# If you want to use AWS SES, set the following variables: +GOTRUE_MAILER_AUTOCONFIRM=false +GOTRUE_SMTP_HOST=email-smtp.us-east-1.amazonaws.com +GOTRUE_SMTP_PORT=465 +GOTRUE_SMTP_USER= +GOTRUE_SMTP_PASSWORD= +GOTRUE_SMTP_ADMIN_EMAIL= + +# This user will be created when AppFlowy Cloud starts successfully +# You can use this user to login to the admin panel +GOTRUE_ADMIN_EMAIL= +GOTRUE_ADMIN_PASSWORD= + +# Change this to your own domain where you host the docker-compose or gotrue +API_EXTERNAL_URL= + +# File Storage +# This is where storage like images, files, etc. will be stored. +# By default, Minio is used as the default file storage which uses host's file system. +APPFLOWY_S3_SECRET_KEY= + +# AppFlowy Cloud Mailer Configuration (same credentials as GOTRUE_SMTP_*) +APPFLOWY_MAILER_SMTP_HOST=email-smtp.us-east-1.amazonaws.com +APPFLOWY_MAILER_SMTP_PORT=465 +APPFLOWY_MAILER_SMTP_USERNAME= +APPFLOWY_MAILER_SMTP_PASSWORD= + +# PgAdmin +# Optional module to manage the postgres database +# You can access the pgadmin at http://your-host/pgadmin +# Refer to the APPFLOWY_DATABASE_URL for password when connecting to the database +PGADMIN_DEFAULT_EMAIL= +PGADMIN_DEFAULT_PASSWORD= + +# Portainer (username: admin) +PORTAINER_PASSWORD= + +# AppFlowy AI (Optional) +APPFLOWY_AI_OPENAI_API_KEY= + +# AppFlowy Web (change localhost to your host address) +APPFLOWY_WEB_URL=http://localhost:3000 +``` + +3. Start the services: + +```bash +docker-compose up -d +``` + +4. Confirm that your services are running: + +```bash +docker ps -a +``` diff --git a/deploy.env b/deploy.env new file mode 100644 index 0000000..f40b8ba --- /dev/null +++ b/deploy.env @@ -0,0 +1,169 @@ +# This file is a template for docker compose deployment +# Copy this file to .env and change the values as needed + +# PostgreSQL Settings +POSTGRES_HOST=postgres +POSTGRES_USER=postgres +POSTGRES_PASSWORD=changepassword +POSTGRES_PORT=5432 +POSTGRES_DB=postgres + +# Supabase user settings +SUPABASE_PASSWORD=root + +# Redis Settings +REDIS_HOST=redis +REDIS_PORT=6379 + +# AppFlowy Cloud +## URL that connects to the gotrue docker container +APPFLOWY_GOTRUE_BASE_URL=http://gotrue:9999 +## URL that connects to the postgres docker container +APPFLOWY_DATABASE_URL=postgres://${POSTGRES_USER}:${POSTGRES_PASSWORD}@${POSTGRES_HOST}:${POSTGRES_PORT}/${POSTGRES_DB} +APPFLOWY_ACCESS_CONTROL=true +APPFLOWY_WEBSOCKET_MAILBOX_SIZE=6000 +APPFLOWY_DATABASE_MAX_CONNECTIONS=40 +## URL that connects to the redis docker container +APPFLOWY_REDIS_URI=redis://${REDIS_HOST}:${REDIS_PORT} + +# admin frontend +## URL that connects to redis docker container +ADMIN_FRONTEND_REDIS_URL=redis://${REDIS_HOST}:${REDIS_PORT} +## URL that connects to gotrue docker container +ADMIN_FRONTEND_GOTRUE_URL=http://gotrue:9999 + +# authentication key, change this and keep the key safe and secret +# self defined key, you can use any string +GOTRUE_JWT_SECRET=hello456 +# Expiration time in seconds for the JWT token +GOTRUE_JWT_EXP=7200 + +# User sign up will automatically be confirmed if this is set to true. +# If you have OAuth2 set up or smtp configured, you can set this to false +# to enforce email confirmation or OAuth2 login instead. +# If you set this to false, you need to either set up SMTP +GOTRUE_MAILER_AUTOCONFIRM=true +# Number of emails that can be per minute +GOTRUE_RATE_LIMIT_EMAIL_SENT=100 + +# If you intend to use mail confirmation, you need to set the SMTP configuration below +# You would then need to set GOTRUE_MAILER_AUTOCONFIRM=false +# Check for logs in gotrue service if there are any issues with email confirmation +# Note that smtps will be used for port 465, otherwise plain smtp with optional STARTTLS +GOTRUE_SMTP_HOST=smtp.gmail.com +GOTRUE_SMTP_PORT=465 +GOTRUE_SMTP_USER=email_sender@some_company.com +GOTRUE_SMTP_PASS=email_sender_password +GOTRUE_SMTP_ADMIN_EMAIL=comp_admin@some_company.com + +# This user will be created when AppFlowy Cloud starts successfully +# You can use this user to login to the admin panel +GOTRUE_ADMIN_EMAIL=admin@example.com +GOTRUE_ADMIN_PASSWORD=password + +# User will be redirected to this after Email or OAuth login +# Change this to your own domain where you host the docker-compose or gotrue +# If you are using a different domain, you need to change the redirect_uri in the OAuth2 configuration +# Make sure that this domain is accessible to the user +# Make sure no endswith / +API_EXTERNAL_URL=http://your-host + +# In docker environment, `postgres` is the hostname of the postgres service +# GoTrue connect to postgres using this url +GOTRUE_DATABASE_URL=postgres://supabase_auth_admin:${SUPABASE_PASSWORD}@${POSTGRES_HOST}:${POSTGRES_PORT}/${POSTGRES_DB} + +# Refer to this for details: https://github.com/AppFlowy-IO/AppFlowy-Cloud/blob/main/doc/AUTHENTICATION.md +# Google OAuth2 +GOTRUE_EXTERNAL_GOOGLE_ENABLED=false +GOTRUE_EXTERNAL_GOOGLE_CLIENT_ID= +GOTRUE_EXTERNAL_GOOGLE_SECRET= +GOTRUE_EXTERNAL_GOOGLE_REDIRECT_URI=${API_EXTERNAL_URL}/gotrue/callback +# GitHub OAuth2 +GOTRUE_EXTERNAL_GITHUB_ENABLED=false +GOTRUE_EXTERNAL_GITHUB_CLIENT_ID= +GOTRUE_EXTERNAL_GITHUB_SECRET= +GOTRUE_EXTERNAL_GITHUB_REDIRECT_URI=${API_EXTERNAL_URL}/gotrue/callback +# Discord OAuth2 +GOTRUE_EXTERNAL_DISCORD_ENABLED=false +GOTRUE_EXTERNAL_DISCORD_CLIENT_ID= +GOTRUE_EXTERNAL_DISCORD_SECRET= +GOTRUE_EXTERNAL_DISCORD_REDIRECT_URI=${API_EXTERNAL_URL}/gotrue/callback +# Apple OAuth2 +GOTRUE_EXTERNAL_APPLE_ENABLED=false +GOTRUE_EXTERNAL_APPLE_CLIENT_ID= +GOTRUE_EXTERNAL_APPLE_SECRET= +GOTRUE_EXTERNAL_APPLE_REDIRECT_URI=${API_EXTERNAL_URL}/gotrue/callback + +# File Storage +# Create the bucket if not exists on AppFlowy Cloud start up. +# Set this to false if the bucket has been created externally. +APPFLOWY_S3_CREATE_BUCKET=true +# This is where storage like images, files, etc. will be stored. +# By default, Minio is used as the default file storage which uses host's file system. +# Keep this as true if you are using other S3 compatible storage provider other than AWS. +APPFLOWY_S3_USE_MINIO=true +APPFLOWY_S3_MINIO_URL=http://minio:9000 # change this if you are using a different address for minio +APPFLOWY_S3_ACCESS_KEY=minioadmin +APPFLOWY_S3_SECRET_KEY=minioadmin +APPFLOWY_S3_BUCKET=appflowy +#APPFLOWY_S3_REGION=us-east-1 + +# AppFlowy Cloud Mailer +# Note that smtps (TLS) is always required, even for ports other than 465 +APPFLOWY_MAILER_SMTP_HOST=smtp.gmail.com +APPFLOWY_MAILER_SMTP_PORT=465 +APPFLOWY_MAILER_SMTP_USERNAME=email_sender@some_company.com +APPFLOWY_MAILER_SMTP_PASSWORD=email_sender_password + +# Log level for the appflowy-cloud service +RUST_LOG=info + +# PgAdmin +# Optional module to manage the postgres database +# You can access the pgadmin at http://your-host/pgadmin +# Refer to the APPFLOWY_DATABASE_URL for password when connecting to the database +PGADMIN_DEFAULT_EMAIL=admin@example.com +PGADMIN_DEFAULT_PASSWORD=password + +# Portainer (username: admin) +PORTAINER_PASSWORD=password1234 + +# Cloudflare tunnel token +CLOUDFLARE_TUNNEL_TOKEN= + +# NGINX +# Optional, change this if you want to use custom ports to expose AppFlowy +NGINX_PORT=80 +NGINX_TLS_PORT=443 + +# If you are using a different postgres database, change the following values +# GOTRUE_DATABASE_URL=postgres://supabase_auth_admin:root@:/$POSTGRES_DB +# APPFLOWY_DATABASE_URL=postgres://POSTGRES_USER:$POSTGRES_PASSWORD@$POSTGRES_HOST:5432/$POSTGRES_DB + +# AppFlowy AI +APPFLOWY_AI_OPENAI_API_KEY= +APPFLOWY_AI_SERVER_PORT=5001 +APPFLOWY_AI_SERVER_HOST=ai +APPFLOWY_AI_DATABASE_URL=postgresql+psycopg://${POSTGRES_USER}:${POSTGRES_PASSWORD}@${POSTGRES_HOST}:${POSTGRES_PORT}/${POSTGRES_DB} +APPFLOWY_LOCAL_AI_TEST_ENABLED=false + +# AppFlowy History +APPFLOWY_GRPC_HISTORY_ADDRS=http://localhost:50051 +APPFLOWY_HISTORY_REDIS_URL=redis://${REDIS_HOST}:${REDIS_PORT} +APPFLOWY_HISTORY_DATABASE_URL=postgres://${POSTGRES_USER}:${POSTGRES_PASSWORD}@${POSTGRES_HOST}:${POSTGRES_PORT}/${POSTGRES_DB} + +# AppFlowy Indexer +APPFLOWY_INDEXER_ENABLED=true +APPFLOWY_INDEXER_DATABASE_URL=postgres://${POSTGRES_USER}:${POSTGRES_PASSWORD}@${POSTGRES_HOST}:${POSTGRES_PORT}/${POSTGRES_DB} +APPFLOWY_INDEXER_REDIS_URL=redis://${REDIS_HOST}:${REDIS_PORT} + +# AppFlowy Collaborate +APPFLOWY_COLLABORATE_MULTI_THREAD=false +APPFLOWY_COLLABORATE_REMOVE_BATCH_SIZE=100 + +# AppFlowy Worker +APPFLOWY_WORKER_REDIS_URL=redis://${REDIS_HOST}:${REDIS_PORT} +APPFLOWY_WORKER_DATABASE_URL=postgres://${POSTGRES_USER}:${POSTGRES_PASSWORD}@${POSTGRES_HOST}:${POSTGRES_PORT}/${POSTGRES_DB} + +# AppFlowy Web +APPFLOWY_WEB_URL=http://localhost:3000 \ No newline at end of file