diff --git a/.github/scripts/dev.js b/.github/scripts/dev.js index 257282701b..86dbd4a20c 100644 --- a/.github/scripts/dev.js +++ b/.github/scripts/dev.js @@ -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; } diff --git a/compose.yml b/compose.yml index 6aa743b89a..fcc4614b34 100644 --- a/compose.yml +++ b/compose.yml @@ -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 diff --git a/package.json b/package.json index 32292183d4..f9b1ac73de 100644 --- a/package.json +++ b/package.json @@ -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",