Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main'
Browse files Browse the repository at this point in the history
  • Loading branch information
Nevo David committed Sep 14, 2024
2 parents a04b96d + 1498f04 commit e88629a
Show file tree
Hide file tree
Showing 8 changed files with 103 additions and 59 deletions.
72 changes: 46 additions & 26 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,15 +1,34 @@
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=""
# 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=""
X_API_SECRET=""
X_CLIENT=""
Expand All @@ -20,19 +39,8 @@ REDDIT_CLIENT_ID=""
REDDIT_CLIENT_SECRET=""
GITHUB_CLIENT_ID=""
GITHUB_CLIENT_SECRET=""
RESEND_API_KEY=""
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=""
Expand All @@ -45,7 +53,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=""
STRIPE_SIGNING_KEY_CONNECT=""

# Developer Settings
NX_ADD_PLUGINS=false
IS_GENERAL="true" # required for now
24 changes: 15 additions & 9 deletions Dockerfile.dev
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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

Expand All @@ -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
Expand All @@ -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)"
36 changes: 26 additions & 10 deletions apps/docs/installation/development.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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://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

- **[Resend account](https://resend.com)** - for user activation and email notifications.

### Prerequisite Local Services

- **Node.js** - for running the code! (version 18+)
Expand Down Expand Up @@ -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"
Expand All @@ -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
Expand Down
2 changes: 0 additions & 2 deletions apps/docs/installation/docker-compose.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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';

<EarlyDoc />
<DockerDatabase />

# Example `docker-compose.yml` file

Expand Down
13 changes: 10 additions & 3 deletions apps/docs/installation/docker.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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';

<EarlyDoc />

<DockerDatabase />
# 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:latest
docker create --name postiz -v ./config:/config -p 4200:4200 -p 3000:3000 ghcr.io/gitroomhq/postiz-app:latest
```

<DockerEnvvarApps />
6 changes: 0 additions & 6 deletions apps/docs/snippets/docker-database.mdx

This file was deleted.

5 changes: 4 additions & 1 deletion var/docker/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,17 @@ 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
echo "POSTIZ_APPS is not set, starting everything!"
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
Expand Down
4 changes: 2 additions & 2 deletions var/docker/supervisord/frontend.conf
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit e88629a

Please sign in to comment.