2

I run a node server (in a Docker container) to listen for github webhooks, so I can redeploy when my master gets updated. My home directory contains:

production/
app/webhooks/
docker-compose-webhooks.yml
deploy.sh

~/docker-compose-webhooks.yml

version: '3'
services:
  webhooks:
    image: node:10.11.0-alpine
    container_name: abis-webhooks
    working_dir: /webhooks
    environment:
      NODE_ENV: production
      PORT: 5050
      GITHUB_SECRET: ${GITHUB_SECRET}
    expose:
      - '5050'
    volumes:
      - ./app/webhooks:/webhooks
    command: /bin/sh -c 'npm install --production; npm start'

~/deploy.sh

#!/bin/bash

cd ~/production && git pull origin master
...
...

What's the easiest way I can call the deploy.sh that is obviously located outside the container where node sits.

I took this from another post and add it in node:

exec(`docker run --rm -v /usr/bin:/usr/bin --privileged -v $(pwd)/depoly.sh:~/deploy.sh ubuntu bash ~/deploy.sh`)
Radu Chiriac
  • 1,374
  • 3
  • 18
  • 34
  • There is a similar question here: [How to run shell script on host from docker container?](https://stackoverflow.com/questions/32163955/how-to-run-shell-script-on-host-from-docker-container). Be careful of the security risks you might have by following this approach. – tgogos Nov 29 '18 at 14:15
  • that's where I found the `docker run --rm` but no success executing that – Radu Chiriac Nov 29 '18 at 14:21
  • 1
    Possible duplicate of [How to run shell script on host from docker container?](https://stackoverflow.com/questions/32163955/how-to-run-shell-script-on-host-from-docker-container) – David Maze Nov 29 '18 at 14:58
  • I saw that post, but I don't see where it should be run from? – Radu Chiriac Nov 29 '18 at 16:18

0 Answers0