Serverless from scratch. Run it in local.

Serverless in local

In the previous post we learn how to setup a serverless app from scratch, in this one we are going to learn how to run and test your updates in local.

Serverless application are really easy to deploy but it is obvious you can not deploy every time you want to test a change.

To improve that, we must have the ability to run the project in our local machine consequently we are going to speed up our development reviewing our change in local without deploying the application.

Emulate some aws resources in local so we are help us with plugins.

Serverless has a plugin ecosystem to make easy common tasks.

We are going to use the plugin serverless offiline to emulate aws lambdas and the api gateway in our local machine.


First we have to install our package, since we are assuming you don’t have node installed you could use the image of the previous post to install it.

docker run --rm -it \
     -v "$PWD":/usr/src/app \
     mirdrack/serverless npm install serverless-offline --save-dev


Next we need to configure it in serverless.yml file.

  - serverless-offline

    port: 3000

We added serverless-offline to the list of plugins and set custom configuration for the plugin.

Since we are using docker we need to explicit define our host.

The port is optional but it helps to be more descriptive.


To run our application in local we execute this command:

docker run --rm -it \
    -v "$PWD":/usr/src/app \
    -p 3000:3000 \
    mirdrack/serverless sls offline

We are spin-in up a new container with the code of our application and binding the port 3000

Finally, if we type in our browser http://localhost:3000/v2/hello you can observe the results.

Next steps

Now, we are able to develop and review our the results, as a result of this we can continue with more topics.

In conclusion to achieve a functional application we will cover:

  • How to include more code and distribute the code of your application.
  • Add a third party package.
  • Create a custom domain.

Photo by Priscilla Du Preez on Unsplash

Share this entry: