0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-01-20 22:42:53 -05:00

Reorganized docker related files (#21650)

ref https://linear.app/ghost/issue/ENG-1782/move-docker-related-files-to-a-better-location-that-githubscripts

- The docker files are currently located in `.github/scripts`. This location doesn't make a lot of sense — you wouldn't think to look there unless you already knew they were there. This also requires you to specify the path to the `compose.yml` file whenever running a `docker compose ...` command. 
- This commit moves the `compose.yml` file to the root of the repo, so you can simply run `docker compose up` and it will automatically find the file in the root, without having to specify `-f .github/scripts/docker-compose.yml`. This is a major win for convenience over the current setup.
- It also moves all the related files, including the `Dockerfile` used by the Dev Container setup and configuration files for supporting services into a new `.docker` directory, which is a more logical location, and should be easier to find.
- Also updated the current convenience commands in the `package.json` scripts block (`yarn docker:reset` and `yarn docker:down`
This commit is contained in:
Chris Raible 2024-11-19 13:15:06 -08:00 committed by GitHub
parent 47b8161805
commit 05127ddc5c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 11 additions and 11 deletions

View file

@ -5,13 +5,13 @@ This file contains the configuration for the dev container. It is used to define
There are three main components that the devcontainer.json file relies on: 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 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 (`.devcontainer/Dockerfile`), which is used to build the dev container image. - 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 `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. 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 ## Dockerfile
The Dockerfile used to build the Dev Container itself is located at `.devcontainer/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: 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`: 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. - `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 - `full-devcontainer`: everything from `base-devcontainer`, plus Ghost's code and all node dependencies

View file

@ -9,7 +9,7 @@ services:
command: ["sleep", "infinity"] command: ["sleep", "infinity"]
build: build:
context: ../ context: ../
dockerfile: .devcontainer/Dockerfile dockerfile: .docker/Dockerfile
target: base-devcontainer target: base-devcontainer
pull_policy: never pull_policy: never
environment: environment:

View file

@ -14,7 +14,7 @@ services:
restart: always restart: always
volumes: volumes:
# Turns out you can drop .sql or .sql.gz files in here, cool! # Turns out you can drop .sql or .sql.gz files in here, cool!
- ./mysql-preload:/docker-entrypoint-initdb.d - ./.docker/mysql-preload:/docker-entrypoint-initdb.d
- mysql-data:/var/lib/mysql - mysql-data:/var/lib/mysql
healthcheck: healthcheck:
test: "mysql -uroot -proot ghost -e 'select 1'" test: "mysql -uroot -proot ghost -e 'select 1'"
@ -34,7 +34,7 @@ services:
- "9090:9090" - "9090:9090"
restart: always restart: always
volumes: volumes:
- ./prometheus/prometheus.yml:/etc/prometheus/prometheus.yml - ./.docker/prometheus/prometheus.yml:/etc/prometheus/prometheus.yml
grafana: grafana:
profiles: [monitoring] profiles: [monitoring]
image: grafana/grafana:8.3.0 image: grafana/grafana:8.3.0
@ -46,9 +46,9 @@ services:
- GF_AUTH_ANONYMOUS_ENABLED=true - GF_AUTH_ANONYMOUS_ENABLED=true
- GF_AUTH_ANONYMOUS_ORG_ROLE=Admin - GF_AUTH_ANONYMOUS_ORG_ROLE=Admin
volumes: volumes:
- ./grafana/datasources:/etc/grafana/provisioning/datasources - ./.docker/grafana/datasources:/etc/grafana/provisioning/datasources
- ./grafana/dashboard.yml:/etc/grafana/provisioning/dashboards/main.yaml - ./.docker/grafana/dashboard.yml:/etc/grafana/provisioning/dashboards/main.yaml
- ./grafana/dashboards:/var/lib/grafana/dashboards - ./.docker/grafana/dashboards:/var/lib/grafana/dashboards
pushgateway: pushgateway:
profiles: [monitoring] profiles: [monitoring]
image: prom/pushgateway:v1.6.0 image: prom/pushgateway:v1.6.0

View file

@ -34,9 +34,9 @@
"reset:data": "cd ghost/core && node index.js generate-data --clear-database --quantities members:100000,posts:500 --seed 123", "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: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", "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:reset": "docker-compose -f .github/scripts/docker-compose.yml down -v && docker-compose -f .github/scripts/docker-compose.yml up -d --wait", "docker:reset": "docker compose down -v && docker compose up -d --wait",
"docker:down": "docker-compose -f .github/scripts/docker-compose.yml down", "docker:down": "docker compose down",
"compose": "docker compose -f .devcontainer/.docker/base.compose.yml -f .devcontainer/.docker/development.compose.yml", "compose": "docker compose -f .devcontainer/compose.yml",
"lint": "nx run-many -t lint", "lint": "nx run-many -t lint",
"test": "nx run-many -t test", "test": "nx run-many -t test",
"test:unit": "nx run-many -t test:unit", "test:unit": "nx run-many -t test:unit",