From e3fd3480f58021456a93a181404027de909f001e Mon Sep 17 00:00:00 2001
From: Rohit Dash
Date: Mon, 21 Oct 2024 16:35:18 +0530
Subject: [PATCH 01/23] add heroku 1-click deployment files
---
.deploy/Dockerfile | 35 +++++++++++++++++++
.deploy/app.json | 64 ++++++++++++++++++++++++++++++++++
.deploy/docker-compose.dev.yml | 37 ++++++++++++++++++++
.deploy/entrypoint.sh | 26 ++++++++++++++
.deploy/healthcheck.sh | 8 +++++
.deploy/heroku.yml | 17 +++++++++
.deploy/supervisord.conf | 25 +++++++++++++
7 files changed, 212 insertions(+)
create mode 100644 .deploy/Dockerfile
create mode 100644 .deploy/app.json
create mode 100644 .deploy/docker-compose.dev.yml
create mode 100644 .deploy/entrypoint.sh
create mode 100644 .deploy/healthcheck.sh
create mode 100644 .deploy/heroku.yml
create mode 100644 .deploy/supervisord.conf
diff --git a/.deploy/Dockerfile b/.deploy/Dockerfile
new file mode 100644
index 00000000..77a7636a
--- /dev/null
+++ b/.deploy/Dockerfile
@@ -0,0 +1,35 @@
+FROM docker.io/node:${NODE_VERSION}-alpine3.19 AS builder
+
+WORKDIR /app
+
+RUN apk add --no-cache python3 make g++ pkgconfig cairo-dev pango-dev
+
+COPY package*.json ./
+COPY nx.json tsconfig.base.json ./
+COPY apps ./apps
+COPY libraries ./libraries
+
+RUN npm ci
+RUN npx nx run-many --target=build --projects=frontend,backend,workers,cron --parallel=4
+
+FROM docker.io/node:${NODE_VERSION}-alpine3.19 AS production
+
+WORKDIR /app
+
+RUN apk add --no-cache \
+ bash \
+ supervisor \
+ curl
+
+COPY --from=builder /app/dist ./dist
+COPY --from=builder /app/node_modules ./node_modules
+COPY package*.json ./
+
+COPY .deploy/entrypoint.sh /app/entrypoint.sh
+COPY .deploy/worker-entrypoint.sh /etc/supervisord.conf
+COPY .deploy/healthcheck.sh /app/healthcheck.sh
+
+RUN chmod +x /app/entrypoint.sh /app/healthcheck.sh
+
+HEALTHCHECK --interval=30s --timeout=30s --start-period=5s --retries=3 \
+ CMD [ "/app/healthcheck.sh" ]
\ No newline at end of file
diff --git a/.deploy/app.json b/.deploy/app.json
new file mode 100644
index 00000000..45216128
--- /dev/null
+++ b/.deploy/app.json
@@ -0,0 +1,64 @@
+{
+ "name": "Postiz",
+ "description": "Self-hosted content management platform",
+ "keywords": ["node", "express", "next.js", "cms", "headless-cms"],
+ "website": "https://github.com/gitroomhq/postiz-app",
+ "repository": "https://github.com/gitroomhq/postiz-app",
+ "logo": "https://raw.githubusercontent.com/gitroomhq/postiz-app/main/apps/frontend/public/logo.png",
+ "success_url": "/",
+ "stack": "container",
+ "env": {
+ "NODE_ENV": {
+ "description": "Environment type",
+ "value": "production"
+ },
+ "JWT_SECRET": {
+ "description": "Secret key for JWT tokens",
+ "generator": "secret"
+ },
+ "ADMIN_PASSWORD": {
+ "description": "Initial admin password",
+ "generator": "secret"
+ },
+ "DATABASE_URL": {
+ "description": "DATABASE_URL for Postgres connection",
+ "required": true
+ },
+ "REDIS_URL": {
+ "description": "REDIS_URL for Redis connection",
+ "required": true
+ },
+ "APP_URL": {
+ "description": "Application URL (will be auto-filled)",
+ "required": true
+ }
+ },
+ "addons": [
+ {
+ "plan": "heroku-postgresql:hobby-dev",
+ "as": "DATABASE"
+ },
+ {
+ "plan": "heroku-redis:hobby-dev",
+ "as": "REDIS"
+ }
+ ],
+ "buildpacks": [
+ {
+ "url": "heroku/nodejs"
+ }
+ ],
+ "formation": {
+ "web": {
+ "quantity": 1,
+ "size": "basic"
+ },
+ "worker": {
+ "quantity": 1,
+ "size": "basic"
+ }
+ },
+ "scripts": {
+ "postdeploy": "npm run db:init && npm run db:seed"
+ }
+}
diff --git a/.deploy/docker-compose.dev.yml b/.deploy/docker-compose.dev.yml
new file mode 100644
index 00000000..85806955
--- /dev/null
+++ b/.deploy/docker-compose.dev.yml
@@ -0,0 +1,37 @@
+version: '3'
+services:
+ postiz-app:
+ build: .
+ ports:
+ - "3000:3000"
+ volumes:
+ - .:/app
+ - /app/node_modules
+ environment:
+ NODE_ENV: development
+ DATABASE_URL: postgres://postiz-local:postiz-local-pwd@postiz-postgres:5432/postiz-db-local
+ REDIS_URL: redis://postiz-redis:6379
+ depends_on:
+ - postiz-postgres
+ - postiz-redis
+
+ postiz-postgres:
+ image: postgres:14.5
+ container_name: postiz-postgres
+ environment:
+ POSTGRES_PASSWORD: postiz-local-pwd
+ POSTGRES_USER: postiz-local
+ POSTGRES_DB: postiz-db-local
+ volumes:
+ - postgres-volume:/var/lib/postgresql/data
+ ports:
+ - "5432:5432"
+
+ postiz-redis:
+ image: redis:7.2
+ container_name: postiz-redis
+ ports:
+ - "6379:6379"
+
+volumes:
+ postgres-volume:
diff --git a/.deploy/entrypoint.sh b/.deploy/entrypoint.sh
new file mode 100644
index 00000000..bb26b076
--- /dev/null
+++ b/.deploy/entrypoint.sh
@@ -0,0 +1,26 @@
+#!/bin/bash
+set -e
+
+# Function to wait for services
+wait_for_service() {
+ echo "Waiting for $1 to be ready..."
+ until $2; do
+ echo "Service $1 is not ready - sleeping"
+ sleep 1
+ done
+ echo "$1 is ready!"
+}
+
+# Wait for PostgreSQL
+wait_for_service "PostgreSQL" "pg_isready -h $DB_HOST -p $DB_PORT -U $DB_USER"
+
+# Wait for Redis
+wait_for_service "Redis" "redis-cli -h $REDIS_HOST -p $REDIS_PORT ping"
+
+if [ "$RUN_MIGRATIONS" = "true" ]; then
+ echo "Running database migrations..."
+ npm run db:migrate
+fi
+
+# Start supervisor
+exec /usr/bin/supervisord -n -c /etc/supervisord.conf
\ No newline at end of file
diff --git a/.deploy/healthcheck.sh b/.deploy/healthcheck.sh
new file mode 100644
index 00000000..bd9d5fee
--- /dev/null
+++ b/.deploy/healthcheck.sh
@@ -0,0 +1,8 @@
+#!/bin/bash
+set -e
+
+curl --fail http://localhost:$POST/health || exit 1
+
+npm run db:health || exit 1
+
+npm run redis:health || exit 1
\ No newline at end of file
diff --git a/.deploy/heroku.yml b/.deploy/heroku.yml
new file mode 100644
index 00000000..5e44f5e0
--- /dev/null
+++ b/.deploy/heroku.yml
@@ -0,0 +1,17 @@
+setup:
+ addons:
+ - plan: heroku-postgresql:hobby-dev
+ as: DATABASE
+ - plan: heroku-redis:hobby-dev
+ as: REDIS
+
+build:
+ docker:
+ web: .deploy/Dockerfile
+ worker: .deploy/Dockerfile.worker
+ config:
+ NODE_ENV: production
+
+run:
+ web: /app/entrypoint.sh
+ worker: /app/worker-entrypoint.sh
diff --git a/.deploy/supervisord.conf b/.deploy/supervisord.conf
new file mode 100644
index 00000000..014528d0
--- /dev/null
+++ b/.deploy/supervisord.conf
@@ -0,0 +1,25 @@
+[supervisord]
+nodaemon=true
+user=root
+logfile=/dev/stdout
+logfile_maxbytes=0
+
+[program:app]
+command=npm start
+directory=/app
+autostart=true
+autorestart=true
+stderr_logfile=/dev/stderr
+stderr_logfile_maxbytes=0
+stdout_logfile=/dev/stdout
+stdout_logfile_maxbytes=0
+
+[program:worker]
+command=npm run worker
+directory=/app
+autostart=true
+autorestart=true
+stderr_logfile=/dev/stdout
+stderr_logfile_maxbytes=0
+stdout_logfile=/dev/stdout
+stdout_logfile_maxbytes=0
\ No newline at end of file
From 9862e47551d0e8d65bd9dc2a6fa9e05e88e3c5ce Mon Sep 17 00:00:00 2001
From: Rohit Dash
Date: Tue, 22 Oct 2024 05:08:11 +0530
Subject: [PATCH 02/23] Heroku 1-click deployment using existing Docker images
---
.../workflows/build-containers-enterprise.yml | 13 ++++--
.heroku/app.json | 46 +++++++++++++++++++
.heroku/heroku.yml | 15 ++++++
var/docker/entrypoint.sh | 30 +++++++++++-
4 files changed, 97 insertions(+), 7 deletions(-)
create mode 100644 .heroku/app.json
create mode 100644 .heroku/heroku.yml
diff --git a/.github/workflows/build-containers-enterprise.yml b/.github/workflows/build-containers-enterprise.yml
index 8776e463..e3b0fe26 100644
--- a/.github/workflows/build-containers-enterprise.yml
+++ b/.github/workflows/build-containers-enterprise.yml
@@ -1,5 +1,5 @@
---
-name: "Build Containers Enterprise"
+name: 'Build Containers Enterprise'
on:
workflow_dispatch:
@@ -20,7 +20,7 @@ jobs:
build-containers:
needs: build-containers-common
- strategy:
+ strategy:
matrix:
include:
- runnertags: ubuntu-latest
@@ -52,7 +52,7 @@ jobs:
docker images
- name: docker tag
- env:
+ env:
CONTAINERVER: ${{ needs.build-containers-common.outputs.containerver }}
run: |
docker tag localhost/postiz ghcr.io/gitroomhq/postiz-app-enterprise:${{ matrix.arch }}-${{ env.CONTAINERVER }}
@@ -64,6 +64,9 @@ jobs:
docker tag ghcr.io/gitroomhq/postiz-devcontainer-enterprise:${{ env.CONTAINERVER }} ghcr.io/gitroomhq/postiz-devcontainer-enterprise:latest
docker push ghcr.io/gitroomhq/postiz-devcontainer-enterprise:latest
+ docker tag localhost/postiz ghcr.io/gitroomhq/postiz-app-enterprise:latest
+ docker push ghcr.io/gitroomhq/postiz-app-enterprise:latest
+
build-container-manifest:
needs: [build-containers, build-containers-common]
runs-on: ubuntu-latest
@@ -75,8 +78,8 @@ jobs:
username: ${{ github.actor }}
password: ${{ github.token }}
- - name: Create Docker Manifest
- env:
+ - name: Create Docker Manifest
+ env:
CONTAINERVER: ${{ needs.build-containers-common.outputs.containerver }}
run: |
docker manifest create \
diff --git a/.heroku/app.json b/.heroku/app.json
new file mode 100644
index 00000000..2d723159
--- /dev/null
+++ b/.heroku/app.json
@@ -0,0 +1,46 @@
+{
+ "name": "Postiz",
+ "description": "Self-hosted content management platform",
+ "keywords": ["node", "express", "next.js", "cms", "headless-cms"],
+ "website": "https://github.com/gitroomhq/postiz-app",
+ "repository": "https://github.com/gitroomhq/postiz-app",
+ "logo": "https://raw.githubusercontent.com/gitroomhq/postiz-app/main/apps/frontend/public/logo.png",
+ "success_url": "/",
+ "stack": "container",
+ "env": {
+ "NODE_ENV": {
+ "description": "Environment type",
+ "value": "production"
+ },
+ "JWT_SECRET": {
+ "description": "Secret key for JWT tokens",
+ "generator": "secret"
+ },
+ "ADMIN_PASSWORD": {
+ "description": "Initial admin password",
+ "generator": "secret"
+ },
+ "DATABASE_URL": {
+ "description": "DATABASE_URL for Postgres connection",
+ "required": true
+ },
+ "REDIS_URL": {
+ "description": "REDIS_URL for Redis connection",
+ "required": true
+ },
+ "APP_URL": {
+ "description": "Application URL (will be auto-filled)",
+ "required": true
+ }
+ },
+ "addons": [
+ {
+ "plan": "heroku-postgresql:hobby-dev",
+ "as": "DATABASE"
+ },
+ {
+ "plan": "heroku-redis:hobby-dev",
+ "as": "REDIS"
+ }
+ ]
+}
diff --git a/.heroku/heroku.yml b/.heroku/heroku.yml
new file mode 100644
index 00000000..52ec9d7c
--- /dev/null
+++ b/.heroku/heroku.yml
@@ -0,0 +1,15 @@
+setup:
+ addons:
+ - plan: heroku-postgresql:hobby-dev
+ as: DATABASE
+ - plan: heroku-redis:hobby-dev
+ as: REDIS
+
+build:
+ docker:
+ web: ghcr.io/gitroomhq/postiz-app-enterprise:latest
+ config:
+ NODE_ENV: production
+
+run:
+ web: /app/entrypoint.sh
diff --git a/var/docker/entrypoint.sh b/var/docker/entrypoint.sh
index e2914d74..14db805d 100755
--- a/var/docker/entrypoint.sh
+++ b/var/docker/entrypoint.sh
@@ -2,13 +2,33 @@
set -o xtrace
+export DATABSAE_URL=${DATABASE_URL:-$HEROKU_POSTGRESQL_DATABASE_URL}
+export REDIS_URL=${REDIS_URL:-$HEROKU_REDIS_URL}
+
+wait_for_service() {
+ echo "Waiting for $1 to be ready..."
+ until $2; do
+ echo "Waiting for $1 is not ready - sleeping"
+ sleep 1
+ done
+ echo "$1 is ready!"
+}
+
+if [[ -n "$DATABASE_URL" ]]; then
+ wait_for_service "PostgreSQL" "pg_isready -h $(echo $DATABASE_URL | cut -d@ -f2 | cut -d/ -f1) -p 5432"
+fi
+
+if [[ -n "$REDIS_URL" ]]; then
+ wait_for_service "Redis" "redis-cli -u $REDIS_URL ping"
+fi
+npm run prisma-db-push
if [[ "$SKIP_CONFIG_CHECK" != "true" ]]; then
echo "Entrypoint: Copying /config/postiz.env into /app/.env"
-
+ cp -vf /app/supervisord_available_configs/caddy.conf /etc/supervisor.d/
if [ ! -f /config/postiz.env ]; then
echo "Entrypoint: WARNING: No postiz.env file found in /config/postiz.env"
fi
-
+ ln -sf /app/supervisord_available_configs/frontend.conf /etc/supervisor.d/
cp -vf /config/postiz.env /app/.env
fi
@@ -17,6 +37,12 @@ if [[ "$POSTIZ_APPS" -eq "" ]]; then
POSTIZ_APPS="frontend workers cron backend"
fi
+if [[$POSTIZ_APPS == *"workers"* ]]; then
+if [[ "$POSTIZ_APPS" -ep "" ]]; then
+ POSTIZ_APPS="frontend workers cron backend"
+fi
+ ln -sf /app/supervisord_available_configs/cron.conf /etc/supervisor.d/
+
echo "Entrypoint: Running database migrations"
npm run prisma-db-push
From eebed10f9d6a41209c04bc7920bc98c526852bcf Mon Sep 17 00:00:00 2001
From: Rohit Dash
Date: Tue, 22 Oct 2024 05:10:27 +0530
Subject: [PATCH 03/23] Heroku 1-click deployment using existing Docker images
and removed .deploy folder
---
.deploy/Dockerfile | 35 -------------------
.deploy/app.json | 64 ----------------------------------
.deploy/docker-compose.dev.yml | 37 --------------------
.deploy/entrypoint.sh | 26 --------------
.deploy/healthcheck.sh | 8 -----
.deploy/heroku.yml | 17 ---------
.deploy/supervisord.conf | 25 -------------
7 files changed, 212 deletions(-)
delete mode 100644 .deploy/Dockerfile
delete mode 100644 .deploy/app.json
delete mode 100644 .deploy/docker-compose.dev.yml
delete mode 100644 .deploy/entrypoint.sh
delete mode 100644 .deploy/healthcheck.sh
delete mode 100644 .deploy/heroku.yml
delete mode 100644 .deploy/supervisord.conf
diff --git a/.deploy/Dockerfile b/.deploy/Dockerfile
deleted file mode 100644
index 77a7636a..00000000
--- a/.deploy/Dockerfile
+++ /dev/null
@@ -1,35 +0,0 @@
-FROM docker.io/node:${NODE_VERSION}-alpine3.19 AS builder
-
-WORKDIR /app
-
-RUN apk add --no-cache python3 make g++ pkgconfig cairo-dev pango-dev
-
-COPY package*.json ./
-COPY nx.json tsconfig.base.json ./
-COPY apps ./apps
-COPY libraries ./libraries
-
-RUN npm ci
-RUN npx nx run-many --target=build --projects=frontend,backend,workers,cron --parallel=4
-
-FROM docker.io/node:${NODE_VERSION}-alpine3.19 AS production
-
-WORKDIR /app
-
-RUN apk add --no-cache \
- bash \
- supervisor \
- curl
-
-COPY --from=builder /app/dist ./dist
-COPY --from=builder /app/node_modules ./node_modules
-COPY package*.json ./
-
-COPY .deploy/entrypoint.sh /app/entrypoint.sh
-COPY .deploy/worker-entrypoint.sh /etc/supervisord.conf
-COPY .deploy/healthcheck.sh /app/healthcheck.sh
-
-RUN chmod +x /app/entrypoint.sh /app/healthcheck.sh
-
-HEALTHCHECK --interval=30s --timeout=30s --start-period=5s --retries=3 \
- CMD [ "/app/healthcheck.sh" ]
\ No newline at end of file
diff --git a/.deploy/app.json b/.deploy/app.json
deleted file mode 100644
index 45216128..00000000
--- a/.deploy/app.json
+++ /dev/null
@@ -1,64 +0,0 @@
-{
- "name": "Postiz",
- "description": "Self-hosted content management platform",
- "keywords": ["node", "express", "next.js", "cms", "headless-cms"],
- "website": "https://github.com/gitroomhq/postiz-app",
- "repository": "https://github.com/gitroomhq/postiz-app",
- "logo": "https://raw.githubusercontent.com/gitroomhq/postiz-app/main/apps/frontend/public/logo.png",
- "success_url": "/",
- "stack": "container",
- "env": {
- "NODE_ENV": {
- "description": "Environment type",
- "value": "production"
- },
- "JWT_SECRET": {
- "description": "Secret key for JWT tokens",
- "generator": "secret"
- },
- "ADMIN_PASSWORD": {
- "description": "Initial admin password",
- "generator": "secret"
- },
- "DATABASE_URL": {
- "description": "DATABASE_URL for Postgres connection",
- "required": true
- },
- "REDIS_URL": {
- "description": "REDIS_URL for Redis connection",
- "required": true
- },
- "APP_URL": {
- "description": "Application URL (will be auto-filled)",
- "required": true
- }
- },
- "addons": [
- {
- "plan": "heroku-postgresql:hobby-dev",
- "as": "DATABASE"
- },
- {
- "plan": "heroku-redis:hobby-dev",
- "as": "REDIS"
- }
- ],
- "buildpacks": [
- {
- "url": "heroku/nodejs"
- }
- ],
- "formation": {
- "web": {
- "quantity": 1,
- "size": "basic"
- },
- "worker": {
- "quantity": 1,
- "size": "basic"
- }
- },
- "scripts": {
- "postdeploy": "npm run db:init && npm run db:seed"
- }
-}
diff --git a/.deploy/docker-compose.dev.yml b/.deploy/docker-compose.dev.yml
deleted file mode 100644
index 85806955..00000000
--- a/.deploy/docker-compose.dev.yml
+++ /dev/null
@@ -1,37 +0,0 @@
-version: '3'
-services:
- postiz-app:
- build: .
- ports:
- - "3000:3000"
- volumes:
- - .:/app
- - /app/node_modules
- environment:
- NODE_ENV: development
- DATABASE_URL: postgres://postiz-local:postiz-local-pwd@postiz-postgres:5432/postiz-db-local
- REDIS_URL: redis://postiz-redis:6379
- depends_on:
- - postiz-postgres
- - postiz-redis
-
- postiz-postgres:
- image: postgres:14.5
- container_name: postiz-postgres
- environment:
- POSTGRES_PASSWORD: postiz-local-pwd
- POSTGRES_USER: postiz-local
- POSTGRES_DB: postiz-db-local
- volumes:
- - postgres-volume:/var/lib/postgresql/data
- ports:
- - "5432:5432"
-
- postiz-redis:
- image: redis:7.2
- container_name: postiz-redis
- ports:
- - "6379:6379"
-
-volumes:
- postgres-volume:
diff --git a/.deploy/entrypoint.sh b/.deploy/entrypoint.sh
deleted file mode 100644
index bb26b076..00000000
--- a/.deploy/entrypoint.sh
+++ /dev/null
@@ -1,26 +0,0 @@
-#!/bin/bash
-set -e
-
-# Function to wait for services
-wait_for_service() {
- echo "Waiting for $1 to be ready..."
- until $2; do
- echo "Service $1 is not ready - sleeping"
- sleep 1
- done
- echo "$1 is ready!"
-}
-
-# Wait for PostgreSQL
-wait_for_service "PostgreSQL" "pg_isready -h $DB_HOST -p $DB_PORT -U $DB_USER"
-
-# Wait for Redis
-wait_for_service "Redis" "redis-cli -h $REDIS_HOST -p $REDIS_PORT ping"
-
-if [ "$RUN_MIGRATIONS" = "true" ]; then
- echo "Running database migrations..."
- npm run db:migrate
-fi
-
-# Start supervisor
-exec /usr/bin/supervisord -n -c /etc/supervisord.conf
\ No newline at end of file
diff --git a/.deploy/healthcheck.sh b/.deploy/healthcheck.sh
deleted file mode 100644
index bd9d5fee..00000000
--- a/.deploy/healthcheck.sh
+++ /dev/null
@@ -1,8 +0,0 @@
-#!/bin/bash
-set -e
-
-curl --fail http://localhost:$POST/health || exit 1
-
-npm run db:health || exit 1
-
-npm run redis:health || exit 1
\ No newline at end of file
diff --git a/.deploy/heroku.yml b/.deploy/heroku.yml
deleted file mode 100644
index 5e44f5e0..00000000
--- a/.deploy/heroku.yml
+++ /dev/null
@@ -1,17 +0,0 @@
-setup:
- addons:
- - plan: heroku-postgresql:hobby-dev
- as: DATABASE
- - plan: heroku-redis:hobby-dev
- as: REDIS
-
-build:
- docker:
- web: .deploy/Dockerfile
- worker: .deploy/Dockerfile.worker
- config:
- NODE_ENV: production
-
-run:
- web: /app/entrypoint.sh
- worker: /app/worker-entrypoint.sh
diff --git a/.deploy/supervisord.conf b/.deploy/supervisord.conf
deleted file mode 100644
index 014528d0..00000000
--- a/.deploy/supervisord.conf
+++ /dev/null
@@ -1,25 +0,0 @@
-[supervisord]
-nodaemon=true
-user=root
-logfile=/dev/stdout
-logfile_maxbytes=0
-
-[program:app]
-command=npm start
-directory=/app
-autostart=true
-autorestart=true
-stderr_logfile=/dev/stderr
-stderr_logfile_maxbytes=0
-stdout_logfile=/dev/stdout
-stdout_logfile_maxbytes=0
-
-[program:worker]
-command=npm run worker
-directory=/app
-autostart=true
-autorestart=true
-stderr_logfile=/dev/stdout
-stderr_logfile_maxbytes=0
-stdout_logfile=/dev/stdout
-stdout_logfile_maxbytes=0
\ No newline at end of file
From b67799929a9e052be99d61876b4927edac9cfa7b Mon Sep 17 00:00:00 2001
From: Rohit Dash
Date: Tue, 22 Oct 2024 05:37:00 +0530
Subject: [PATCH 04/23] railway app 1-click deployment
---
.railway/railway.json | 14 ++++++++++++++
.railway/variables.tf | 21 +++++++++++++++++++++
2 files changed, 35 insertions(+)
create mode 100644 .railway/railway.json
create mode 100644 .railway/variables.tf
diff --git a/.railway/railway.json b/.railway/railway.json
new file mode 100644
index 00000000..861963d9
--- /dev/null
+++ b/.railway/railway.json
@@ -0,0 +1,14 @@
+{
+ "$schema": "https://railway.app/railway.schema.json",
+ "build": {
+ "builder": "DOCKERFILE",
+ "dockerfilePath": "../Dockerfile.dev"
+ },
+ "deploy": {
+ "startCommand": "/app/entrypoint.sh",
+ "healthcheckPath": "/health",
+ "healthcheckTimeout": 100,
+ "restartPolicyType": "ON_FAILURE",
+ "restartPolicyMaxRetries": 10
+ }
+}
diff --git a/.railway/variables.tf b/.railway/variables.tf
new file mode 100644
index 00000000..fc4862a8
--- /dev/null
+++ b/.railway/variables.tf
@@ -0,0 +1,21 @@
+variable "NODE_ENV" {
+ default = "production"
+}
+
+variable "JWT_SECRET" {
+ sensitive = true
+}
+
+variable "ADMIN_PASSWORD" {
+ sensitive = true
+}
+
+variable "DATABASE_URL" {
+ sensitive = true
+}
+
+variable "REDIS_URL" {
+ sensitive = true
+}
+
+variable "APP_URL" {}
\ No newline at end of file
From dd8e04511d6ca5189e7ba2e1ca5062ec8d1c79fc Mon Sep 17 00:00:00 2001
From: Rohit Dash
Date: Tue, 22 Oct 2024 05:58:05 +0530
Subject: [PATCH 05/23] fix the startcommand for railwayapp
---
.railway/railway.json | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/.railway/railway.json b/.railway/railway.json
index 861963d9..14c97902 100644
--- a/.railway/railway.json
+++ b/.railway/railway.json
@@ -5,7 +5,7 @@
"dockerfilePath": "../Dockerfile.dev"
},
"deploy": {
- "startCommand": "/app/entrypoint.sh",
+ "startCommand": "npm run start:prod",
"healthcheckPath": "/health",
"healthcheckTimeout": 100,
"restartPolicyType": "ON_FAILURE",
From 691c9d163495c3849973059e2ecdfede30fe33d8 Mon Sep 17 00:00:00 2001
From: Rohit Dash
Date: Tue, 22 Oct 2024 06:00:43 +0530
Subject: [PATCH 06/23] railway app 1-click deployment
---
.railway/railway.json | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/.railway/railway.json b/.railway/railway.json
index 14c97902..861963d9 100644
--- a/.railway/railway.json
+++ b/.railway/railway.json
@@ -5,7 +5,7 @@
"dockerfilePath": "../Dockerfile.dev"
},
"deploy": {
- "startCommand": "npm run start:prod",
+ "startCommand": "/app/entrypoint.sh",
"healthcheckPath": "/health",
"healthcheckTimeout": 100,
"restartPolicyType": "ON_FAILURE",
From 0be9084f8dd33535451a14829a866e04b7e014c3 Mon Sep 17 00:00:00 2001
From: Rohit Dash
Date: Sun, 27 Oct 2024 01:55:26 +0530
Subject: [PATCH 07/23] 1-click railway deploy
---
.heroku/app.json | 46 -------------------------------------
.heroku/heroku.yml | 15 ------------
.railway/railway.json | 14 ------------
.railway/template.yaml | 52 ++++++++++++++++++++++++++++++++++++++++++
.railway/variables.tf | 21 -----------------
5 files changed, 52 insertions(+), 96 deletions(-)
delete mode 100644 .heroku/app.json
delete mode 100644 .heroku/heroku.yml
delete mode 100644 .railway/railway.json
create mode 100644 .railway/template.yaml
delete mode 100644 .railway/variables.tf
diff --git a/.heroku/app.json b/.heroku/app.json
deleted file mode 100644
index 2d723159..00000000
--- a/.heroku/app.json
+++ /dev/null
@@ -1,46 +0,0 @@
-{
- "name": "Postiz",
- "description": "Self-hosted content management platform",
- "keywords": ["node", "express", "next.js", "cms", "headless-cms"],
- "website": "https://github.com/gitroomhq/postiz-app",
- "repository": "https://github.com/gitroomhq/postiz-app",
- "logo": "https://raw.githubusercontent.com/gitroomhq/postiz-app/main/apps/frontend/public/logo.png",
- "success_url": "/",
- "stack": "container",
- "env": {
- "NODE_ENV": {
- "description": "Environment type",
- "value": "production"
- },
- "JWT_SECRET": {
- "description": "Secret key for JWT tokens",
- "generator": "secret"
- },
- "ADMIN_PASSWORD": {
- "description": "Initial admin password",
- "generator": "secret"
- },
- "DATABASE_URL": {
- "description": "DATABASE_URL for Postgres connection",
- "required": true
- },
- "REDIS_URL": {
- "description": "REDIS_URL for Redis connection",
- "required": true
- },
- "APP_URL": {
- "description": "Application URL (will be auto-filled)",
- "required": true
- }
- },
- "addons": [
- {
- "plan": "heroku-postgresql:hobby-dev",
- "as": "DATABASE"
- },
- {
- "plan": "heroku-redis:hobby-dev",
- "as": "REDIS"
- }
- ]
-}
diff --git a/.heroku/heroku.yml b/.heroku/heroku.yml
deleted file mode 100644
index 52ec9d7c..00000000
--- a/.heroku/heroku.yml
+++ /dev/null
@@ -1,15 +0,0 @@
-setup:
- addons:
- - plan: heroku-postgresql:hobby-dev
- as: DATABASE
- - plan: heroku-redis:hobby-dev
- as: REDIS
-
-build:
- docker:
- web: ghcr.io/gitroomhq/postiz-app-enterprise:latest
- config:
- NODE_ENV: production
-
-run:
- web: /app/entrypoint.sh
diff --git a/.railway/railway.json b/.railway/railway.json
deleted file mode 100644
index 861963d9..00000000
--- a/.railway/railway.json
+++ /dev/null
@@ -1,14 +0,0 @@
-{
- "$schema": "https://railway.app/railway.schema.json",
- "build": {
- "builder": "DOCKERFILE",
- "dockerfilePath": "../Dockerfile.dev"
- },
- "deploy": {
- "startCommand": "/app/entrypoint.sh",
- "healthcheckPath": "/health",
- "healthcheckTimeout": 100,
- "restartPolicyType": "ON_FAILURE",
- "restartPolicyMaxRetries": 10
- }
-}
diff --git a/.railway/template.yaml b/.railway/template.yaml
new file mode 100644
index 00000000..79d25b6e
--- /dev/null
+++ b/.railway/template.yaml
@@ -0,0 +1,52 @@
+service:
+ web:
+ dockerfile: Dockerfile
+ target: dist
+ numReplicas: 1
+ ports:
+ - 3000:3000
+ - 4200:4200
+ - 5000:5000
+ env:
+ - key: NODE_ENV
+ value: production
+ - key: DATABASE_URL
+ fromService:
+ type: postgres
+ property: connectionString
+ - key: REDIS_URL
+ fromService:
+ type: redis
+ property: connectionString
+ - key: JWT_SECRET
+ generate: secret
+ volumes:
+ - name: uploads
+ path: /uploads
+ - name: config
+ path: /config
+
+databases:
+ - type: postgres
+ name: postiz-db
+ version: '17'
+ ipAllowList: []
+
+services:
+ - type: redis
+ name: postiz-redis
+ version: '7'
+ ipAllowList: []
+
+volumes:
+ - name: uploads
+ mountPath: /uploads
+ persistent: true
+ - name: config
+ mountPath: /config
+ persistent: true
+
+scripts:
+ postDeploy: |
+ npm run prisma-generate
+ npm run prisma-db-push
diff --git a/.railway/variables.tf b/.railway/variables.tf
deleted file mode 100644
index fc4862a8..00000000
--- a/.railway/variables.tf
+++ /dev/null
@@ -1,21 +0,0 @@
-variable "NODE_ENV" {
- default = "production"
-}
-
-variable "JWT_SECRET" {
- sensitive = true
-}
-
-variable "ADMIN_PASSWORD" {
- sensitive = true
-}
-
-variable "DATABASE_URL" {
- sensitive = true
-}
-
-variable "REDIS_URL" {
- sensitive = true
-}
-
-variable "APP_URL" {}
\ No newline at end of file
From 5df62be814150418b2eb818b0188d14907de42e4 Mon Sep 17 00:00:00 2001
From: Rohit Dash
Date: Sun, 27 Oct 2024 02:02:09 +0530
Subject: [PATCH 08/23] removed the changes made to postiz enterprise and
entrypoint
---
.../workflows/build-containers-enterprise.yml | 3 --
var/docker/entrypoint.sh | 32 ++-----------------
2 files changed, 3 insertions(+), 32 deletions(-)
diff --git a/.github/workflows/build-containers-enterprise.yml b/.github/workflows/build-containers-enterprise.yml
index e3b0fe26..f4dedfbf 100644
--- a/.github/workflows/build-containers-enterprise.yml
+++ b/.github/workflows/build-containers-enterprise.yml
@@ -64,9 +64,6 @@ jobs:
docker tag ghcr.io/gitroomhq/postiz-devcontainer-enterprise:${{ env.CONTAINERVER }} ghcr.io/gitroomhq/postiz-devcontainer-enterprise:latest
docker push ghcr.io/gitroomhq/postiz-devcontainer-enterprise:latest
- docker tag localhost/postiz ghcr.io/gitroomhq/postiz-app-enterprise:latest
- docker push ghcr.io/gitroomhq/postiz-app-enterprise:latest
-
build-container-manifest:
needs: [build-containers, build-containers-common]
runs-on: ubuntu-latest
diff --git a/var/docker/entrypoint.sh b/var/docker/entrypoint.sh
index 14db805d..ff2b400c 100755
--- a/var/docker/entrypoint.sh
+++ b/var/docker/entrypoint.sh
@@ -2,33 +2,13 @@
set -o xtrace
-export DATABSAE_URL=${DATABASE_URL:-$HEROKU_POSTGRESQL_DATABASE_URL}
-export REDIS_URL=${REDIS_URL:-$HEROKU_REDIS_URL}
-
-wait_for_service() {
- echo "Waiting for $1 to be ready..."
- until $2; do
- echo "Waiting for $1 is not ready - sleeping"
- sleep 1
- done
- echo "$1 is ready!"
-}
-
-if [[ -n "$DATABASE_URL" ]]; then
- wait_for_service "PostgreSQL" "pg_isready -h $(echo $DATABASE_URL | cut -d@ -f2 | cut -d/ -f1) -p 5432"
-fi
-
-if [[ -n "$REDIS_URL" ]]; then
- wait_for_service "Redis" "redis-cli -u $REDIS_URL ping"
-fi
-npm run prisma-db-push
if [[ "$SKIP_CONFIG_CHECK" != "true" ]]; then
echo "Entrypoint: Copying /config/postiz.env into /app/.env"
- cp -vf /app/supervisord_available_configs/caddy.conf /etc/supervisor.d/
+
if [ ! -f /config/postiz.env ]; then
echo "Entrypoint: WARNING: No postiz.env file found in /config/postiz.env"
fi
- ln -sf /app/supervisord_available_configs/frontend.conf /etc/supervisor.d/
+
cp -vf /config/postiz.env /app/.env
fi
@@ -37,12 +17,6 @@ if [[ "$POSTIZ_APPS" -eq "" ]]; then
POSTIZ_APPS="frontend workers cron backend"
fi
-if [[$POSTIZ_APPS == *"workers"* ]]; then
-if [[ "$POSTIZ_APPS" -ep "" ]]; then
- POSTIZ_APPS="frontend workers cron backend"
-fi
- ln -sf /app/supervisord_available_configs/cron.conf /etc/supervisor.d/
-
echo "Entrypoint: Running database migrations"
npm run prisma-db-push
@@ -69,4 +43,4 @@ if [[ $POSTIZ_APPS == *"backend"* ]]; then
ln -sf /app/supervisord_available_configs/backend.conf /etc/supervisor.d/
fi
-/usr/bin/supervisord -c /etc/supervisord.conf
+/usr/bin/supervisord -c /etc/supervisord.conf
\ No newline at end of file
From db55d1b9dcc5bed5c7de3c885d507cd59461b7da Mon Sep 17 00:00:00 2001
From: Rohit Dash
Date: Sun, 27 Oct 2024 02:42:11 +0530
Subject: [PATCH 09/23] 1-click railway deploy
---
.railway/template.yaml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/.railway/template.yaml b/.railway/template.yaml
index 79d25b6e..8217c4b1 100644
--- a/.railway/template.yaml
+++ b/.railway/template.yaml
@@ -1,6 +1,6 @@
service:
web:
- dockerfile: Dockerfile
+ dockerfile: ../Dockerfile
target: dist
numReplicas: 1
ports:
From 43d1b911cf0694f8e0303ae5bcf2237e3801419b Mon Sep 17 00:00:00 2001
From: Rohit Dash
Date: Sun, 27 Oct 2024 02:44:54 +0530
Subject: [PATCH 10/23] 1-click railway deploy
---
.railway/template.yaml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/.railway/template.yaml b/.railway/template.yaml
index 8217c4b1..cd6fac30 100644
--- a/.railway/template.yaml
+++ b/.railway/template.yaml
@@ -1,6 +1,6 @@
service:
web:
- dockerfile: ../Dockerfile
+ dockerfile: ../Dockerfile.dev
target: dist
numReplicas: 1
ports:
From 5e1aa155b86301f2ec62fa3170e63854c13b75ea Mon Sep 17 00:00:00 2001
From: Rohit Dash
Date: Sun, 27 Oct 2024 04:14:09 +0530
Subject: [PATCH 11/23] 1-click railway deploy
---
package.json | 1 +
1 file changed, 1 insertion(+)
diff --git a/package.json b/package.json
index 8b356af5..07f73c72 100644
--- a/package.json
+++ b/package.json
@@ -16,6 +16,7 @@
"dev:workers": "npx nx run workers:serve:development",
"dev:cron": "npx nx run cron:serve:development",
"dev:docker": "docker compose -f ./docker-compose.dev.yaml up -d",
+ "start": "npm run start:prod",
"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 3ee432a9fc25d0cd23f388a78f00cfe5c881cb6d Mon Sep 17 00:00:00 2001
From: Rohit Dash
Date: Sun, 27 Oct 2024 13:21:51 +0530
Subject: [PATCH 12/23] using dev for testing
---
package.json | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/package.json b/package.json
index 07f73c72..42be756c 100644
--- a/package.json
+++ b/package.json
@@ -16,7 +16,7 @@
"dev:workers": "npx nx run workers:serve:development",
"dev:cron": "npx nx run cron:serve:development",
"dev:docker": "docker compose -f ./docker-compose.dev.yaml up -d",
- "start": "npm run start:prod",
+ "start": "npm run dev && npm run dev:docker",
"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 aa8af7ccc46f82a11d4dc74b6ca731e52769e865 Mon Sep 17 00:00:00 2001
From: Rohit Dash
Date: Sun, 27 Oct 2024 13:41:57 +0530
Subject: [PATCH 13/23] modified the scripts for railway
---
.railway/template.yaml | 9 +++++----
package.json | 7 +++++--
2 files changed, 10 insertions(+), 6 deletions(-)
diff --git a/.railway/template.yaml b/.railway/template.yaml
index cd6fac30..1e4a1065 100644
--- a/.railway/template.yaml
+++ b/.railway/template.yaml
@@ -9,7 +9,9 @@ service:
- 5000:5000
env:
- key: NODE_ENV
- value: production
+ value: development
+ - key: NEXT_PUBLIC_API_URL
+ value: /api
- key: DATABASE_URL
fromService:
type: postgres
@@ -47,6 +49,5 @@ volumes:
persistent: true
scripts:
- postDeploy: |
- npm run prisma-generate
- npm run prisma-db-push
+ postDeploy: npm run railway:setup
+ start: npm run railway:start
diff --git a/package.json b/package.json
index 42be756c..50f2c71f 100644
--- a/package.json
+++ b/package.json
@@ -16,7 +16,6 @@
"dev:workers": "npx nx run workers:serve:development",
"dev:cron": "npx nx run cron:serve:development",
"dev:docker": "docker compose -f ./docker-compose.dev.yaml up -d",
- "start": "npm run dev && npm run dev:docker",
"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",
@@ -29,7 +28,11 @@
"prisma-reset": "cd ./libraries/nestjs-libraries/src/database/prisma && npx prisma db push --force-reset && npx prisma db push",
"docker-build": "./var/docker/docker-build.sh",
"docker-create": "./var/docker/docker-create.sh",
- "postinstall": "npm run update-plugins && npm run prisma-generate"
+ "railway:start": "npm run build && npm run start:prod",
+ "railway:dev": "npm run dev",
+ "railway:setup": "npm install && npm run prisma-generate && npm run prisma-db-push",
+ "postinstall": "npm run update-plugins && npm run prisma-generate",
+ "start": "npm run railway:start"
},
"private": true,
"dependencies": {
From 595f666645cb2160aee14bb81813e90231a179ff Mon Sep 17 00:00:00 2001
From: Rohit Dash
Date: Sun, 27 Oct 2024 13:49:30 +0530
Subject: [PATCH 14/23] fixing error for postgres and redis
---
package.json | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/package.json b/package.json
index 50f2c71f..d82bbe3d 100644
--- a/package.json
+++ b/package.json
@@ -29,7 +29,7 @@
"docker-build": "./var/docker/docker-build.sh",
"docker-create": "./var/docker/docker-create.sh",
"railway:start": "npm run build && npm run start:prod",
- "railway:dev": "npm run dev",
+ "railway:dev": "npm run dev && docker compose -f ./docker-compose.dev.yaml up -d",
"railway:setup": "npm install && npm run prisma-generate && npm run prisma-db-push",
"postinstall": "npm run update-plugins && npm run prisma-generate",
"start": "npm run railway:start"
From 108393d49be42febdd085ff6bc94ee0607369e22 Mon Sep 17 00:00:00 2001
From: Rohit Dash
Date: Sun, 27 Oct 2024 13:56:13 +0530
Subject: [PATCH 15/23] fix build error
---
.railway/template.yaml | 52 +++++++++++++++++++++++++-----------------
package.json | 5 ++--
railway.toml | 9 ++++++++
3 files changed, 42 insertions(+), 24 deletions(-)
create mode 100644 railway.toml
diff --git a/.railway/template.yaml b/.railway/template.yaml
index 1e4a1065..ad13c160 100644
--- a/.railway/template.yaml
+++ b/.railway/template.yaml
@@ -1,4 +1,4 @@
-service:
+services:
web:
dockerfile: ../Dockerfile.dev
target: dist
@@ -13,41 +13,51 @@ service:
- key: NEXT_PUBLIC_API_URL
value: /api
- key: DATABASE_URL
- fromService:
- type: postgres
- property: connectionString
+ value: postgresql://postiz-local:postiz-local-pwd@localhost:5432/postiz-db-local
- key: REDIS_URL
- fromService:
- type: redis
- property: connectionString
+ value: redis://localhost:6379
- key: JWT_SECRET
generate: secret
+ - key: SKIP_CONFIG_CHECK
+ value: "true"
volumes:
- name: uploads
path: /uploads
- name: config
path: /config
-databases:
- - type: postgres
- name: postiz-db
- version: '17'
- ipAllowList: []
-
services:
- - type: redis
- name: postiz-redis
- version: '7'
- ipAllowList: []
+ postgres:
+ container_name: postiz-postgres
+ image: postgres:17-alpine
+ environment:
+ POSTGRES_PASSWORD: postiz-local-pwd
+ POSTGRES_USER: postiz-local
+ POSTGRES_DB: postiz-db-local
+ ports:
+ - 5432:5432
+ volumes:
+ - postgres-data:/var/lib/postgresql/data
+
+ redis:
+ container_name: postiz-redis
+ image: redis:7-alpine
+ ports:
+ - 6379:6379
volumes:
- - name: uploads
+ postgres-data:
+ uploads:
mountPath: /uploads
persistent: true
- - name: config
+ config:
mountPath: /config
persistent: true
scripts:
- postDeploy: npm run railway:setup
- start: npm run railway:start
+ predeploy: |
+ npm install
+ npm run prisma-generate
+ postDeploy: |
+ npm run prisma-db-push
+ start: npm run railway:dev
\ No newline at end of file
diff --git a/package.json b/package.json
index d82bbe3d..8837166f 100644
--- a/package.json
+++ b/package.json
@@ -28,11 +28,10 @@
"prisma-reset": "cd ./libraries/nestjs-libraries/src/database/prisma && npx prisma db push --force-reset && npx prisma db push",
"docker-build": "./var/docker/docker-build.sh",
"docker-create": "./var/docker/docker-create.sh",
- "railway:start": "npm run build && npm run start:prod",
- "railway:dev": "npm run dev && docker compose -f ./docker-compose.dev.yaml up -d",
+ "railway:dev": "npm run build && npm run start:prod",
"railway:setup": "npm install && npm run prisma-generate && npm run prisma-db-push",
"postinstall": "npm run update-plugins && npm run prisma-generate",
- "start": "npm run railway:start"
+ "start": "npm run railway:dev"
},
"private": true,
"dependencies": {
diff --git a/railway.toml b/railway.toml
new file mode 100644
index 00000000..ef7ad320
--- /dev/null
+++ b/railway.toml
@@ -0,0 +1,9 @@
+[build]
+builder = "nixpacks"
+buildCommand = "npm install"
+
+[deploy]
+startCommand = "npm run railway:dev"
+
+[service]
+internalPort = 3000
\ No newline at end of file
From 5c8af24c580538eb78551d83137d614a82175b86 Mon Sep 17 00:00:00 2001
From: Rohit Dash
Date: Sun, 27 Oct 2024 14:58:29 +0530
Subject: [PATCH 16/23] fixed build errors
---
.railway/template.yaml | 169 ++++++++++++++++++++++++++++++++++++-----
package.json | 5 +-
railway.toml | 9 ---
3 files changed, 153 insertions(+), 30 deletions(-)
delete mode 100644 railway.toml
diff --git a/.railway/template.yaml b/.railway/template.yaml
index ad13c160..c228561b 100644
--- a/.railway/template.yaml
+++ b/.railway/template.yaml
@@ -3,19 +3,30 @@ services:
dockerfile: ../Dockerfile.dev
target: dist
numReplicas: 1
+ depends_on:
+ - postgres
+ - redis
ports:
- 3000:3000
- 4200:4200
- 5000:5000
env:
- key: NODE_ENV
- value: development
+ value: production
- key: NEXT_PUBLIC_API_URL
value: /api
- key: DATABASE_URL
- value: postgresql://postiz-local:postiz-local-pwd@localhost:5432/postiz-db-local
+ fromService:
+ name: postgres
+ type: postgresql
+ property: connectionString
+ format: postgresql://${username}:${password}@${host}:${port}/${database}
- key: REDIS_URL
- value: redis://localhost:6379
+ fromService:
+ name: redis
+ type: redis
+ property: connectionString
+ format: redis://${host}:${port}
- key: JWT_SECRET
generate: secret
- key: SKIP_CONFIG_CHECK
@@ -26,27 +37,38 @@ services:
- name: config
path: /config
-services:
postgres:
- container_name: postiz-postgres
image: postgres:17-alpine
- environment:
- POSTGRES_PASSWORD: postiz-local-pwd
- POSTGRES_USER: postiz-local
- POSTGRES_DB: postiz-db-local
- ports:
- - 5432:5432
+ provision: true
+ env:
+ - key: POSTGRES_USER
+ value: postiz
+ - key: POSTGRES_PASSWORD
+ generate: password
+ - key: POSTGRES_DB
+ value: postiz
volumes:
- - postgres-data:/var/lib/postgresql/data
+ - name: postgres-data
+ path: /var/lib/postgresql/data
+ persistent: true
+ healthcheck:
+ command: pg_isready -U postiz
+ interval: 5s
+ timeout: 5s
+ retries: 5
redis:
- container_name: postiz-redis
image: redis:7-alpine
- ports:
- - 6379:6379
+ provision: true
+ healthcheck:
+ command: redis-cli ping
+ interval: 5s
+ timeout: 5s
+ retries: 5
volumes:
postgres-data:
+ persistent: true
uploads:
mountPath: /uploads
persistent: true
@@ -56,8 +78,121 @@ volumes:
scripts:
predeploy: |
- npm install
+ # Install dependencies and generate Prisma client
+ npm ci --production=false
+ npm run update-plugins
npm run prisma-generate
+
+ # Create service checker script
+ cat > check-services.js << 'EOF'
+ const net = require('net');
+ const { Client } = require('pg');
+ const Redis = require('ioredis');
+
+ async function waitForPort(host, port, timeout = 60000) {
+ const startTime = Date.now();
+
+ while (Date.now() - startTime < timeout) {
+ try {
+ const socket = new net.Socket();
+
+ const connected = await new Promise((resolve) => {
+ socket.connect(port, host, () => resolve(true));
+ socket.on('error', () => resolve(false));
+ });
+
+ socket.end();
+
+ if (connected) return true;
+ } catch (err) {
+ console.log(`Waiting for ${host}:${port}...`);
+ }
+
+ await new Promise(resolve => setTimeout(resolve, 1000));
+ }
+
+ throw new Error(`Timeout waiting for ${host}:${port}`);
+ }
+
+ async function checkPostgres() {
+ const client = new Client({
+ connectionString: process.env.DATABASE_URL
+ });
+
+ try {
+ await client.connect();
+ console.log('PostgreSQL is ready');
+ await client.end();
+ return true;
+ } catch (err) {
+ console.log('Waiting for PostgreSQL...');
+ return false;
+ }
+ }
+
+ async function checkRedis() {
+ const redis = new Redis(process.env.REDIS_URL);
+
+ try {
+ await redis.ping();
+ console.log('Redis is ready');
+ await redis.quit();
+ return true;
+ } catch (err) {
+ console.log('Waiting for Redis...');
+ return false;
+ }
+ }
+
+ async function main() {
+ const pgHost = process.env.POSTGRES_HOST;
+ const pgPort = process.env.POSTGRES_PORT || 5432;
+ const redisHost = process.env.REDIS_HOST;
+ const redisPort = process.env.REDIS_PORT || 6379;
+
+ try {
+ // First check if ports are accessible
+ await waitForPort(pgHost, pgPort);
+ await waitForPort(redisHost, redisPort);
+
+ // Then check if services are ready
+ let pgReady = false;
+ let redisReady = false;
+
+ while (!pgReady || !redisReady) {
+ if (!pgReady) pgReady = await checkPostgres();
+ if (!redisReady) redisReady = await checkRedis();
+ if (!pgReady || !redisReady) {
+ await new Promise(resolve => setTimeout(resolve, 1000));
+ }
+ }
+
+ console.log('All services are ready!');
+ process.exit(0);
+ } catch (err) {
+ console.error('Service check failed:', err);
+ process.exit(1);
+ }
+ }
+
+ main();
+ EOF
+
+ # Build the application
+ npm run build
+
+ prestart: |
+ echo "Checking service availability..."
+ node check-services.js
+
postDeploy: |
+ # Ensure database is migrated
npm run prisma-db-push
- start: npm run railway:dev
\ No newline at end of file
+
+ start: |
+ # Start the application components
+ npm run start:prod &
+ npm run start:prod:workers &
+ npm run start:prod:frontend &
+ npm run start:prod:cron &
+ wait
\ No newline at end of file
diff --git a/package.json b/package.json
index 8837166f..8b356af5 100644
--- a/package.json
+++ b/package.json
@@ -28,10 +28,7 @@
"prisma-reset": "cd ./libraries/nestjs-libraries/src/database/prisma && npx prisma db push --force-reset && npx prisma db push",
"docker-build": "./var/docker/docker-build.sh",
"docker-create": "./var/docker/docker-create.sh",
- "railway:dev": "npm run build && npm run start:prod",
- "railway:setup": "npm install && npm run prisma-generate && npm run prisma-db-push",
- "postinstall": "npm run update-plugins && npm run prisma-generate",
- "start": "npm run railway:dev"
+ "postinstall": "npm run update-plugins && npm run prisma-generate"
},
"private": true,
"dependencies": {
diff --git a/railway.toml b/railway.toml
deleted file mode 100644
index ef7ad320..00000000
--- a/railway.toml
+++ /dev/null
@@ -1,9 +0,0 @@
-[build]
-builder = "nixpacks"
-buildCommand = "npm install"
-
-[deploy]
-startCommand = "npm run railway:dev"
-
-[service]
-internalPort = 3000
\ No newline at end of file
From f1c8b93981898e6c54677689c6537f9238236ae7 Mon Sep 17 00:00:00 2001
From: Rohit Dash
Date: Sun, 27 Oct 2024 15:01:17 +0530
Subject: [PATCH 17/23] fixed build logs error
---
package.json | 1 +
1 file changed, 1 insertion(+)
diff --git a/package.json b/package.json
index 8b356af5..07f73c72 100644
--- a/package.json
+++ b/package.json
@@ -16,6 +16,7 @@
"dev:workers": "npx nx run workers:serve:development",
"dev:cron": "npx nx run cron:serve:development",
"dev:docker": "docker compose -f ./docker-compose.dev.yaml up -d",
+ "start": "npm run start:prod",
"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 3fc5bb73360b894652b18036868a139ca2047766 Mon Sep 17 00:00:00 2001
From: Rohit Dash
Date: Sun, 27 Oct 2024 15:19:57 +0530
Subject: [PATCH 18/23] fix build errors
---
.railway/template.yaml | 117 ++---------------------------------------
package.json | 1 +
2 files changed, 5 insertions(+), 113 deletions(-)
diff --git a/.railway/template.yaml b/.railway/template.yaml
index c228561b..be02e857 100644
--- a/.railway/template.yaml
+++ b/.railway/template.yaml
@@ -17,16 +17,12 @@ services:
value: /api
- key: DATABASE_URL
fromService:
- name: postgres
- type: postgresql
+ type: postgres
property: connectionString
- format: postgresql://${username}:${password}@${host}:${port}/${database}
- key: REDIS_URL
fromService:
- name: redis
type: redis
property: connectionString
- format: redis://${host}:${port}
- key: JWT_SECRET
generate: secret
- key: SKIP_CONFIG_CHECK
@@ -78,121 +74,16 @@ volumes:
scripts:
predeploy: |
- # Install dependencies and generate Prisma client
npm ci --production=false
npm run update-plugins
npm run prisma-generate
- # Create service checker script
- cat > check-services.js << 'EOF'
- const net = require('net');
- const { Client } = require('pg');
- const Redis = require('ioredis');
-
- async function waitForPort(host, port, timeout = 60000) {
- const startTime = Date.now();
-
- while (Date.now() - startTime < timeout) {
- try {
- const socket = new net.Socket();
-
- const connected = await new Promise((resolve) => {
- socket.connect(port, host, () => resolve(true));
- socket.on('error', () => resolve(false));
- });
-
- socket.end();
-
- if (connected) return true;
- } catch (err) {
- console.log(`Waiting for ${host}:${port}...`);
- }
-
- await new Promise(resolve => setTimeout(resolve, 1000));
- }
-
- throw new Error(`Timeout waiting for ${host}:${port}`);
- }
-
- async function checkPostgres() {
- const client = new Client({
- connectionString: process.env.DATABASE_URL
- });
-
- try {
- await client.connect();
- console.log('PostgreSQL is ready');
- await client.end();
- return true;
- } catch (err) {
- console.log('Waiting for PostgreSQL...');
- return false;
- }
- }
-
- async function checkRedis() {
- const redis = new Redis(process.env.REDIS_URL);
-
- try {
- await redis.ping();
- console.log('Redis is ready');
- await redis.quit();
- return true;
- } catch (err) {
- console.log('Waiting for Redis...');
- return false;
- }
- }
-
- async function main() {
- const pgHost = process.env.POSTGRES_HOST;
- const pgPort = process.env.POSTGRES_PORT || 5432;
- const redisHost = process.env.REDIS_HOST;
- const redisPort = process.env.REDIS_PORT || 6379;
-
- try {
- // First check if ports are accessible
- await waitForPort(pgHost, pgPort);
- await waitForPort(redisHost, redisPort);
-
- // Then check if services are ready
- let pgReady = false;
- let redisReady = false;
-
- while (!pgReady || !redisReady) {
- if (!pgReady) pgReady = await checkPostgres();
- if (!redisReady) redisReady = await checkRedis();
- if (!pgReady || !redisReady) {
- await new Promise(resolve => setTimeout(resolve, 1000));
- }
- }
-
- console.log('All services are ready!');
- process.exit(0);
- } catch (err) {
- console.error('Service check failed:', err);
- process.exit(1);
- }
- }
-
- main();
- EOF
-
- # Build the application
- npm run build
-
prestart: |
echo "Checking service availability..."
node check-services.js
- postDeploy: |
- # Ensure database is migrated
+ postdeploy: |
npm run prisma-db-push
- start: |
- # Start the application components
- npm run start:prod &
- npm run start:prod:workers &
- npm run start:prod:frontend &
- npm run start:prod:cron &
- wait
\ No newline at end of file
+ railway:start: |
+ npm run railway:start
\ No newline at end of file
diff --git a/package.json b/package.json
index 07f73c72..a3c818c8 100644
--- a/package.json
+++ b/package.json
@@ -21,6 +21,7 @@
"start:prod:frontend": "nx run frontend:serve:production",
"start:prod:workers": "node dist/apps/workers/main.js",
"start:prod:cron": "node dist/apps/cron/main.js",
+ "railway:start": "npm run start:prod & npm run start:prod:workers & npm run start:prod:frontend & npm run start:prod:cron & wait",
"workers": "npx nx run workers:serve:development",
"cron": "npx nx run cron:serve:development",
"command": "rm -rf dist/apps/commands && npx nx run commands:build && npx nx run commands:command",
From 2a14f4e9231fac0c6ebde0b697da8460d61827e7 Mon Sep 17 00:00:00 2001
From: Rohit Dash
Date: Sun, 27 Oct 2024 16:06:05 +0530
Subject: [PATCH 19/23] fixed build errors
---
.railway/template.yaml | 8 +-------
package.json | 3 ++-
2 files changed, 3 insertions(+), 8 deletions(-)
diff --git a/.railway/template.yaml b/.railway/template.yaml
index be02e857..c17dfbc3 100644
--- a/.railway/template.yaml
+++ b/.railway/template.yaml
@@ -77,13 +77,7 @@ scripts:
npm ci --production=false
npm run update-plugins
npm run prisma-generate
-
- prestart: |
- echo "Checking service availability..."
- node check-services.js
-
- postdeploy: |
npm run prisma-db-push
railway:start: |
- npm run railway:start
\ No newline at end of file
+ npm run railway:deploy
\ No newline at end of file
diff --git a/package.json b/package.json
index a3c818c8..231b2237 100644
--- a/package.json
+++ b/package.json
@@ -21,7 +21,8 @@
"start:prod:frontend": "nx run frontend:serve:production",
"start:prod:workers": "node dist/apps/workers/main.js",
"start:prod:cron": "node dist/apps/cron/main.js",
- "railway:start": "npm run start:prod & npm run start:prod:workers & npm run start:prod:frontend & npm run start:prod:cron & wait",
+ "railway:start": "npm run start:prod && npm run start:prod:workers && npm run start:prod:frontend && npm run start:prod:cron && wait",
+ "railway:deploy": "npm run predeploy && npm run railway:start",
"workers": "npx nx run workers:serve:development",
"cron": "npx nx run cron:serve:development",
"command": "rm -rf dist/apps/commands && npx nx run commands:build && npx nx run commands:command",
From be3a63363dae60fa73ec4d14b11c2e4ea654b1d9 Mon Sep 17 00:00:00 2001
From: Rohit Dash
Date: Wed, 30 Oct 2024 02:01:41 +0530
Subject: [PATCH 20/23] 1-click deployment
---
.railway/template.yaml | 166 ++++++++++++++++++++---------------------
README.md | 3 +
2 files changed, 86 insertions(+), 83 deletions(-)
diff --git a/.railway/template.yaml b/.railway/template.yaml
index c17dfbc3..0313bc0f 100644
--- a/.railway/template.yaml
+++ b/.railway/template.yaml
@@ -1,83 +1,83 @@
-services:
- web:
- dockerfile: ../Dockerfile.dev
- target: dist
- numReplicas: 1
- depends_on:
- - postgres
- - redis
- ports:
- - 3000:3000
- - 4200:4200
- - 5000:5000
- env:
- - key: NODE_ENV
- value: production
- - key: NEXT_PUBLIC_API_URL
- value: /api
- - key: DATABASE_URL
- fromService:
- type: postgres
- property: connectionString
- - key: REDIS_URL
- fromService:
- type: redis
- property: connectionString
- - key: JWT_SECRET
- generate: secret
- - key: SKIP_CONFIG_CHECK
- value: "true"
- volumes:
- - name: uploads
- path: /uploads
- - name: config
- path: /config
-
- postgres:
- image: postgres:17-alpine
- provision: true
- env:
- - key: POSTGRES_USER
- value: postiz
- - key: POSTGRES_PASSWORD
- generate: password
- - key: POSTGRES_DB
- value: postiz
- volumes:
- - name: postgres-data
- path: /var/lib/postgresql/data
- persistent: true
- healthcheck:
- command: pg_isready -U postiz
- interval: 5s
- timeout: 5s
- retries: 5
-
- redis:
- image: redis:7-alpine
- provision: true
- healthcheck:
- command: redis-cli ping
- interval: 5s
- timeout: 5s
- retries: 5
-
-volumes:
- postgres-data:
- persistent: true
- uploads:
- mountPath: /uploads
- persistent: true
- config:
- mountPath: /config
- persistent: true
-
-scripts:
- predeploy: |
- npm ci --production=false
- npm run update-plugins
- npm run prisma-generate
- npm run prisma-db-push
-
- railway:start: |
- npm run railway:deploy
\ No newline at end of file
+services:
+ web:
+ dockerfile: ../Dockerfile.dev
+ target: dist
+ numReplicas: 1
+ depends_on:
+ - postgres
+ - redis
+ ports:
+ - 3000:3000
+ - 4200:4200
+ - 5000:5000
+ env:
+ - key: NODE_ENV
+ value: production
+ - key: NEXT_PUBLIC_API_URL
+ value: /api
+ - key: DATABASE_URL
+ fromService:
+ type: postgres
+ property: connectionString
+ - key: REDIS_URL
+ fromService:
+ type: redis
+ property: connectionString
+ - key: JWT_SECRET
+ generate: secret
+ - key: SKIP_CONFIG_CHECK
+ value: "true"
+ volumes:
+ - name: uploads
+ path: /uploads
+ - name: config
+ path: /config
+
+ postgres:
+ image: postgres:17-alpine
+ provision: true
+ env:
+ - key: POSTGRES_USER
+ value: postiz
+ - key: POSTGRES_PASSWORD
+ generate: password
+ - key: POSTGRES_DB
+ value: postiz
+ volumes:
+ - name: postgres-data
+ path: /var/lib/postgresql/data
+ persistent: true
+ healthcheck:
+ command: pg_isready -U postiz
+ interval: 5s
+ timeout: 5s
+ retries: 5
+
+ redis:
+ image: redis:7-alpine
+ provision: true
+ healthcheck:
+ command: redis-cli ping
+ interval: 5s
+ timeout: 5s
+ retries: 5
+
+volumes:
+ postgres-data:
+ persistent: true
+ uploads:
+ mountPath: /uploads
+ persistent: true
+ config:
+ mountPath: /config
+ persistent: true
+
+scripts:
+ predeploy: |
+ npm ci --production=false
+ npm run update-plugins
+ npm run prisma-generate
+ npm run prisma-db-push
+
+ railway:start: |
+ npm run railway:deploy
\ No newline at end of file
diff --git a/README.md b/README.md
index 37a882c3..42f30859 100644
--- a/README.md
+++ b/README.md
@@ -12,6 +12,9 @@
+
+
+
From 24285cc61b192904f375ecf1ad45e8dbbaf4cf4d Mon Sep 17 00:00:00 2001
From: Rohit Dash
Date: Wed, 30 Oct 2024 02:05:39 +0530
Subject: [PATCH 21/23] fix build errors
---
.railway/template.yaml | 55 ++++++++++++++++++------------------------
README.md | 2 +-
2 files changed, 25 insertions(+), 32 deletions(-)
diff --git a/.railway/template.yaml b/.railway/template.yaml
index 0313bc0f..3e139c2d 100644
--- a/.railway/template.yaml
+++ b/.railway/template.yaml
@@ -1,14 +1,9 @@
services:
web:
- dockerfile: ../Dockerfile.dev
+ dockerfile: Dockerfile.dev
target: dist
numReplicas: 1
- depends_on:
- - postgres
- - redis
ports:
- - 3000:3000
- - 4200:4200
- 5000:5000
env:
- key: NODE_ENV
@@ -17,25 +12,38 @@ services:
value: /api
- key: DATABASE_URL
fromService:
+ name: postgres
type: postgres
property: connectionString
- key: REDIS_URL
fromService:
+ name: redis
type: redis
property: connectionString
- key: JWT_SECRET
generate: secret
- key: SKIP_CONFIG_CHECK
value: "true"
+ - key: FRONTEND_URL
+ sync: RAILWAY_PUBLIC_DOMAIN
+ prefix: https://
+ - key: MAIN_URL
+ sync: RAILWAY_PUBLIC_DOMAIN
+ prefix: https://
+ - key: STORAGE_PROVIDER
+ value: local
+ - key: UPLOAD_DIRECTORY
+ value: /uploads
volumes:
- name: uploads
- path: /uploads
+ mountPath: /uploads
+ persistent: true
- name: config
- path: /config
+ mountPath: /config
+ persistent: true
postgres:
image: postgres:17-alpine
- provision: true
env:
- key: POSTGRES_USER
value: postiz
@@ -45,39 +53,24 @@ services:
value: postiz
volumes:
- name: postgres-data
- path: /var/lib/postgresql/data
+ mountPath: /var/lib/postgresql/data
persistent: true
- healthcheck:
- command: pg_isready -U postiz
- interval: 5s
- timeout: 5s
- retries: 5
redis:
image: redis:7-alpine
- provision: true
- healthcheck:
- command: redis-cli ping
- interval: 5s
- timeout: 5s
- retries: 5
volumes:
postgres-data:
+ name: postgres-data
persistent: true
uploads:
- mountPath: /uploads
+ name: uploads
persistent: true
config:
- mountPath: /config
+ name: config
persistent: true
scripts:
- predeploy: |
- npm ci --production=false
- npm run update-plugins
- npm run prisma-generate
- npm run prisma-db-push
-
- railway:start: |
- npm run railway:deploy
\ No newline at end of file
+ postdeploy: |
+ npx prisma generate
+ npx prisma db push --accept-data-loss
\ No newline at end of file
diff --git a/README.md b/README.md
index 42f30859..22ae9bea 100644
--- a/README.md
+++ b/README.md
@@ -12,7 +12,7 @@
-
+
From fdac9c05c073d107c0c24778bbf5573159c422f8 Mon Sep 17 00:00:00 2001
From: Rohit Dash
Date: Wed, 30 Oct 2024 02:22:48 +0530
Subject: [PATCH 22/23] fixes error
---
.railway/template.yaml | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/.railway/template.yaml b/.railway/template.yaml
index 3e139c2d..38efbf30 100644
--- a/.railway/template.yaml
+++ b/.railway/template.yaml
@@ -4,12 +4,16 @@ services:
target: dist
numReplicas: 1
ports:
+ - 3000:3000
+ - 4200:4200
- 5000:5000
env:
- key: NODE_ENV
- value: production
- - key: NEXT_PUBLIC_API_URL
- value: /api
+ value: development
+ - key: PORT
+ value: 3000
+ - key: FRONTEND_PORT
+ value: 4200
- key: DATABASE_URL
fromService:
name: postgres
@@ -34,6 +38,8 @@ services:
value: local
- key: UPLOAD_DIRECTORY
value: /uploads
+ - key: NEXT_PUBLIC_API_URL
+ value: /api
volumes:
- name: uploads
mountPath: /uploads
From 4e2574c4544164b4c1e6ca5274b79eaef0838a62 Mon Sep 17 00:00:00 2001
From: Rohit Dash
Date: Wed, 30 Oct 2024 02:30:40 +0530
Subject: [PATCH 23/23] checking some issue
---
package.json | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/package.json b/package.json
index 231b2237..c98a6789 100644
--- a/package.json
+++ b/package.json
@@ -16,13 +16,11 @@
"dev:workers": "npx nx run workers:serve:development",
"dev:cron": "npx nx run cron:serve:development",
"dev:docker": "docker compose -f ./docker-compose.dev.yaml up -d",
- "start": "npm run start:prod",
+ "start": "npm run dev",
"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",
"start:prod:cron": "node dist/apps/cron/main.js",
- "railway:start": "npm run start:prod && npm run start:prod:workers && npm run start:prod:frontend && npm run start:prod:cron && wait",
- "railway:deploy": "npm run predeploy && npm run railway:start",
"workers": "npx nx run workers:serve:development",
"cron": "npx nx run cron:serve:development",
"command": "rm -rf dist/apps/commands && npx nx run commands:build && npx nx run commands:command",