add deploy script

This commit is contained in:
falsycat 2025-06-21 10:10:53 +09:00
parent 82b6a7a718
commit 89edcce799
8 changed files with 47 additions and 8 deletions

18
backend/deploy.sh Executable file
View File

@ -0,0 +1,18 @@
#!/bin/bash
set -e
tmpdir=$(mktemp -d)
trap 'rm -rf "$tmpdir"' EXIT
cd $(dirname $0)/dist
zip -r "$tmpdir/lambda.zip" .
cd $tmpdir
aws s3 cp lambda.zip "s3://$IMBUSY_BE_BUCKET"
cd $(dirname $0)
aws lambda update-function-code \
--function-name $IMBUSY_BE_LAMBDA \
--s3-bucket $IMBUSY_BE_BUCKET \
--s3-key lambda.zip

View File

@ -6,7 +6,8 @@
"scripts": {
"build": "esbuild src/index.ts --bundle --platform=node --target=node18 --outfile=dist/index.js",
"clean": "rm -rf dist",
"watch": "npm run build -- --watch"
"watch": "npm run build -- --watch",
"deploy": "./deploy.sh"
},
"keywords": [],
"author": "",

View File

@ -22,8 +22,7 @@ phases:
post_build:
commands:
- echo deploying frontend...
- aws s3 sync frontend/dist/ s3://$IMBUSY_FE_BUCKET --delete
- cd frontend && npm run deploy && cd ..
- echo deploying backend...
- cd backend/dist && zip -r ../../backend.zip . && cd ../..
- aws s3 cp backend.zip s3://$IMBUSY_BE_BUCKET
- cd backend && npm run deploy && cd ..

6
frontend/deploy.sh Executable file
View File

@ -0,0 +1,6 @@
#!/bin/bash
set -e
cd $(dirname $0)/dist
aws s3 sync . "s3://$IMBUSY_FE_BUCKET" --delete

View File

@ -7,7 +7,8 @@
"dev": "vite",
"build": "tsc -b && vite build",
"lint": "eslint .",
"preview": "vite preview"
"preview": "vite preview",
"deploy": "./deploy.sh"
},
"dependencies": {
"react": "^19.1.0",

View File

@ -23,7 +23,7 @@ new aws.iam.RolePolicyAttachment(`${prefix}-lambda-role-exec`, {
policyArn: aws.iam.ManagedPolicies.AWSLambdaBasicExecutionRole,
});
const lambda = new aws.lambda.Function(`${prefix}-lambda`, {
export const lambda = new aws.lambda.Function(`${prefix}-lambda`, {
tags,
runtime: "nodejs18.x",
handler: "index.main",

View File

@ -6,5 +6,8 @@ import * as frontend from "./frontend";
import "./deployment";
export const frontendDomain = frontend.cloudfront.domainName;
export const backendEndpoint = backend.api.apiEndpoint;
export const feBucket = frontend.bucket.bucket;
export const feDomain = frontend.cloudfront.domainName;
export const beBucket = backend.bucket.bucket;
export const beLambda = backend.lambda.name;
export const beEndpoint = backend.api.apiEndpoint;

11
setenv Normal file
View File

@ -0,0 +1,11 @@
#!/bin/bash
cd $(dirname $0)
cd infra/
export IMBUSY_BE_BUCKET=$(pulumi stack output beBucket)
export IMBUSY_BE_LAMBDA=$(pulumi stack output beLambda)
export IMBUSY_FE_BUCKET=$(pulumi stack output feBucket)
cd ../