weixu365 / serverless-scriptable-plugin

Adding script support to Serverless 1.x which enables you to customize Serverless behavior without writing a plugin.
MIT License
112 stars 11 forks source link

Issue running this plugin with docker #41

Closed AnthonyWC closed 5 years ago

AnthonyWC commented 5 years ago

Will able to do more testing later but I had issue getting the plugin to trigger within a docker environment that only has ash shell (alpine). Does the plugin make certain assumption about the shell environment? I had a bash script that had a shebang pointing to the bash installed inside docker but it wasn't launched from bash.

weixu365 commented 5 years ago

Hi @AnthonyWC , could you please provide more information? e.g.

I did a quick test and it works on my machine. I'm using node:alpine docker image

A few things to check:

Here's my testing commands:

$ docker run -it -v `pwd`:/code -w /code node:alpine sh
/code # ls -l
total 192
-rw-r--r--    1 root     root            17 Aug 16 04:46 Dockerfile
-rwxr-xr-x    1 root     root            24 Aug 15 23:49 build.sh
-rw-r--r--    1 root     root            87 Aug 15 23:53 handler.js
drwxr-xr-x  422 root     root         13504 Aug 16 04:57 node_modules
-rw-r--r--    1 root     root        172162 Aug 15 23:49 package-lock.json
-rw-r--r--    1 root     root           304 Aug 15 23:49 package.json
-rw-r--r--    1 root     root           257 Aug 16 04:49 serverless.yml

/code # cat serverless.yml 
service: demo

provider:
  name: aws
  runtime: nodejs8.10
  region: ap-southeast-2

plugins:
  - serverless-scriptable-plugin

custom:
  scriptHooks:
    before:package:createDeploymentArtifacts: ./build.sh

functions:
  test:
    handler: handler.handle

/code # cat build.sh 
echo my own build script

/code # npx serverless package
Running command: ./build.sh
my own build script
Serverless: Packaging service...
Serverless: Excluding development dependencies...
AnthonyWC commented 5 years ago

Sorry user error. :)