mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-03-04 02:01:58 -05:00
Configured ssh agent forwarding for docker compose (#22232)
no issue - Currently running any `git` commands in the docker container (i.e. updating submodules) that use ssh are failing because the container can't see your ssh keys. This commit adds a volume & environment variable to enable forwarding your local ssh agent into the container. As long as you've got an ssh agent running locally with your keys enabled, this will allow you to e.g. push to a remote over ssh from inside the container. - It also mounts your local `.gitconfig` file into the container, so your git configuration (i.e. name & email address) will also work inside the container - Finally, it adds githubs ssh keys to known_hosts in the development target of the Dockerfile to avoid the prompt, which only works in interactive environments and fails in any kind of script (like `yarn main:submodules`).
This commit is contained in:
parent
11ca9e3009
commit
fa377b5ac0
2 changed files with 12 additions and 0 deletions
|
@ -37,6 +37,11 @@ FROM development-base AS development
|
|||
ARG WORKDIR=/home/ghost
|
||||
WORKDIR $WORKDIR
|
||||
|
||||
## Add github to known hosts
|
||||
### Without this, git submodule updates fail inside the container
|
||||
RUN mkdir -p /root/.ssh && \
|
||||
ssh-keyscan github.com >> /root/.ssh/known_hosts
|
||||
|
||||
# Enable the NX Daemon
|
||||
ENV NX_DAEMON=true
|
||||
|
||||
|
|
|
@ -23,6 +23,12 @@ services:
|
|||
# Mount the source code
|
||||
- .:/home/ghost
|
||||
|
||||
## SSH Agent forwarding
|
||||
- ${SSH_AUTH_SOCK}:/ssh-agent
|
||||
|
||||
## Git config
|
||||
- ${HOME}/.gitconfig:/root/.gitconfig:ro
|
||||
|
||||
# Volume exclusions:
|
||||
## Prevent collisions between host and container node_modules
|
||||
- node_modules_ghost_root:/home/ghost/node_modules:delegated
|
||||
|
@ -131,6 +137,7 @@ services:
|
|||
condition: service_healthy
|
||||
environment:
|
||||
- DEBUG=${DEBUG:-}
|
||||
- SSH_AUTH_SOCK=/ssh-agent
|
||||
- GHOST_DEV_IS_DOCKER=true
|
||||
- GHOST_DEV_APP_FLAGS=${GHOST_DEV_APP_FLAGS:-}
|
||||
- STRIPE_SECRET_KEY=${STRIPE_SECRET_KEY:-}
|
||||
|
|
Loading…
Add table
Reference in a new issue