Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add heroku 1-click deployment files #383

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions .github/workflows/build-containers-enterprise.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
name: "Build Containers Enterprise"
name: 'Build Containers Enterprise'

on:
workflow_dispatch:
Expand All @@ -20,7 +20,7 @@ jobs:

build-containers:
needs: build-containers-common
strategy:
strategy:
matrix:
include:
- runnertags: ubuntu-latest
Expand Down Expand Up @@ -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 }}
Expand All @@ -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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please don't change the enterprise container workflows.


build-container-manifest:
needs: [build-containers, build-containers-common]
runs-on: ubuntu-latest
Expand All @@ -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 \
Expand Down
46 changes: 46 additions & 0 deletions .heroku/app.json
Original file line number Diff line number Diff line change
@@ -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": {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is this?

"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": {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where is this used?

"description": "Application URL (will be auto-filled)",
"required": true
}
},
"addons": [
{
"plan": "heroku-postgresql:hobby-dev",
"as": "DATABASE"
},
{
"plan": "heroku-redis:hobby-dev",
"as": "REDIS"
}
]
}
15 changes: 15 additions & 0 deletions .heroku/heroku.yml
Original file line number Diff line number Diff line change
@@ -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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You shouldn't use the enterprise containers.

config:
NODE_ENV: production

run:
web: /app/entrypoint.sh
30 changes: 28 additions & 2 deletions var/docker/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,33 @@

set -o xtrace

export DATABSAE_URL=${DATABASE_URL:-$HEROKU_POSTGRESQL_DATABASE_URL}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Waiting for the database should be handled on the platform level.

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/
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removing these lines will break the existing docker containers.

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/
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same with this line.

cp -vf /config/postiz.env /app/.env
fi

Expand All @@ -17,6 +37,12 @@ if [[ "$POSTIZ_APPS" -eq "" ]]; then
POSTIZ_APPS="frontend workers cron backend"
fi

if [[$POSTIZ_APPS == *"workers"* ]]; then
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These lines just look wrong.

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

Expand Down