mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-20 22:42:53 -05:00
c1f9740665
ref https://linear.app/ghost/issue/ENG-1957/add-ghost-service-to-base-docker-compose-setup - Currently our `compose.yml` file only runs Ghost's supporting services, and it's expected that you'll run Ghost locally on your host machine. This commit adds a `ghost` service to our `compose.yml` file, so you can optionally run Ghost itself in a container using docker compose. - The `ghost` service is opt-in using [docker compose profiles](https://docs.docker.com/compose/how-tos/profiles/), to maintain the current behavior of only running supporting services as the default. - This commit also fixes an issue in the Dockerfile: the `WORKDIR` arg, which is used to optionally specify an alternative working directory, is not propagated from one build stage to the next, so it has to be manually added as an `ARG` in each stage. This was necessary to use the same Dockerfile for devcontainers (which require the WORKDIR to be `/workspaces/ghost`) and docker compose, where we use `/home/ghost` in alignment with the production image.
60 lines
1.9 KiB
Docker
60 lines
1.9 KiB
Docker
ARG NODE_VERSION=20.15.1
|
|
ARG WORKDIR=/home/ghost
|
|
|
|
## Base Image used for all targets
|
|
FROM node:$NODE_VERSION-bullseye-slim AS base
|
|
RUN apt-get update && \
|
|
apt-get install -y \
|
|
build-essential \
|
|
curl \
|
|
jq \
|
|
libjemalloc2 \
|
|
python3 \
|
|
tar
|
|
|
|
# Base DevContainer: for use in a Dev Container where your local code is mounted into the container
|
|
### Adding code and installing dependencies gets overridden by your local code/dependencies, so this is done in onCreateCommand
|
|
FROM base AS base-devcontainer
|
|
ARG WORKDIR=/home/ghost
|
|
# Install Stripe CLI, zsh, playwright
|
|
RUN curl -s https://packages.stripe.dev/api/security/keypair/stripe-cli-gpg/public | gpg --dearmor | tee /usr/share/keyrings/stripe.gpg && \
|
|
echo "deb [signed-by=/usr/share/keyrings/stripe.gpg] https://packages.stripe.dev/stripe-cli-debian-local stable main" | tee -a /etc/apt/sources.list.d/stripe.list && \
|
|
apt update && \
|
|
apt install -y \
|
|
git \
|
|
stripe \
|
|
zsh \
|
|
procps \
|
|
default-mysql-client && \
|
|
npx -y playwright@1.46.1 install --with-deps
|
|
|
|
ENV NX_DAEMON=true
|
|
ENV YARN_CACHE_FOLDER=$WORKDIR/.yarncache
|
|
|
|
EXPOSE 2368
|
|
EXPOSE 4200
|
|
EXPOSE 4173
|
|
EXPOSE 41730
|
|
EXPOSE 4175
|
|
EXPOSE 4176
|
|
EXPOSE 4177
|
|
EXPOSE 4178
|
|
EXPOSE 6174
|
|
EXPOSE 7173
|
|
EXPOSE 7174
|
|
|
|
|
|
# Full Devcontainer Stage: Add the code and install dependencies
|
|
### 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
|
|
FROM base-devcontainer AS full-devcontainer
|
|
ARG WORKDIR=/home/ghost
|
|
WORKDIR $WORKDIR
|
|
COPY . .
|
|
RUN yarn install --frozen-lockfile --prefer-offline --cache-folder $YARN_CACHE_FOLDER
|
|
|
|
FROM base-devcontainer AS development
|
|
ARG WORKDIR=/home/ghost
|
|
WORKDIR $WORKDIR
|
|
ENTRYPOINT ["/home/ghost/.docker/development.entrypoint.sh"]
|
|
CMD ["yarn", "dev"]
|