Skip to content

Commit f8288a7

Browse files
committed
Initail commit
0 parents  commit f8288a7

File tree

82 files changed

+13790
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

82 files changed

+13790
-0
lines changed

.cspell/aws.txt

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
firelens
2+
fargate
3+
nacl
4+
cloudfront
5+
cloudwatch
6+
codebuild
7+
codepipeline
8+
cognito
9+
cidr
10+
secretsmanager
11+
customresources
12+
amazonaws
13+
apigateway
14+
buildspec

.cspell/middleware.txt

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
fluentbit

.cspell/mysql.txt

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
autocommit
2+
slowquery
3+
mysqld
4+
infile

.cspell/node.txt

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
nestjs
2+
wafv2
3+
elasticloadbalancingv
4+
deregistration
5+
elbv
6+
kysely
7+
graphql
8+
datasource
9+
biomejs

.dockerignore

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
*
2+
!packages/server/package.json
3+
!packages/server/tsconfig.build.json
4+
!packages/server/tsconfig.json
5+
!packages/server/schema.prisma
6+
!packages/server/.env
7+
!packages/server/src
8+
!pnpm-lock.yaml
9+
!pnpm-workspace.yaml
10+
!package.json
11+
!.eslintrc.json
12+
!schema.graphql

.github/CODEOWNERS

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* @shuntaka9576 @tomoki10
+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
---
2+
name: Feature request
3+
about: このリポジトリに追加して欲しい機能やドキュメントなどを記載
4+
title: ''
5+
labels: enhancement
6+
assignees: ''
7+
8+
---
9+
10+
## 機能概要
11+
12+
## 解決策
13+
14+
## 参考情報

.github/actions/setup-node/action.yml

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: Setup node
2+
description: Setup Node and restore cache
3+
4+
runs:
5+
using: 'composite'
6+
steps:
7+
- uses: actions/setup-node@v4
8+
with:
9+
node-version-file: './.node-version'
10+
11+
- uses: pnpm/action-setup@v4
12+
13+
- name: Restore node modules
14+
uses: actions/cache@v4
15+
id: cache_dependency
16+
env:
17+
cache-name: cache-dependency
18+
with:
19+
path: '**/node_modules'
20+
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('pnpm-lock.yaml') }}
21+
22+
- name: Install node modules
23+
if: ${{ steps.cache_dependency.outputs.cache-hit != 'true' }}
24+
shell: bash
25+
run: pnpm install --frozen-lockfile

.github/dependabot.yml

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: npm
4+
directory: /
5+
schedule:
6+
# MEMO: daily だとアクティブに開発をしていない期間に PR の作成頻度が過剰となるため、weekly を指定。
7+
interval: weekly
8+
groups:
9+
minor-and-patch:
10+
patterns:
11+
- '*'
12+
update-types:
13+
- minor
14+
- patch
+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
name: ADD_ISSUE_TO_PROJECT
2+
3+
on:
4+
issues:
5+
types:
6+
- opened
7+
8+
jobs:
9+
add-to-project:
10+
name: Add issue to project
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/[email protected]
14+
with:
15+
project-url: https://github.com/orgs/cm-cxlabs/projects/2
16+
github-token: ${{ secrets.ADD_TO_PROJECT_PAT }}

.github/workflows/ci.yml

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: CI
2+
3+
on: [push]
4+
5+
jobs:
6+
ci:
7+
runs-on: ubuntu-latest
8+
timeout-minutes: 30
9+
environment: ${{ inputs.stageName }}
10+
steps:
11+
- name: Checkout
12+
uses: actions/checkout@v4
13+
14+
- name: Setup node
15+
uses: ./.github/actions/setup-node
16+
17+
- name: CI
18+
shell: bash
19+
run: |
20+
pnpm run lint
21+
pnpm run test

.github/workflows/deploy.yml

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: DEPLOY_INFRA
2+
3+
env:
4+
TZ: 'Asia/Tokyo'
5+
6+
on:
7+
push:
8+
branches:
9+
- main
10+
paths:
11+
- packages/server/**
12+
- packages/iac/**
13+
- .github/workflows/workflow-create-container.yml
14+
- .github/workflows/workflow-deploy-infra.yml
15+
- .github/workflows/deploy.yml
16+
- pnpm-lock.yaml
17+
18+
jobs:
19+
build-container:
20+
name: build container dev
21+
uses: ./.github/workflows/workflow-create-container.yml
22+
with:
23+
stageName: dev
24+
imageName: icasu-ecs-fargate-sample-app
25+
secrets: inherit
26+
27+
deploy-infra:
28+
name: deploy infra dev
29+
uses: ./.github/workflows/workflow-deploy-infra.yml
30+
needs:
31+
- build-container
32+
with:
33+
stageName: dev
34+
secrets: inherit
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
name: WORK_FLOW_CREATE_CONTAINER
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
stageName:
7+
required: true
8+
type: string
9+
imageName:
10+
required: true
11+
type: string
12+
13+
env:
14+
PROJECT_NAME: icasu-ecs-fargate
15+
CACHE_PATH: /tmp/.buildx-cache-icasu-ecs-fargate-sample-app
16+
17+
permissions:
18+
id-token: write
19+
contents: read
20+
actions: read
21+
22+
jobs:
23+
create-container:
24+
runs-on: ubuntu-latest
25+
timeout-minutes: 30
26+
environment: ${{ inputs.stageName }}
27+
28+
steps:
29+
- name: Checkout
30+
uses: actions/checkout@v4
31+
- name: Set up Docker Buildx
32+
uses: docker/setup-buildx-action@v3
33+
- name: Cache Docker layers
34+
uses: actions/cache@v4
35+
with:
36+
path: ${{ env.CACHE_PATH }}
37+
key: ${{ runner.os }}-${{ env.CACHE_PATH }}-${{ github.sha }}
38+
restore-keys: |
39+
${{ runner.os }}-${{ env.CACHE_PATH }}
40+
- name: Create tag
41+
run: |
42+
COMMIT_HASH=$(git rev-parse --short "$GITHUB_SHA")
43+
TAG=${{ vars.AWS_ACCOUNT_ID }}.dkr.ecr.ap-northeast-1.amazonaws.com/${{ inputs.imageName }}:$COMMIT_HASH
44+
echo "TAGS=$TAG" >> $GITHUB_ENV
45+
- name: Configure AWS credentials
46+
uses: aws-actions/configure-aws-credentials@v4
47+
with:
48+
role-to-assume: arn:aws:iam::${{ vars.AWS_ACCOUNT_ID }}:role/${{ env.PROJECT_NAME }}-assume-role
49+
aws-region: ap-northeast-1
50+
- name: Login to Amazon ECR
51+
uses: aws-actions/amazon-ecr-login@v2
52+
- name: Build and push
53+
uses: docker/build-push-action@v6
54+
with:
55+
context: .
56+
tags: ${{ env.TAGS }}
57+
push: true
58+
platforms: linux/amd64
59+
file: Dockerfile.server
60+
provenance: false
61+
cache-from: type=local,src=${{ env.CACHE_PATH }}
62+
cache-to: type=local,dest=${{ env.CACHE_PATH }}-new,mode=max
63+
- name: Move cache
64+
run: |
65+
rm -rf ${{ env.CACHE_PATH }}
66+
mv ${{ env.CACHE_PATH }}-new ${{ env.CACHE_PATH }}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
name: WORK_FLOW_DEPLOY_INFRA
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
stageName:
7+
required: true
8+
type: string
9+
env:
10+
PROJECT_NAME: icasu-ecs-fargate
11+
12+
permissions:
13+
id-token: write
14+
contents: read
15+
actions: read
16+
17+
jobs:
18+
deploy-infra:
19+
runs-on: ubuntu-latest
20+
timeout-minutes: 30
21+
environment: ${{ inputs.stageName }}
22+
23+
steps:
24+
- name: Checkout
25+
uses: actions/checkout@v4
26+
27+
- name: Setup node
28+
uses: ./.github/actions/setup-node
29+
30+
- name: Configure AWS credentials
31+
uses: aws-actions/configure-aws-credentials@v4
32+
with:
33+
role-to-assume: arn:aws:iam::${{ vars.AWS_ACCOUNT_ID }}:role/${{ env.PROJECT_NAME }}-assume-role
34+
aws-region: ap-northeast-1
35+
36+
- name: Create deploy container hash
37+
shell: bash
38+
run: |
39+
COMMIT_HASH=$(git rev-parse --short "$GITHUB_SHA")
40+
echo "imageTag=$COMMIT_HASH" >> $GITHUB_ENV
41+
42+
- name: Deploy infra
43+
shell: bash
44+
run: |
45+
export CDK_DEFAULT_ACCOUNT=${{ vars.AWS_ACCOUNT_ID }}
46+
export CDK_DEFAULT_REGION="ap-northeast-1"
47+
48+
cd ./packages/iac
49+
50+
pnpm cdk deploy \
51+
-c environment=${{ inputs.stageName }} \
52+
${{ inputs.stageName }}-${{ env.PROJECT_NAME }}-deploy-role-stack \
53+
--require-approval never
54+
pnpm cdk deploy \
55+
-c environment=${{ inputs.stageName }} \
56+
${{ inputs.stageName }}-${{ env.PROJECT_NAME }}-ecr-stack \
57+
--require-approval never
58+
pnpm cdk deploy \
59+
-c environment=${{ inputs.stageName }} \
60+
-c imageTag=${{ env.imageTag }} \
61+
${{ inputs.stageName }}-${{ env.PROJECT_NAME }}-infra-stack \
62+
--require-approval never

.gitignore

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
*.js
2+
!jest.config.js
3+
!.eslintrc.js
4+
*.d.ts
5+
node_modules
6+
7+
# CDK asset staging directory
8+
.cdk.staging
9+
cdk.out
10+
11+
# サンプルコード開発用の環境設定をコミットしないためcdk.context.jsonはコミット対象外としている
12+
# 開発で利用する場合は削除すること
13+
cdk.context.json
14+
15+
.cspellcache

.node-version

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
20.9.0

.npmrc

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
engine-strict=true
2+
save-exact=true

.vscode/settings.json

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"editor.formatOnSave": true,
3+
"editor.defaultFormatter": "biomejs.biome",
4+
"editor.codeActionsOnSave": {
5+
"source.organizeImports.biome": "explicit",
6+
"quickfix.biome": "explicit"
7+
}
8+
}

Dockerfile.server

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
./packages/server/Dockerfile

0 commit comments

Comments
 (0)