dherault / dherault/serverless-offline
Question: Is there a way to leave the docker container running when using `--useDocker`?
- Dominant language
- JavaScript
- Stars
- 5.3k
- Forks
- 811
- Avg merge
- 2d 4h
- Merged PRs (30d)
- 3
Description
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](https://github.com/dherault/serverless-offline) : 8.2.0
[serverless-appsync-simulator](https://github.com/bboure/serverless-appsync-simulator) : 0.19.2
[serverless-appsync-plugin](https://github.com/sid88in/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
```typescript
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.
Contributor guide
Assessment
This issue has not been assessed yet.