0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2024-12-30 22:34:01 -05:00

Consolidated compose.yml files for Dev Container (#21659)

ref
https://linear.app/ghost/issue/ENG-1785/consolidate-dev-container-composeyml-with-the-root-level-composeyml

- We currently have two compose.yml files:
    - `.devcontainer/compose.yml`: used for the Dev Container
    - `compose.yml`: used for local development with docker compose
- The Dev Container compose file does need some additional
configuration, but most of this code is duplicated from the root level
compose.yml file
- This commit removes this duplication by using both compose files in
the Dev Container setup, so it will base the compose configuration on
the root level, and then extend it with the Dev Container specific
configuration
- This way any updates to the root level compose file will also be
available and reflected in the Dev Container setup without having to
make the change twice.
This commit is contained in:
Chris Raible 2024-12-17 15:57:02 -05:00 committed by GitHub
parent 58ac19ada6
commit cabee005f4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 19 additions and 26 deletions

View file

@ -11,6 +11,8 @@ services:
context: ../ context: ../
dockerfile: .docker/Dockerfile dockerfile: .docker/Dockerfile
target: base-devcontainer target: base-devcontainer
args:
WORKDIR: /workspaces/ghost
pull_policy: never pull_policy: never
environment: environment:
- DEVCONTAINER=true - DEVCONTAINER=true
@ -21,30 +23,15 @@ services:
redis: redis:
condition: service_healthy condition: service_healthy
mysql: mysql:
image: mysql:8.0.35 extends:
# We'll need to look into how we can further fine tune the memory usage/performance here file: ../compose.yml
command: --innodb-buffer-pool-size=1G --innodb-log-buffer-size=500M --innodb-change-buffer-max-size=50 --innodb-flush-log-at-trx_commit=0 --innodb-flush-method=O_DIRECT service: mysql
ports: container_name: ghost-devcontainer-mysql
- "3306"
environment:
MYSQL_ROOT_PASSWORD: root
MYSQL_DATABASE: ghost
restart: always
volumes:
- mysql-data:/var/lib/mysql
healthcheck:
test: "mysql -uroot -proot ghost -e 'select 1'"
interval: 1s
retries: 120
redis: redis:
image: redis:7.0 extends:
ports: file: ../compose.yml
- "6379" service: redis
restart: always container_name: ghost-devcontainer-redis
healthcheck:
test: [ "CMD", "redis-cli", "--raw", "incr", "ping" ]
interval: 1s
retries: 120
volumes: volumes:
mysql-data: mysql-data:

View file

@ -1,4 +1,6 @@
ARG NODE_VERSION=20.15.1 ARG NODE_VERSION=20.15.1
ARG WORKDIR=/home/ghost
## Base Image used for all targets ## Base Image used for all targets
FROM node:$NODE_VERSION-bullseye-slim AS base FROM node:$NODE_VERSION-bullseye-slim AS base
RUN apt-get update && \ RUN apt-get update && \
@ -45,14 +47,14 @@ EXPOSE 7174
### This is a full devcontainer with all the code and dependencies installed ### This is a full devcontainer with all the code and dependencies installed
### Useful in an environment like Github Codespaces where you don't mount your local code into the container ### Useful in an environment like Github Codespaces where you don't mount your local code into the container
FROM base-devcontainer AS full-devcontainer FROM base-devcontainer AS full-devcontainer
WORKDIR /workspaces/ghost WORKDIR $WORKDIR
COPY ../../ . COPY ../../ .
RUN yarn install --frozen-lockfile --prefer-offline --cache-folder $YARN_CACHE_FOLDER RUN yarn install --frozen-lockfile --prefer-offline --cache-folder $YARN_CACHE_FOLDER
# Development Stage: alternative entrypoint for development with some caching optimizations # Development Stage: alternative entrypoint for development with some caching optimizations
FROM base-devcontainer AS development FROM base-devcontainer AS development
WORKDIR /workspaces/ghost WORKDIR $WORKDIR
COPY ../../ . COPY ../../ .

View file

@ -26,6 +26,10 @@ services:
ports: ports:
- "6379:6379" - "6379:6379"
restart: always restart: always
healthcheck:
test: [ "CMD", "redis-cli", "--raw", "incr", "ping" ]
interval: 1s
retries: 120
prometheus: prometheus:
profiles: [monitoring] profiles: [monitoring]
image: prom/prometheus:v2.30.3 image: prom/prometheus:v2.30.3