简体   繁体   English

离线构建无服务器应用程序的最佳方法是什么?

[英]What is the best way to build serverless app offline?

I'm trying to create a REST API with aws (Nodejs) and dynamodb. 我试图用aws(Nodejs)和dynamodb创建一个REST API。 Most of the time I do not have access to AWS and I need to have everything running offline to test and only deploy when I have an amount of work done. 大多数情况下,我无权访问AWS,并且我需要使所有内容脱机运行以进行测试,并且仅在完成大量工作后才进行部署。 Is there any guide or good practices that help me in the development? 是否有任何指南或良好实践对我的发展有所帮助?

Thanks in advance! 提前致谢!

you can run offline version of dynamodb on your localhost. 您可以在本地主机上运行dynamodb的脱机版本。 The easiest is to have it in container in docker. 最简单的方法是将其放在Docker的容器中。 Then you dont have to manage it at all and it will work in every environment that has docker installed. 然后,您完全不必对其进行管理,它将在安装了docker的每个环境中运行。

This is what we have in package.json scripts for serverless application 这是无服务器应用程序的package.json脚本中的内容

    "start": "sls offline start",
    "start-local": "npm run force-dynamo sls offline start --stage=localhost",
    "force-dynamo": "npm run stop-dynamo && npm run start-dynamo",
    "start-dynamo": "docker run -d -p 8000:8000 dwmkerr/dynamodb -sharedDb",
    "stop-dynamo": "docker stop $(docker ps -a -q --filter ancestor=dwmkerr/dynamodb --format=\"{{.ID}}\")",

However if you do not care that much about CI/CD pipeline or reusability on multiple devices -> you can just install dynamoDB, run it and based on configuration just target your offline/online dynamodb. 但是,如果您不太在意CI / CD管道或在多个设备上的可重用性->您可以仅安装dynamoDB,运行它,并基于配置仅针对您的脱机/在线动态模型。

AWS Localstack是无服务器应用程序本地开发的不错选择

Use Sam Local for the lambda part and DynamoDB Local for the DynamoDB part. Sam Local用于lambda部分,将DynamoDB Local用于DynamoDB部分。 I recommend running DynamoDB local using the docker container like libik mentions. 我建议使用libik提到的docker容器在本地运行DynamoDB。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用AWS Lambda上的无服务器框架在微服务架构项目中处理node_modules的最佳方法是什么? - What is the best way to handle node_modules in a microservice architecture project using serverless framework on AWS Lambda? 在服务器上执行nodejs应用的最佳方法是什么? - What is the best way to execute nodejs app on a server? 未找到无服务器命令“离线” - Serverless command "offline" not found 无服务器 - 离线插件 - Serverless - offline plugin 在 mongodb 上构建多个权限组的最佳方法是什么? - what is the best way to build multiple permission group on mongodb? 在离线桌面应用程序上显示 ZIP 存档中的图像的最有效方法是什么? - What is the most efficient way to display images from a ZIP archive on an offline desktop app? 从节点应用程序发布到 Wordpress 博客的最佳方式是什么? - What is the best way to post to a Wordpress blog from a node app? 将 React js 应用程序与节点 js 服务器连接的最佳方式是什么? - What is the best way to connect React js app with node js server? 在Windows上托管node.js应用程序的最佳方法是什么? - What is the best way to host node.js app on Windows? 在应用程序中分离“开发”和“生产”模式的最佳方法是什么? - What is the best way of separating "dev" and "prod" modes in the app?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM