From 12e0f1e041fc28965474489e09a84fcb58573168 Mon Sep 17 00:00:00 2001 From: Piyush Garg Date: Sun, 29 Oct 2023 19:01:50 +0530 Subject: [PATCH] Added deployment scripts --- package.json | 9 +++++---- prisma/schema.prisma | 3 ++- scripts/deploy.sh | 10 ++++++++++ serverless.yml | 2 +- 4 files changed, 18 insertions(+), 6 deletions(-) create mode 100644 scripts/deploy.sh diff --git a/package.json b/package.json index d8d575a..378e392 100644 --- a/package.json +++ b/package.json @@ -5,11 +5,12 @@ "repository": "git@github.com:piyushgarg-dev/review-app-api.git", "author": "Piyush Garg ", "scripts": { - "local": "dotenv -c local -- npm run prisma:generate && concurrently \"serverless offline --stage local --disableCookieValidation\"", - "migrate:latest": "dotenv -c local -- prisma migrate deploy", - "prisma:migrate:local": "dotenv -c local -- prisma migrate dev", + "local": "dotenv -c development -- npm run prisma:generate && concurrently \"serverless offline --stage development --disableCookieValidation\"", + "migrate:latest": "dotenv -c development -- prisma migrate deploy", + "prisma:migrate:local": "dotenv -c development -- prisma migrate dev", "prisma:generate": "prisma generate", - "prisma:studio": "dotenv -c local -- prisma studio" + "prisma:studio": "dotenv -c development -- prisma studio", + "deploy:prod": "dotenv -c production -- sh scripts/deploy.sh production" }, "devDependencies": { "@types/jsonwebtoken": "^9.0.2", diff --git a/prisma/schema.prisma b/prisma/schema.prisma index 9e9b2ed..5360d08 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -2,7 +2,8 @@ // learn more about it in the docs: https://pris.ly/d/prisma-schema generator client { - provider = "prisma-client-js" + provider = "prisma-client-js" + binaryTargets = ["native", "rhel-openssl-1.0.x"] } datasource db { diff --git a/scripts/deploy.sh b/scripts/deploy.sh new file mode 100644 index 0000000..c5e5077 --- /dev/null +++ b/scripts/deploy.sh @@ -0,0 +1,10 @@ +STAGE="$1" + +echo "[$STAGE]: Migrate Primsa" +dotenv -c $STAGE -- prisma migrate deploy + +echo "[$STAGE]: Generate Primsa Client" +npm run prisma:generate + +echo "[$STAGE]: Start Serverless Deployment" +sls deploy --stage $STAGE diff --git a/serverless.yml b/serverless.yml index 6694be0..79e86fa 100644 --- a/serverless.yml +++ b/serverless.yml @@ -27,7 +27,7 @@ provider: timeout: 25 lambdaHashingVersion: 20201221 region: ap-south-1 - profile: default + profile: melonreviews environment: STAGE: ${self:provider.stage} NODE_ENV: ${self:provider.stage}