From 46ab62d0e26a7c6b5182f8b01433097643a80e76 Mon Sep 17 00:00:00 2001 From: jamesread Date: Fri, 13 Sep 2024 00:32:25 +0100 Subject: [PATCH 1/8] docs: extra comments in config, and how to make resend optional --- apps/docs/installation/development.mdx | 36 +++++++++++++++++++------- apps/docs/installation/docker.mdx | 2 +- 2 files changed, 27 insertions(+), 11 deletions(-) diff --git a/apps/docs/installation/development.mdx b/apps/docs/installation/development.mdx index c6e5f9321..c456c5d2a 100644 --- a/apps/docs/installation/development.mdx +++ b/apps/docs/installation/development.mdx @@ -17,10 +17,13 @@ This guide will ask you to install & configure several services exaplained below ### Prerequisite Cloud Services -- **[Resend account](https://resend.com)** - for user activation and email notifications. -- **[Cloudflare R2](https://cloudfalre.com)** - for uploads (optional, can use local machine), and storing account data. +- **[Cloudflare R2](https://cloudfalre.com)** - for uploads (optional, can use local machine). - **Social Media API details** - various API keys and secrets (more details later) for services you want to use; reddit, X, Instagram, etc.. +### Optional Cloud Services + +- **[Resend account](https://resend.com)** - for user activation and email notifications. + ### Prerequisite Local Services - **Node.js** - for running the code! (version 18+) @@ -78,6 +81,26 @@ FRONTEND_URL="http://localhost:4200" NEXT_PUBLIC_BACKEND_URL="http://localhost:3000" BACKEND_INTERNAL_URL="http://localhost:3000" +# Optional. Your upload directory path if you host your files locally. +UPLOAD_DIRECTORY="/opt/postiz/uploads/" + +# Optional: your upload directory slug if you host your files locally. +NEXT_PUBLIC_UPLOAD_STATIC_DIRECTORY="" + +## This is a dummy key, you must create your own from Resend. +## If this variable exists, user activation is required. +## If it is commented out, users are activated automatically. +#RESEND_API_KEY="RzeTwHijvxvPUerScFcenUZUALuQJzSaGSMJ" + +## These are dummy values, you must create your own from Cloudflare. +## Remember to set your public internet IP address in the allow-list for the API token. +CLOUDFLARE_ACCOUNT_ID="QhcMSXQyPuMCRpSQcSYdEuTYgHeCXHbu" +CLOUDFLARE_ACCESS_KEY="dcfCMSuFEeCNfvByUureMZEfxWJmDqZe" +CLOUDFLARE_SECRET_ACCESS_KEY="zTTMXBmtyLPwHEdpACGHgDgzRTNpTJewiNriLnUS" +CLOUDFLARE_BUCKETNAME="postiz" +CLOUDFLARE_BUCKET_URL="https://QhcMSXQyPuMCRpSQcSYdEuTYgHeCXHbu.r2.cloudflarestorage.com/" +CLOUDFLARE_REGION="auto" + # Social Media API Settings X_API_KEY="Twitter API key for normal oAuth not oAuth2" X_API_SECRET="Twitter API secret for normal oAuth not oAuth2" @@ -87,14 +110,7 @@ REDDIT_CLIENT_ID="Reddit Client ID" REDDIT_CLIENT_SECRET="Linkedin Client Secret" GITHUB_CLIENT_ID="GitHub Client ID" GITHUB_CLIENT_SECRET="GitHub Client Secret" -RESEND_API_KEY="Resend API KEY" -UPLOAD_DIRECTORY="optional: your upload directory path if you host your files locally" -NEXT_PUBLIC_UPLOAD_STATIC_DIRECTORY="optional: your upload directory slug if you host your files locally" -CLOUDFLARE_ACCOUNT_ID="Cloudflare R2 Account ID" -CLOUDFLARE_ACCESS_KEY="Cloudflare R2 Access Key" -CLOUDFLARE_SECRET_ACCESS_KEY="Cloudflare R2 Secret Access Key" -CLOUDFLARE_BUCKETNAME="Cloudflare R2 Bucket Name" -CLOUDFLARE_BUCKET_URL="Cloudflare R2 Backet URL" + # Developer Settings NX_ADD_PLUGINS=false diff --git a/apps/docs/installation/docker.mdx b/apps/docs/installation/docker.mdx index 487bf23c2..2c9484ac3 100644 --- a/apps/docs/installation/docker.mdx +++ b/apps/docs/installation/docker.mdx @@ -14,7 +14,7 @@ import DockerEnvvarApps from '/snippets/docker-envvar-apps.mdx'; # Create the container on command line ```bash -docker create --name postiz -v ./config:/config -p 4200:4200 -p 3000:3000 ghcr.io/postiz/postiz:latest +docker create --name postiz -v ./config:/config -p 4200:4200 -p 3000:3000 ghcr.io/postiz/postiz-app:latest ``` From 0817b657982aaa51de3e143c842e9a68e70b1c4d Mon Sep 17 00:00:00 2001 From: jamesread Date: Fri, 13 Sep 2024 08:17:21 +0100 Subject: [PATCH 2/8] doc: Typo in cloudflare [skip ci] --- apps/docs/installation/development.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/docs/installation/development.mdx b/apps/docs/installation/development.mdx index c456c5d2a..a5b2dc62a 100644 --- a/apps/docs/installation/development.mdx +++ b/apps/docs/installation/development.mdx @@ -17,7 +17,7 @@ This guide will ask you to install & configure several services exaplained below ### Prerequisite Cloud Services -- **[Cloudflare R2](https://cloudfalre.com)** - for uploads (optional, can use local machine). +- **[Cloudflare R2](https://cloudflare.com)** - for uploads (optional, can use local machine). - **Social Media API details** - various API keys and secrets (more details later) for services you want to use; reddit, X, Instagram, etc.. ### Optional Cloud Services From df9c172236f49c19a94d22d0bac1827b140d0f3c Mon Sep 17 00:00:00 2001 From: jamesread Date: Fri, 13 Sep 2024 08:49:58 +0100 Subject: [PATCH 3/8] feat: Migrations inside containers, and better default .env file. --- .env.example | 90 ++++++++++++++--------- apps/docs/installation/docker-compose.mdx | 2 - apps/docs/installation/docker.mdx | 13 +++- apps/docs/snippets/docker-database.mdx | 6 -- var/docker/entrypoint.sh | 3 + 5 files changed, 67 insertions(+), 47 deletions(-) delete mode 100644 apps/docs/snippets/docker-database.mdx diff --git a/.env.example b/.env.example index d06208b63..7528cf446 100644 --- a/.env.example +++ b/.env.example @@ -1,38 +1,44 @@ -DATABASE_URL="" -REDIS_URL="" -UPLOAD_DIRECTORY="" -NEXT_PUBLIC_UPLOAD_STATIC_DIRECTORY="" -STRIPE_PUBLISHABLE_KEY="" -STRIPE_SECRET_KEY="" -STRIPE_SIGNING_KEY="" -JWT_SECRET="" -FRONTEND_URL="" -MAIN_URL="" -NEXT_PUBLIC_BACKEND_URL="" -BACKEND_INTERNAL_URL="" -X_API_KEY="" -X_API_SECRET="" -X_CLIENT="" -X_SECRET="" -LINKEDIN_CLIENT_ID="" -LINKEDIN_CLIENT_SECRET="" -REDDIT_CLIENT_ID="" -REDDIT_CLIENT_SECRET="" -GITHUB_CLIENT_ID="" -GITHUB_CLIENT_SECRET="" -RESEND_API_KEY="" +# Required Settings +DATABASE_URL="postgresql://postiz-user:postiz-password@localhost:5432/postiz-db-local" +REDIS_URL="redis://localhost:6379" +JWT_SECRET="random string for your JWT secret, make it long" +FRONTEND_URL="http://localhost:4200" +NEXT_PUBLIC_BACKEND_URL="http://localhost:3000" +BACKEND_INTERNAL_URL="http://localhost:3000" + +# Optional. Your upload directory path if you host your files locally. +UPLOAD_DIRECTORY="/opt/postiz/uploads/" + +# Optional: your upload directory slug if you host your files locally. +NEXT_PUBLIC_UPLOAD_STATIC_DIRECTORY="/opt/postiz/uploads/" + +## This is a dummy key, you must create your own from Resend. +## If this variable exists, user activation is required. +## If it is commented out, users are activated automatically. +#RESEND_API_KEY="RzeTwHijvxvPUerScFcenUZUALuQJzSaGSMJ" +#EMAIL_FROM_ADDRESS="" +#EMAIL_FROM_NAME="" + +## These are dummy values, you must create your own from Cloudflare. +## Remember to set your public internet IP address in the allow-list for the API token. +CLOUDFLARE_ACCOUNT_ID="QhcMSXQyPuMCRpSQcSYdEuTYgHeCXHbu" +CLOUDFLARE_ACCESS_KEY="dcfCMSuFEeCNfvByUureMZEfxWJmDqZe" +CLOUDFLARE_SECRET_ACCESS_KEY="zTTMXBmtyLPwHEdpACGHgDgzRTNpTJewiNriLnUS" +CLOUDFLARE_BUCKETNAME="postiz" +CLOUDFLARE_BUCKET_URL="https://QhcMSXQyPuMCRpSQcSYdEuTYgHeCXHbu.r2.cloudflarestorage.com/" +CLOUDFLARE_REGION="auto" + +# Social Media API Settings +X_API_KEY="Twitter API key for normal oAuth not oAuth2" +X_API_SECRET="Twitter API secret for normal oAuth not oAuth2" +LINKEDIN_CLIENT_ID="Linkedin Client ID" +LINKEDIN_CLIENT_SECRET="Linkedin Client Secret" +REDDIT_CLIENT_ID="Reddit Client ID" +REDDIT_CLIENT_SECRET="Linkedin Client Secret" +GITHUB_CLIENT_ID="GitHub Client ID" +GITHUB_CLIENT_SECRET="GitHub Client Secret" BEEHIIVE_API_KEY="" BEEHIIVE_PUBLICATION_ID="" -NX_ADD_PLUGINS=false -CLOUDFLARE_ACCOUNT_ID="" -CLOUDFLARE_ACCESS_KEY="" -CLOUDFLARE_SECRET_ACCESS_KEY="" -CLOUDFLARE_BUCKETNAME="" -CLOUDFLARE_BUCKET_URL="" -CLOUDFLARE_REGION="" -FEE_AMOUNT=0.05 -OPENAI_API_KEY="" -NEXT_PUBLIC_DISCORD_SUPPORT="" THREADS_APP_ID="" THREADS_APP_SECRET="" FACEBOOK_APP_ID="" @@ -45,7 +51,19 @@ PINTEREST_CLIENT_ID="" PINTEREST_CLIENT_SECRET="" DRIBBBLE_CLIENT_ID="" DRIBBBLE_CLIENT_SECRET="" -IS_GENERAL="true" -EMAIL_FROM_ADDRESS="" -EMAIL_FROM_NAME="" + + +# Misc Settings +OPENAI_API_KEY="" +NEXT_PUBLIC_DISCORD_SUPPORT="" NEXT_PUBLIC_POLOTNO="Polotno key for the gallery" + +# Payment settings +FEE_AMOUNT=0.05 +STRIPE_PUBLISHABLE_KEY="" +STRIPE_SECRET_KEY="" +STRIPE_SIGNING_KEY="" + +# Developer Settings +NX_ADD_PLUGINS=false +IS_GENERAL="true" # required for now diff --git a/apps/docs/installation/docker-compose.mdx b/apps/docs/installation/docker-compose.mdx index 21b01799f..d4e009b7d 100644 --- a/apps/docs/installation/docker-compose.mdx +++ b/apps/docs/installation/docker-compose.mdx @@ -3,11 +3,9 @@ title: Docker Compose --- import EarlyDoc from '/snippets/earlydoc.mdx'; -import DockerDatabase from '/snippets/docker-database.mdx'; import DockerEnvvarApps from '/snippets/docker-envvar-apps.mdx'; - # Example `docker-compose.yml` file diff --git a/apps/docs/installation/docker.mdx b/apps/docs/installation/docker.mdx index 2c9484ac3..154cdea60 100644 --- a/apps/docs/installation/docker.mdx +++ b/apps/docs/installation/docker.mdx @@ -3,18 +3,25 @@ title: Docker --- import EarlyDoc from '/snippets/earlydoc.mdx'; -import DockerDatabase from '/snippets/docker-database.mdx'; import DockerEnvvarApps from '/snippets/docker-envvar-apps.mdx'; - +# Set environment variables +Postiz configuration is entirely via environment variables for now. You might be used to setting environment variables when starting containers, +however postiz needs a LOT of environment variables, so setting these on command line or in a docker-compose is probably not practical for long +term maintainability. + +It is recommended to use a `.env` file, which the Postiz containers look for in /config. Docker will automatically create this file for you on a +docker volume the first time you start up Postiz. + +The default .env file can be found here; [example .env file](https://raw.githubusercontent.com/gitroomhq/postiz-app/main/.env.example) # Create the container on command line ```bash -docker create --name postiz -v ./config:/config -p 4200:4200 -p 3000:3000 ghcr.io/postiz/postiz-app:latest +docker create --name postiz -v ./config:/config -p 4200:4200 -p 3000:3000 ghcr.io/gitroomhq/postiz-app:latest ``` diff --git a/apps/docs/snippets/docker-database.mdx b/apps/docs/snippets/docker-database.mdx deleted file mode 100644 index babd2cf5b..000000000 --- a/apps/docs/snippets/docker-database.mdx +++ /dev/null @@ -1,6 +0,0 @@ - -The container images do not yet provide automatic database "installation" -(migrations). This must be done manually outside of the docker containers for now. - -This is being worked on with a high priority. - diff --git a/var/docker/entrypoint.sh b/var/docker/entrypoint.sh index 2e98950e4..f896d960a 100755 --- a/var/docker/entrypoint.sh +++ b/var/docker/entrypoint.sh @@ -15,6 +15,9 @@ if [[ "$POSTIZ_APPS" -eq "" ]]; then POSTIZ_APPS="frontend workers cron backend" fi +echo "Running database migrations" +npm run prisma-db-push + mkdir -p /etc/supervisor.d/ if [[ "$POSTIZ_APPS" == *"frontend"* ]]; then From 5f86a5396e9cf1bdb5d35c7e203b4e514a25442b Mon Sep 17 00:00:00 2001 From: jamesread Date: Fri, 13 Sep 2024 09:00:38 +0100 Subject: [PATCH 4/8] doc: Cleanup a few default config keys --- .env.example | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/.env.example b/.env.example index 7528cf446..7ef00fa58 100644 --- a/.env.example +++ b/.env.example @@ -29,14 +29,16 @@ CLOUDFLARE_BUCKET_URL="https://QhcMSXQyPuMCRpSQcSYdEuTYgHeCXHbu.r2.cloudflaresto CLOUDFLARE_REGION="auto" # Social Media API Settings -X_API_KEY="Twitter API key for normal oAuth not oAuth2" -X_API_SECRET="Twitter API secret for normal oAuth not oAuth2" -LINKEDIN_CLIENT_ID="Linkedin Client ID" -LINKEDIN_CLIENT_SECRET="Linkedin Client Secret" -REDDIT_CLIENT_ID="Reddit Client ID" -REDDIT_CLIENT_SECRET="Linkedin Client Secret" -GITHUB_CLIENT_ID="GitHub Client ID" -GITHUB_CLIENT_SECRET="GitHub Client Secret" +X_API_KEY="" +X_API_SECRET="" +X_CLIENT="" +X_SECRET="" +LINKEDIN_CLIENT_ID="" +LINKEDIN_CLIENT_SECRET="" +REDDIT_CLIENT_ID="" +REDDIT_CLIENT_SECRET="" +GITHUB_CLIENT_ID="" +GITHUB_CLIENT_SECRET="" BEEHIIVE_API_KEY="" BEEHIIVE_PUBLICATION_ID="" THREADS_APP_ID="" @@ -52,7 +54,6 @@ PINTEREST_CLIENT_SECRET="" DRIBBBLE_CLIENT_ID="" DRIBBBLE_CLIENT_SECRET="" - # Misc Settings OPENAI_API_KEY="" NEXT_PUBLIC_DISCORD_SUPPORT="" @@ -63,6 +64,7 @@ FEE_AMOUNT=0.05 STRIPE_PUBLISHABLE_KEY="" STRIPE_SECRET_KEY="" STRIPE_SIGNING_KEY="" +STRIPE_SIGNING_KEY_CONNECT="" # Developer Settings NX_ADD_PLUGINS=false From e1b79a43e897ffe5387ca6a06d7406bbab86e1c8 Mon Sep 17 00:00:00 2001 From: jamesread Date: Fri, 13 Sep 2024 20:37:16 +0100 Subject: [PATCH 5/8] ci: Docker frontend startup, move packages to devcontainer, and config to postiz.env --- Dockerfile.dev | 24 +++++++++++++++--------- var/docker/entrypoint.sh | 2 +- var/docker/supervisord/frontend.conf | 4 ++-- 3 files changed, 18 insertions(+), 12 deletions(-) diff --git a/Dockerfile.dev b/Dockerfile.dev index fc85c023a..d43b45afa 100644 --- a/Dockerfile.dev +++ b/Dockerfile.dev @@ -15,14 +15,7 @@ ENV NEXT_TELEMETRY_DISABLED=1 RUN apk add --no-cache \ bash=5.2.21-r0 \ - supervisor=4.2.5-r4 \ - pkgconfig \ - gcc \ - pixman-dev \ - cairo-dev \ - pango-dev \ - make \ - build-base + supervisor=4.2.5-r4 WORKDIR /app @@ -32,7 +25,7 @@ EXPOSE 3000 COPY var/docker/entrypoint.sh /app/entrypoint.sh COPY var/docker/supervisord.conf /etc/supervisord.conf COPY var/docker/supervisord /app/supervisord_available_configs/ -COPY .env.example /config/.env +COPY .env.example /config/postiz.env VOLUME /config @@ -43,12 +36,23 @@ ENTRYPOINT ["/app/entrypoint.sh"] # Builder image FROM base AS devcontainer +RUN apk add --no-cache \ + pkgconfig \ + gcc \ + pixman-dev \ + cairo-dev \ + pango-dev \ + make \ + build-base + COPY nx.json tsconfig.base.json package.json package-lock.json /app/ COPY apps /app/apps/ COPY libraries /app/libraries/ RUN npm ci --no-fund && npx nx run-many --target=build --projects=frontend,backend,workers,cron +VOLUME /config + LABEL org.opencontainers.image.title="Postiz App (DevContainer)" # Output image @@ -59,5 +63,7 @@ COPY --from=devcontainer /app/dist/ /app/dist/ COPY package.json nx.json /app/ +VOLUME /config + ## Labels at the bottom, because CI will eventually add dates, commit hashes, etc. LABEL org.opencontainers.image.title="Postiz App (Production)" diff --git a/var/docker/entrypoint.sh b/var/docker/entrypoint.sh index f896d960a..f79c8f42a 100755 --- a/var/docker/entrypoint.sh +++ b/var/docker/entrypoint.sh @@ -7,7 +7,7 @@ if [[ "$SKIP_CONFIG_CHECK" != "true" ]]; then echo "ERROR: No .env file found in /config/.env" fi - ln -sf /config/.env /app/.env + ln -sf /config/postiz.env /app/.env fi if [[ "$POSTIZ_APPS" -eq "" ]]; then diff --git a/var/docker/supervisord/frontend.conf b/var/docker/supervisord/frontend.conf index c157a2050..53c03a6f5 100644 --- a/var/docker/supervisord/frontend.conf +++ b/var/docker/supervisord/frontend.conf @@ -1,6 +1,6 @@ [program:frontend] -directory=/app -command=npm run start:prod:frontend +directory=/app/dist/apps/frontend +command=npx next start autostart=true autorestart=false redirect_stderr=true From 091be4ec2fb0b1d0f06c3f3417154fef31b39dc6 Mon Sep 17 00:00:00 2001 From: Nevo David Date: Sat, 14 Sep 2024 18:54:18 +0700 Subject: [PATCH 6/8] feat: run process individually for dev --- package.json | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/package.json b/package.json index 737151659..0b4703b38 100644 --- a/package.json +++ b/package.json @@ -10,6 +10,10 @@ "dev:stripe": "npx concurrently \"stripe listen --forward-to localhost:3000/stripe\" \"npm run dev\"", "build": "npx nx run-many --target=build --projects=frontend,backend,workers,cron", "build:frontend": "npx nx run frontend:build:production", + "dev:frontend": "npx nx run frontend:serve:development", + "dev:backend": "npx nx run backend:serve:development", + "dev:workers": "npx nx run workers:serve:development", + "dev:cron": "npx nx run cron:serve:development", "start:prod": "node dist/apps/backend/main.js", "start:prod:frontend": "nx run frontend:serve:production", "start:prod:workers": "node dist/apps/workers/main.js", From d4d410e0d2cf3ed798bc369d41edb9b71029744c Mon Sep 17 00:00:00 2001 From: jamesread Date: Sat, 14 Sep 2024 20:23:10 +0100 Subject: [PATCH 7/8] docker: Copy config, instead of symlink. This means config is a standard file, and changes wont affect running containers. --- var/docker/entrypoint.sh | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/var/docker/entrypoint.sh b/var/docker/entrypoint.sh index f79c8f42a..526ca6f32 100755 --- a/var/docker/entrypoint.sh +++ b/var/docker/entrypoint.sh @@ -1,21 +1,23 @@ #!/bin/bash +set -o xtrace + if [[ "$SKIP_CONFIG_CHECK" != "true" ]]; then - echo "symlinking /config/.env into /app/.env" + echo "Entrypoint: Copying /config/postiz.env into /app/.env" if [ ! -f /config/.env ]; then - echo "ERROR: No .env file found in /config/.env" + echo "Entrypoint: WARNING: No .env file found in /config/postiz.env" fi - ln -sf /config/postiz.env /app/.env + cp -vf /config/postiz.env /app/.env fi if [[ "$POSTIZ_APPS" -eq "" ]]; then - echo "POSTIZ_APPS is not set, starting everything!" + echo "Entrypoint: POSTIZ_APPS is not set, starting everything!" POSTIZ_APPS="frontend workers cron backend" fi -echo "Running database migrations" +echo "Entrypoint: Running database migrations" npm run prisma-db-push mkdir -p /etc/supervisor.d/ From 8639cc14d9f088569fa515b62d7cb9e1344c277a Mon Sep 17 00:00:00 2001 From: jamesread Date: Sat, 14 Sep 2024 21:50:20 +0100 Subject: [PATCH 8/8] doc: Improve config docs --- .env.example | 36 ++++++++++++-------- apps/docs/installation/development.mdx | 4 +++ apps/docs/installation/docker-compose.mdx | 14 +++++++- apps/docs/installation/docker.mdx | 32 +++++++++++------ apps/docs/mint.json | 6 ++++ apps/docs/snippets/docker-envvar-apps.mdx | 13 ++++--- apps/docs/snippets/docker-envvar-general.mdx | 15 ++++++++ 7 files changed, 90 insertions(+), 30 deletions(-) create mode 100644 apps/docs/snippets/docker-envvar-general.mdx diff --git a/.env.example b/.env.example index 7ef00fa58..5b70c78c2 100644 --- a/.env.example +++ b/.env.example @@ -1,4 +1,6 @@ -# Required Settings +# Configuration reference: http://docs.postiz.com/configuration/reference + +# === Required Settings DATABASE_URL="postgresql://postiz-user:postiz-password@localhost:5432/postiz-db-local" REDIS_URL="redis://localhost:6379" JWT_SECRET="random string for your JWT secret, make it long" @@ -6,11 +8,19 @@ FRONTEND_URL="http://localhost:4200" NEXT_PUBLIC_BACKEND_URL="http://localhost:3000" BACKEND_INTERNAL_URL="http://localhost:3000" -# Optional. Your upload directory path if you host your files locally. -UPLOAD_DIRECTORY="/opt/postiz/uploads/" +## These are dummy values, you must create your own from Cloudflare. +## Remember to set your public internet IP address in the allow-list for the API token. +## +## Cloudflare is currently required to save things like social media avatars for accounts. +CLOUDFLARE_ACCOUNT_ID="QhcMSXQyPuMCRpSQcSYdEuTYgHeCXHbu" +CLOUDFLARE_ACCESS_KEY="dcfCMSuFEeCNfvByUureMZEfxWJmDqZe" +CLOUDFLARE_SECRET_ACCESS_KEY="zTTMXBmtyLPwHEdpACGHgDgzRTNpTJewiNriLnUS" +CLOUDFLARE_BUCKETNAME="postiz" +CLOUDFLARE_BUCKET_URL="https://QhcMSXQyPuMCRpSQcSYdEuTYgHeCXHbu.r2.cloudflarestorage.com/" +CLOUDFLARE_REGION="auto" + -# Optional: your upload directory slug if you host your files locally. -NEXT_PUBLIC_UPLOAD_STATIC_DIRECTORY="/opt/postiz/uploads/" +# === Common optional Settings ## This is a dummy key, you must create your own from Resend. ## If this variable exists, user activation is required. @@ -19,14 +29,12 @@ NEXT_PUBLIC_UPLOAD_STATIC_DIRECTORY="/opt/postiz/uploads/" #EMAIL_FROM_ADDRESS="" #EMAIL_FROM_NAME="" -## These are dummy values, you must create your own from Cloudflare. -## Remember to set your public internet IP address in the allow-list for the API token. -CLOUDFLARE_ACCOUNT_ID="QhcMSXQyPuMCRpSQcSYdEuTYgHeCXHbu" -CLOUDFLARE_ACCESS_KEY="dcfCMSuFEeCNfvByUureMZEfxWJmDqZe" -CLOUDFLARE_SECRET_ACCESS_KEY="zTTMXBmtyLPwHEdpACGHgDgzRTNpTJewiNriLnUS" -CLOUDFLARE_BUCKETNAME="postiz" -CLOUDFLARE_BUCKET_URL="https://QhcMSXQyPuMCRpSQcSYdEuTYgHeCXHbu.r2.cloudflarestorage.com/" -CLOUDFLARE_REGION="auto" +# Your upload directory path if you host your files locally, otherwise Cloudflare will be used. +#UPLOAD_DIRECTORY="/opt/postiz/uploads/" + +# Your upload directory path if you host your files locally, otherwise Cloudflare will be used. +#NEXT_PUBLIC_UPLOAD_STATIC_DIRECTORY="/opt/postiz/uploads/" + # Social Media API Settings X_API_KEY="" @@ -57,7 +65,7 @@ DRIBBBLE_CLIENT_SECRET="" # Misc Settings OPENAI_API_KEY="" NEXT_PUBLIC_DISCORD_SUPPORT="" -NEXT_PUBLIC_POLOTNO="Polotno key for the gallery" +NEXT_PUBLIC_POLOTNO="" # Payment settings FEE_AMOUNT=0.05 diff --git a/apps/docs/installation/development.mdx b/apps/docs/installation/development.mdx index a5b2dc62a..015b9bf18 100644 --- a/apps/docs/installation/development.mdx +++ b/apps/docs/installation/development.mdx @@ -72,6 +72,10 @@ git clone https://github.com/gitroomhq/gitroom Copy the `.env.example` file to `.env` and fill in the values +An example file of the most used configuration settings can be found here; [example postiz.env file](https://raw.githubusercontent.com/gitroomhq/postiz-app/main/.env.example) + +There is also a [configuration reference](/configuration/reference) page that goes into more detail. + ```bash .env # Required Settings DATABASE_URL="postgresql://postiz-user:postiz-password@localhost:5432/postiz-db-local" diff --git a/apps/docs/installation/docker-compose.mdx b/apps/docs/installation/docker-compose.mdx index d4e009b7d..8c422f018 100644 --- a/apps/docs/installation/docker-compose.mdx +++ b/apps/docs/installation/docker-compose.mdx @@ -4,9 +4,14 @@ title: Docker Compose import EarlyDoc from '/snippets/earlydoc.mdx'; import DockerEnvvarApps from '/snippets/docker-envvar-apps.mdx'; +import DockerEnvvarGeneral from '/snippets/docker-envvar-general.mdx'; + + +The container images will copy a file called `/config/postiz.env` to `/apps/.env` on startup. + # Example `docker-compose.yml` file ```yaml @@ -15,8 +20,15 @@ services: image: ghcr.io/gitroomhq/postiz-app:latest container_name: postiz restart: always + environment: # If you want to specify the variables in your compose file. + - DATABASE_URL="postgresql://postiz-user:postiz-password@localhost:5432/postiz-db-local" + - REDIS_URL="redis://localhost:6379" + - JWT_SECRET="random string for your JWT secret, make it long" + - FRONTEND_URL="http://localhost:4200" + - NEXT_PUBLIC_BACKEND_URL="http://localhost:3000" + - BACKEND_INTERNAL_URL="http://localhost:3000" volumes: - - ./config:/config/ # Should contain your .env file + - ./config:/config/ # If you want to specify the variables in your `postiz.env` file. ports: - 4200:4200 - 3000:3000 diff --git a/apps/docs/installation/docker.mdx b/apps/docs/installation/docker.mdx index 154cdea60..3ba5228b7 100644 --- a/apps/docs/installation/docker.mdx +++ b/apps/docs/installation/docker.mdx @@ -4,24 +4,36 @@ title: Docker import EarlyDoc from '/snippets/earlydoc.mdx'; import DockerEnvvarApps from '/snippets/docker-envvar-apps.mdx'; +import DockerEnvvarGeneral from '/snippets/docker-envvar-general.mdx'; -# Set environment variables + -Postiz configuration is entirely via environment variables for now. You might be used to setting environment variables when starting containers, -however postiz needs a LOT of environment variables, so setting these on command line or in a docker-compose is probably not practical for long -term maintainability. +The container images will copy a file called `/config/postiz.env` to `/apps/.env` on startup. -It is recommended to use a `.env` file, which the Postiz containers look for in /config. Docker will automatically create this file for you on a -docker volume the first time you start up Postiz. +# Create the container on command line -The default .env file can be found here; [example .env file](https://raw.githubusercontent.com/gitroomhq/postiz-app/main/.env.example) +It is recommended to have a local directory where you save your `postiz.env` file, such as `/myContainers/postiz/config`, which is mounted as a volume. -# Create the container on command line +```bash Using a configuration volume +docker create --name postiz -v /myContainers/postiz/config:/config -p 4200:4200 -p 3000:3000 ghcr.io/gitroomhq/postiz-app:latest +``` -```bash -docker create --name postiz -v ./config:/config -p 4200:4200 -p 3000:3000 ghcr.io/gitroomhq/postiz-app:latest +Alternatively, you can specify the variables one by one at creation time. This approach is not recommended +simply because it's a pain to manage, and sensitive keys get stored with the container definition, which is bad practice. + +```bash At creation-time (not recommended) +docker create --name postiz \ + -e DATABASE_URL=postgres://... \ + -e REDIS_URL=redis:// \ + -e JWT_SECRET \ + ... \ + -p 4200:4200 \ + -p 3000:3000 \ + ghcr.io/gitroomhq/postiz-app:latest ``` + + diff --git a/apps/docs/mint.json b/apps/docs/mint.json index 7fa169e09..4b375a4d9 100644 --- a/apps/docs/mint.json +++ b/apps/docs/mint.json @@ -70,6 +70,12 @@ "installation/kubernetes-helm" ] }, + { + "group": "Configuration", + "pages": [ + "configuration/reference" + ] + }, "howitworks", "emails", "github", diff --git a/apps/docs/snippets/docker-envvar-apps.mdx b/apps/docs/snippets/docker-envvar-apps.mdx index 967daf402..314aeaa50 100644 --- a/apps/docs/snippets/docker-envvar-apps.mdx +++ b/apps/docs/snippets/docker-envvar-apps.mdx @@ -1,7 +1,10 @@ ## Controlling container services -The environment variable POSTIZ_APPS defaults to "", which means that all -services will be started in a single container. However, you can only start -specific services within the docker container by changing this environement variable. +When the environment variable `POSTIZ_APPS` is not set, or is set to an empty string, all +services will be started in a single container. This is normally fine for small, personal deployments. -For most deployments, starting all services is fine. To scale out, you might want -to start individual containers for "frontend", "backend", "worker" and "cron". +However, you can only start specific services within the docker container by changing this environement variable. + +If you need to scale, you can experiement with having multiple containers defined like; +- Frontend only: `POSTIZ_APPS="frontend"` +- Backend only: `POSTIZ_APPS="backend"` +- Worker and Cron only: `POSTIZ_APPS="worker cron"` diff --git a/apps/docs/snippets/docker-envvar-general.mdx b/apps/docs/snippets/docker-envvar-general.mdx new file mode 100644 index 000000000..cf1a09714 --- /dev/null +++ b/apps/docs/snippets/docker-envvar-general.mdx @@ -0,0 +1,15 @@ +# Set environment variables + +Postiz configuration is entirely via environment variables. + +When using Postiz container images, you can specify the environment variables when you create the container (`docker create -e DATABASE_URL=...`), but this might be +a bit tedious, as Postiz requires quite a few variables set to startup. + +It is recommended to use a `postiz.env` file, which the Postiz containers look for in /config. Docker will automatically create this file for you on a +docker volume the first time you start up Postiz. The default container images will copy the `/config/postiz.env` to `/apps/.env` on startup. Like with +any environment variables, if you change them, you must restart the application for the changes to take effect. + +An example file of the most used configuration settings can be found here; [example postiz.env file](https://raw.githubusercontent.com/gitroomhq/postiz-app/main/.env.example) + +There is also a [configuration reference](/configuration/reference) page that goes into more detail. +