Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#5993: Ability to pass args for docker run command during invoke local docker #5994

Merged

Conversation

endeepak
Copy link
Contributor

@endeepak endeepak commented Apr 3, 2019

What did you implement:

Closes #5993

How did you implement it:

Added new option --docker-arg to pass additional arguments to docker run command used in invoke local --docker

How can we verify it:

serverless.yml

service: debuggable-lambda

provider:
  name: aws
  runtime: nodejs8.10

functions:
  hello:
    handler: handler.hello

handler.js

'use strict';

require('inspector').open(9229, "0.0.0.0", true);

module.exports.hello = async (event) => {
  debugger;
  let var_to_debug = "hello"
  return var_to_debug;
};

.vscode/launch.json

{
    "version": "0.2.0",
    "configurations": [
        {
            "type": "node",
            "request": "attach",
            "name": "Attach",
            "port": 9229,
            "localRoot": "${workspaceFolder}",
            "remoteRoot": "/var/task"
        }       
    ]
}

Example steps to debug with Visual Studio Code

  • Run below commands
# Create above files in dir called debuggable-lambda
cd debuggable-lambda
# Open code in Visual Studio Code
code .
npm install -g github:endeepak/serverless#feature/5993_invoke_local_docker_arg
serverless invoke local -f hello --docker --docker-arg='-p 9229:9229'
  • In Visual Studio Code -> Debug(Left Side Panel) -> Run Attach (Tool Bar)

Todos:

  • Write tests
  • Write documentation
  • Fix linting errors
  • Make sure code coverage hasn't dropped
  • Provide verification config / commands / resources
  • Enable "Allow edits from maintainers" for this PR
  • Update the messages below

Is this ready for review?: YES
Is it a breaking change?: NO

@pmuens pmuens self-assigned this Apr 8, 2019
Copy link
Contributor

@pmuens pmuens left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great! Thanks for updating this @endeepak 👍

I just tested it and it works fine! LGTM :shipit:

@pmuens pmuens merged commit 580396a into serverless:master Apr 8, 2019
@pmuens pmuens added this to the 1.41.0 milestone Apr 8, 2019
@dschep dschep added the feature label Apr 24, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Ability to pass docker run arguments during invoke local docker
3 participants