0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-02-17 23:44:39 -05:00

Added support for portal & other apps in containerized Ghost (#22121)

no issue

- The `yarn dev` command accepts dash-dash-args to conditionally build &
run other apps, like portal, comments, etc.
- Passing these flags to the docker compose setup directly doesn't work,
so the only way to run these apps in docker was to either change the
command in the Dockerfile or override the command in the `compose.yml`
file
- This commit extends `yarn dev` to also check for the
`GHOST_DEV_APP_FLAGS` environment variable for these flags, which can be
forwarded into the container and make it easier to run these apps using
docker compose.
This commit is contained in:
Chris Raible 2025-02-05 18:18:58 -08:00 committed by GitHub
parent 5631e804b6
commit 049dba469f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 39 additions and 22 deletions

View file

@ -34,7 +34,10 @@ const tsPackages = fs.readdirSync(path.resolve(__dirname, '../../ghost'), {withF
const liveReloadBaseUrl = config.getSubdir() || '/ghost/';
const siteUrl = config.getSiteUrl();
// Pass flags using GHOST_DEV_APP_FLAGS env var or --flag
const DASH_DASH_ARGS = process.argv.filter(a => a.startsWith('--')).map(a => a.slice(2));
const ENV_ARGS = process.env.GHOST_DEV_APP_FLAGS?.split(',') || [];
const GHOST_APP_FLAGS = [...ENV_ARGS, ...DASH_DASH_ARGS];
let commands = [];
@ -90,17 +93,17 @@ const COMMANDS_ADMINX = [{
env: {}
}];
if (DASH_DASH_ARGS.includes('ghost')) {
if (GHOST_APP_FLAGS.includes('ghost')) {
commands = [COMMAND_GHOST, COMMAND_TYPESCRIPT];
} else if (DASH_DASH_ARGS.includes('admin')) {
} else if (GHOST_APP_FLAGS.includes('admin')) {
commands = [COMMAND_ADMIN, ...COMMANDS_ADMINX];
} else if (DASH_DASH_ARGS.includes('browser-tests')) {
} else if (GHOST_APP_FLAGS.includes('browser-tests')) {
commands = [COMMAND_BROWSERTESTS];
} else {
commands = [COMMAND_GHOST, COMMAND_TYPESCRIPT, COMMAND_ADMIN, ...COMMANDS_ADMINX];
}
if (DASH_DASH_ARGS.includes('portal') || DASH_DASH_ARGS.includes('all')) {
if (GHOST_APP_FLAGS.includes('portal') || GHOST_APP_FLAGS.includes('all')) {
commands.push({
name: 'portal',
command: 'nx run @tryghost/portal:dev',
@ -109,7 +112,7 @@ if (DASH_DASH_ARGS.includes('portal') || DASH_DASH_ARGS.includes('all')) {
env: {}
});
if (DASH_DASH_ARGS.includes('https')) {
if (GHOST_APP_FLAGS.includes('https')) {
// Safari needs HTTPS for it to work
// To make this work, you'll need a CADDY server running in front
// Note the port is different because of this extra layer. Use the following Caddyfile:
@ -123,10 +126,10 @@ if (DASH_DASH_ARGS.includes('portal') || DASH_DASH_ARGS.includes('all')) {
}
}
if (DASH_DASH_ARGS.includes('signup') || DASH_DASH_ARGS.includes('all')) {
if (GHOST_APP_FLAGS.includes('signup') || GHOST_APP_FLAGS.includes('all')) {
commands.push({
name: 'signup-form',
command: DASH_DASH_ARGS.includes('signup') ? 'nx run @tryghost/signup-form:dev' : 'nx run @tryghost/signup-form:preview',
command: GHOST_APP_FLAGS.includes('signup') ? 'nx run @tryghost/signup-form:dev' : 'nx run @tryghost/signup-form:preview',
cwd: path.resolve(__dirname, '../../apps/signup-form'),
prefixColor: 'magenta',
env: {}
@ -134,7 +137,7 @@ if (DASH_DASH_ARGS.includes('signup') || DASH_DASH_ARGS.includes('all')) {
COMMAND_GHOST.env['signupForm__url'] = 'http://localhost:6174/signup-form.min.js';
}
if (DASH_DASH_ARGS.includes('announcement-bar') || DASH_DASH_ARGS.includes('announcementBar') || DASH_DASH_ARGS.includes('announcementbar') || DASH_DASH_ARGS.includes('all')) {
if (GHOST_APP_FLAGS.includes('announcement-bar') || GHOST_APP_FLAGS.includes('announcementBar') || GHOST_APP_FLAGS.includes('announcementbar') || GHOST_APP_FLAGS.includes('all')) {
commands.push({
name: 'announcement-bar',
command: 'nx run @tryghost/announcement-bar:dev',
@ -145,7 +148,7 @@ if (DASH_DASH_ARGS.includes('announcement-bar') || DASH_DASH_ARGS.includes('anno
COMMAND_GHOST.env['announcementBar__url'] = 'http://localhost:4177/announcement-bar.min.js';
}
if (DASH_DASH_ARGS.includes('search') || DASH_DASH_ARGS.includes('all')) {
if (GHOST_APP_FLAGS.includes('search') || GHOST_APP_FLAGS.includes('all')) {
commands.push({
name: 'search',
command: 'nx run @tryghost/sodo-search:dev',
@ -157,8 +160,8 @@ if (DASH_DASH_ARGS.includes('search') || DASH_DASH_ARGS.includes('all')) {
COMMAND_GHOST.env['sodoSearch__styles'] = 'http://localhost:4178/main.css';
}
if (DASH_DASH_ARGS.includes('lexical')) {
if (DASH_DASH_ARGS.includes('https')) {
if (GHOST_APP_FLAGS.includes('lexical')) {
if (GHOST_APP_FLAGS.includes('https')) {
// Safari needs HTTPS for it to work
// To make this work, you'll need a CADDY server running in front
// Note the port is different because of this extra layer. Use the following Caddyfile:
@ -172,8 +175,8 @@ if (DASH_DASH_ARGS.includes('lexical')) {
}
}
if (DASH_DASH_ARGS.includes('comments') || DASH_DASH_ARGS.includes('all')) {
if (DASH_DASH_ARGS.includes('https')) {
if (GHOST_APP_FLAGS.includes('comments') || GHOST_APP_FLAGS.includes('all')) {
if (GHOST_APP_FLAGS.includes('https')) {
// Safari needs HTTPS for it to work
// To make this work, you'll need a CADDY server running in front
// Note the port is different because of this extra layer. Use the following Caddyfile:
@ -195,8 +198,8 @@ if (DASH_DASH_ARGS.includes('comments') || DASH_DASH_ARGS.includes('all')) {
}
async function handleStripe() {
if (DASH_DASH_ARGS.includes('stripe') || DASH_DASH_ARGS.includes('all')) {
if (DASH_DASH_ARGS.includes('offline') || DASH_DASH_ARGS.includes('browser-tests')) {
if (GHOST_APP_FLAGS.includes('stripe') || GHOST_APP_FLAGS.includes('all')) {
if (GHOST_APP_FLAGS.includes('offline') || GHOST_APP_FLAGS.includes('browser-tests')) {
return;
}

View file

@ -7,9 +7,18 @@ services:
dockerfile: ./.docker/Dockerfile
target: development
ports:
- "2368:2368"
- "4200:4200"
- "4201:4201"
- "2368:2368" # Ghost
- "4200:4200" # Admin
- "4201:4201" # Admin tests
- "4173:4173" # Lexical
- "41730:41730" # Lexical HTTPS
- "4175:4175" # Portal
- "4176:4176" # Portal HTTPS
- "4177:4177" # Announcement bar
- "4178:4178" # Search
- "6174:6174" # Signup form
- "7173:7173" # Comments
- "7174:7174" # Comments HTTPS
profiles: [full]
volumes:
- .:/home/ghost
@ -19,6 +28,10 @@ services:
condition: service_healthy
redis:
condition: service_healthy
environment:
- DEBUG=${DEBUG:-}
- GHOST_DEV_APP_FLAGS=${GHOST_DEV_APP_FLAGS:-}
- GHOST_DEV_MODE=${GHOST_DEV_MODE:-}
mysql:
image: mysql:8.0.35
container_name: ghost-mysql

View file

@ -34,11 +34,12 @@
"reset:data": "cd ghost/core && node index.js generate-data --clear-database --quantities members:100000,posts:500 --seed 123",
"reset:data:empty": "cd ghost/core && node index.js generate-data --clear-database --quantities members:0,posts:0 --seed 123",
"reset:data:xxl": "cd ghost/core && node index.js generate-data --clear-database --quantities members:2000000,posts:0,emails:0,members_stripe_customers:0,members_login_events:0,members_status_events:0 --seed 123",
"docker": "COMPOSE_PROFILES=${COMPOSE_PROFILES:-full} docker compose run --rm -it ghost yarn",
"docker:setup": "git submodule update --init && node .github/scripts/setup-docker.js",
"docker:dev": "COMPOSE_PROFILES=full docker compose up --attach=ghost --no-log-prefix",
"docker:test:unit": "COMPOSE_PROFILES=full docker compose run --rm --no-deps ghost yarn test:unit",
"docker:test:browser": "COMPOSE_PROFILES=full docker compose run --rm ghost yarn test:browser",
"docker:test:all": "COMPOSE_PROFILES=full docker compose run --rm ghost yarn nx run ghost:test:all",
"docker:dev": "COMPOSE_PROFILES=${COMPOSE_PROFILES:-full} docker compose up --attach=ghost --no-log-prefix",
"docker:test:unit": "COMPOSE_PROFILES=${COMPOSE_PROFILES:-full} docker compose run --rm --no-deps ghost yarn test:unit",
"docker:test:browser": "COMPOSE_PROFILES=${COMPOSE_PROFILES:-full} docker compose run --rm ghost yarn test:browser",
"docker:test:all": "COMPOSE_PROFILES=${COMPOSE_PROFILES:-full} docker compose run --rm ghost yarn nx run ghost:test:all",
"docker:reset": "docker compose down -v && docker compose up -d --wait",
"docker:down": "docker compose down",
"compose": "docker compose -f .devcontainer/compose.yml",