It is a simple node application provided as Rest API. It can be used with docker or serverless.
Uses a number of open source projects to work properly:
express.js
mysql
node.js
- v16.x
You can use docker or serverless to start your new instance.
You need to create a image local to run a aplication. I created 3 images, those represent stages like stable, development and production.
Create a stable( latest ) image tag:
docker build -t pedrotti/node:express .
Create a new production tag with updated source code inside:
docker build --no-cache -f Dockerfile.prod -t pedrotti/node-express:v1.0 .
Create a new developement tag using nodemon:
docker build --no-cache -f Dockerfile.dev -t pedrotti/node-express:dev .
That tag is already setted on docker-compose.yml
.
Start a new instance at root project:
docker-compose up -d
Charge a new instance of database.
docker exec node-api npx sequelize --help
docker exec node-api npx sequelize db:migrate
docker exec node-api npx sequelize db:seed:all
Watch logs from nodemon:
docker logs --follow node-api
Install Serverless as global package.
npm install -g serverless
Install plugins to start localhost.
npm install serverless-offline --save-dev
npm install serverless-sequelize-migrations --save-dev
Startup a new instance.
serverless offline
Serverless will bind in port 3000 on localhost. You could create a new instance of database at localhost too. Install a mysql-server
package or using docker mysql bind por 5306 to localhost.
Create a new instance with docker:
docker run -d --name mysql -p 5306:5306 -e MYSQL_ROOT_PASSWORD=root mysql:5.7
Charge that instance with migrations:
serverless migrations list
serverless migrations up
Todo: expand this topic.
If you are trying to use AWS Lambda, first you need to install AWS CLI and configure Access key ID and Secret acess key from a IAM account.
aws configure
Serverless deploy will translate serverless.yml
configs into AWS CloudFormation commands.
serverless deploy
Todo: expand this topic.
Todo: expand this topic.
- AWS CLI - AWS Command Line Interface
- Serverless - Cloud computing execution model
- Express.js - A back end web application framework for building RESTful APIs
- Lambda Layers - Creating and sharing Lambda layers