0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-01-06 22:40:14 -05:00
ghost/.devcontainer
Chris Raible 71fb9f8b34
Converted dev container's onCreateCommand to JavaScript (#21457)
no issue

- The onCreateCommand was previously a bash script, which made it a bit
more challenging to read and make changes to it. This commit converts it
to JavaScript so it will be easier to make updates to it.
2024-10-29 13:03:49 -07:00
..
.docker Added Dev Container setup (#21279) 2024-10-24 11:15:08 -07:00
devcontainer.json Converted dev container's onCreateCommand to JavaScript (#21457) 2024-10-29 13:03:49 -07:00
onCreateCommand.js Converted dev container's onCreateCommand to JavaScript (#21457) 2024-10-29 13:03:49 -07:00
README.md Added Dev Container setup (#21279) 2024-10-24 11:15:08 -07:00

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.

It points to a docker compose file in the .devcontainer/.docker directory, which in turn relies on a Dockerfile in the same directory.

Dockerfile

The Dockerfile in this directory 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

Similarly, the docker compose configuration relies on merging compose files to create the final configuration. The base.compose.yml file contains the bare minimum configuration, and can be extended by specifying additional services or modifying the existing ones by supplying additional compose files. For example, to run the development.compose.yml file, you would use the following command:

docker compose -f .devcontainer/docker/base.compose.yml -f .devcontainer/docker/development.compose.yml up

There is an alias yarn compose script in the top level package.json which points to the appropriate compose.yml files for local development.

This setup gives us the flexibility to create multiple different docker compose configurations, while ensuring a base level of consistency across configurations.