serverless-localstack icon indicating copy to clipboard operation
serverless-localstack copied to clipboard

How to work with mountCode and webpack?

Open fterradev opened this issue 4 years ago • 2 comments
trafficstars

I'm working with mountCode + serverless-webpack. My main question is:

  1. Do I need to create a docker volume? If so, how should this volume be defined?

  2. Does it make sense to use mountCode together with LAMBDA_REMOTE_DOCKER=true?

fterradev avatar Aug 06 '21 17:08 fterradev

@fterradev did you manage to solve your issue pls?

Could be that I'm having the same issue - https://github.com/localstack/serverless-localstack/issues/171

ivanmartos avatar Nov 16 '21 08:11 ivanmartos

Same for me, the documentation unfortunately is very ambiguous.

I've been trying to make this work with the following setup:

Docker-compose with two services:

  1. app: This is a serverless framework app that depends on serverless-webpack and serverless-localstack
  2. localstack: This is based on image localstack/localstack:latest

To run:

  1. docker-compose up localstack
  2. docker-compose up app to build and deploy the lambdas (which invokes serverless webpack --stage local and serverless deploy --stage local)

A .webpack folder is created in the host and without mountCode everything is deployed fine, although it takes around 5+ minutes because of all the docker bindings.

I wanted then to improve by binding the .webpack folder to localstack /tmp/localstack (according to documentation), but unfortunately it won't work, I've tried all kinds of env var + serverless configuration settings.

bertrandmc avatar Mar 15 '22 18:03 bertrandmc