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

Question: Is there a way to leave the docker container running when using --useDocker? #1334

Open
uh-zz opened this issue Feb 12, 2022 · 0 comments
Labels

Comments

@uh-zz
Copy link
Contributor

uh-zz commented Feb 12, 2022

Thanks for the great project!

I am using lambda implemented in Go as a resolver for AWS AppSync.

Then, we use serverless-offline to perform local debugging with the following steps.

Prerequisite

Version

serverless-offline : 8.2.0
serverless-appsync-simulator : 0.19.2
serverless-appsync-plugin : 1.11.3

Directory

.
├── bin
│   └── myhandler // A lambda binary implemented in Go
├── mapping-templates
├── package-lock.json
├── package.json
├── schema.graphql
├── serverless.ts // Using ts files instead of yaml

serverless.ts

provider: {
    runtime: "go1.x",
},
functions: {
    myhandler: {
        name: "myhandler",
        handler: "bin/myhandler",
    }
},
plugins: [
    "serverless-appsync-plugin",
    "serverless-appsync-simulator",
    "serverless-offline",
]

Run command

npx sls offline start --stage local --useDocker --dockerNetwork my-local-docker-network

When started, I will see the following log and can access the local GraqhiQl from browser

AppSync Simulator: AppSync endpoint: http://x.x.x.x:20002/graphql
AppSync Simulator: GraphiQl: http://x.x.x.x:20002
offline: Starting Offline: *****.
offline: Offline [http for lambda] listening on http://localhost:3002
offline: Function names exposed for local invocation by aws-sdk:
Hot-reloading AppSync simulator...

Once I run the query, I will see the results in about 40-50 seconds.

Then, about 2 minutes later, the local lambda started by the docker container will stop.

Question

  1. Is it possible to extend the stoppage of lambda started by a Docker container? (Is there such an option available?)
  2. Other than using the --useDocker, is there any other way to start a lambda implemented in Go at the same time as GraphiQl?

Expect

It would be nice if the lambda would return results a little faster after executing a Graphiql query, like it did with AWS.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants