Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main'
Browse files Browse the repository at this point in the history
  • Loading branch information
andreascreten committed Feb 4, 2025
2 parents 90019d4 + 0e63055 commit 34de5a5
Show file tree
Hide file tree
Showing 1,938 changed files with 91,029 additions and 33,935 deletions.
24 changes: 24 additions & 0 deletions .devcontainer/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Dev Container Setup

## devcontainer.json
This file contains the configuration for the dev container. It is used to define the setup of the container, including things like port bindings, environment variables, and other dev container specific features.

There are three main components that the devcontainer.json file relies on:
- The docker compose file (`.devcontainer/compose.yml`), which defines all the services that should be started when the dev container is launched, like MySQL and Redis.
- The Dockerfile (`.docker/Dockerfile`), which is used to build the dev container image.
- The `onCreateCommand` script (`.devcontainer/onCreateCommand.js`), which is used to setup the dev container after it is created.

The Dev Container setup is intended to be as simple as possible with a focus on a really simple setup experience. It is designed to use VSCode's "Clone Repository in Container" feature, which will automatically handle the setup of the dev container, and create a volume for the Ghost codebase that is managed by Docker. It is a great tool for quickly spinning up an isolated development environment, but it lacks some of the flexibility and direct control that a full docker compose setup can provide. Therefore, if you plan to do more "heavy lifting" on Ghost, we recommend using the docker compose setup instead.

## Dockerfile
The Dockerfile used to build the Dev Container itself is located at `.docker/Dockerfile`. This Dockerfile uses a multi-stage build to allow for multiple types of builds without duplicating code and ensuring maximum consistency. The following targets are available:
- `base`: The bare minimum base image used to build and run Ghost. Includes the operating system, node, and some build dependencies, but does not include any Ghost code or dependencies.
- `base-devcontainer`: everything from `base`, plus additional development dependencies like the stripe-cli and playwright. No code or node dependencies.
- `full-devcontainer`: everything from `base-devcontainer`, plus Ghost's code and all node dependencies
- `development`: an alternative to `full-devcontainer` intended for manual development e.g. with docker compose. Add Ghost's code and installs dependencies with some optimizations for the yarn cache

## Docker Compose
The docker compose setup for the dev container is located at `.devcontainer/compose.yml`. This compose file includes the MySQL database service and the Redis service, in addition to the Ghost dev container service. When running the Dev Container (i.e. via the "Clone Repository in Container" feature in VSCode), this compose file will be used to start the necessary services before starting the Ghost Dev Container itself.

## On Create Command
The Dev Container spec allows developers to specify a command to run after the container is created. This is done by specifying an `onCreateCommand` in the devcontainer.json file. For Ghost's Dev Container, this command simply runs a JS script defined in `.devcontainer/onCreateCommand.js`. This script handles installing node dependencies, setting up the local configuration at `ghost/core/config.local.json`, and some other simple setup tasks to get the dev container ready for use.
38 changes: 38 additions & 0 deletions .devcontainer/compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Base container and services for running Ghost
## Intended to be extended by another compose file
## e.g. docker compose -f base.compose.yml -f development.compose.yml up
## Does not include development dependencies, Ghost code, or any other dependencies
name: ghost-devcontainer
services:
ghost:
image: ghost-devcontainer
command: ["sleep", "infinity"]
build:
context: ../
dockerfile: .docker/Dockerfile
target: base-devcontainer
args:
WORKDIR: /workspaces/ghost
pull_policy: never
environment:
- DEVCONTAINER=true
tty: true
depends_on:
mysql:
condition: service_healthy
redis:
condition: service_healthy
mysql:
extends:
file: ../compose.yml
service: mysql
container_name: ghost-devcontainer-mysql
redis:
extends:
file: ../compose.yml
service: redis
container_name: ghost-devcontainer-redis

volumes:
mysql-data:
redis-data:
154 changes: 154 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
{
"name": "Ghost Local DevContainer",
"features": {
"ghcr.io/devcontainers/features/github-cli:1": {},
"ghcr.io/nils-geistmann/devcontainers-features/zsh:0": {
"plugins": "git yarn gh"
}
},
"dockerComposeFile": ["./compose.yml"],
"service": "ghost",
"workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}",
"shutdownAction": "stopCompose",
"onCreateCommand": ["node", "./.devcontainer/onCreateCommand.js"],
"updateContentCommand": ["git", "submodule", "update", "--init", "--recursive"],
"postCreateCommand": ["yarn", "knex-migrator", "init"],
"remoteEnv": {
"STRIPE_SECRET_KEY": "${localEnv:STRIPE_SECRET_KEY}",
"STRIPE_API_KEY": "${localEnv:STRIPE_SECRET_KEY}",
"STRIPE_PUBLISHABLE_KEY": "${localEnv:STRIPE_PUBLISHABLE_KEY}",
"STRIPE_ACCOUNT_ID": "${localEnv:STRIPE_ACCOUNT_ID}",
"MAILGUN_SMTP_USER": "${localEnv:MAILGUN_SMTP_USER}",
"MAILGUN_SMTP_PASS": "${localEnv:MAILGUN_SMTP_PASS}",
"MAILGUN_FROM_ADDRESS": "${localEnv:MAILGUN_FROM_ADDRESS}",
"MAILGUN_API_KEY": "${localEnv:MAILGUN_API_KEY}",
"MAILGUN_DOMAIN": "${localEnv:MAILGUN_DOMAIN}",
"GHOST_UPSTREAM": "${localEnv:GHOST_UPSTREAM}",
"GHOST_FORK_REMOTE_URL": "${localEnv:GHOST_FORK_REMOTE_URL}",
"GHOST_FORK_REMOTE_NAME": "${localEnv:GHOST_FORK_REMOTE_NAME}",
"GHOST_FORCE_SSH": "${localEnv:GHOST_FORCE_SSH}"
},
"forwardPorts": [2368,4200],
"portsAttributes": {
"80": {
"onAutoForward": "ignore"
},
"2368": {
"label": "Ghost"
},
"2369": {
"label": "Ghost (Test Server)",
"onAutoForward": "silent"
},
"2370": {
"label": "Ghost (Test Server)",
"onAutoForward": "silent"
},
"2371": {
"label": "Ghost (Test Server)",
"onAutoForward": "silent"
},
"2372": {
"label": "Ghost (Test Server)",
"onAutoForward": "silent"
},
"2373": {
"label": "Ghost (Test Server)",
"onAutoForward": "silent"
},
"4200": {
"label": "Admin",
"onAutoForward": "silent"
},
"4201": {
"label": "Admin Live Reload",
"onAutoForward": "silent"
},
"4175": {
"label": "Portal",
},
"4176": {
"label": "Portal (HTTPS)",
"protocol": "https"
},
"4177": {
"label": "Announcement Bar"
},
"4178": {
"label": "Search"
},
"4173": {
"label": "Lexical"
},
"41730": {
"label": "Lexical (HTTPS)",
"protocol": "https"
},
"6174": {
"label": "Signup Form",
"onAutoForward": "silent"
},
"7173": {
"label": "Comments"
},
"7174": {
"label": "Comments (HTTPS)",
"protocol": "https"
},
"9174": {
"label": "Prometheus Metrics Exporter",
"onAutoForward": "silent"
},
"5173": {
"onAutoForward": "silent"
},
"5368": {
"onAutoForward": "silent"
}
},
"customizations": {
"vscode": {
"settings": {
"terminal.integrated.defaultProfile.linux": "zsh",
"terminal.integrated.profiles.linux": { "zsh": { "path": "/bin/zsh" } }
},
"extensions": [
"ms-azuretools.vscode-docker"
]
}
},
"secrets": {
"STRIPE_SECRET_KEY": {
"description": "Your Stripe account's test secret API key",
"documentationUrl": "https://dashboard.stripe.com/test/apikeys"
},
"STRIPE_PUBLISHABLE_KEY": {
"description": "Your Stripe account's test publishable key",
"documentationUrl": "https://dashboard.stripe.com/test/apikeys"
},
"STRIPE_ACCOUNT_ID": {
"description": "Your Stripe Account ID",
"documentationUrl": "https://dashboard.stripe.com/settings/account"
},
"MAILGUN_SMTP_USER": {
"description": "Your Mailgun account's SMTP username, e.g. [email protected]. You can find this in the Mailgun dashboard under Sending -> Domains -> Select your domain -> SMTP.",
"documentationUrl": "https://app.mailgun.com/mg/sending/domains"
},
"MAILGUN_SMTP_PASS": {
"description": "Your Mailgun account's SMTP password",
"documentationUrl": "https://app.mailgun.com/mg/sending/domains"
},
"MAILGUN_FROM_ADDRESS": {
"description": "The email address that will be used as the `from` address when sending emails via Mailgun",
"documentationUrl": "https://app.mailgun.com/mg/sending/domains"
},
"MAILGUN_API_KEY": {
"description": "Your Mailgun account's API key",
"documentationUrl": "https://app.mailgun.com/mg/sending/domains"
},
"MAILGUN_DOMAIN": {
"description": "Your Mailgun account's domain, e.g. sandbox1234567890.mailgun.org",
"documentationUrl": "https://app.mailgun.com/mg/sending/domains"
}
}
}
Loading

0 comments on commit 34de5a5

Please sign in to comment.