-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor codebase and update dependencies
- Loading branch information
1 parent
04acfe5
commit 378c20a
Showing
48 changed files
with
3,828 additions
and
9,878 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
SSH_HOST=${SSH_HOST} | ||
SSH_PORT=${SSH_PORT} | ||
SSH_USERNAME=${SSH_USERNAME} | ||
SSH_PASSWORD=${SSH_PASSWORD} | ||
DATABASE_HOST=${DATABASE_HOST} | ||
DATABASE_PORT=${DATABASE_PORT} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,5 @@ | ||
# MySQL | ||
MYSQL_HOST=${MYSQL_HOST} | ||
MYSQL_PORT=${MYSQL_PORT} | ||
MYSQL_USER=${MYSQL_USER} | ||
MYSQL_PASSWORD=${MYSQL_PASSWORD} | ||
MYSQL_DATABASE=${MYSQL_DATABASE} | ||
|
||
# JWT | ||
JWT_SECRET=${JWT_SECRET} | ||
|
||
# Secret | ||
AES_SECRET=${AES_SECRET} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,4 @@ | ||
* linguist-vendored | ||
src/* linguist-vendored=false | ||
scheme/* linguist-vendored=false | ||
.github/* linguist-vendored=false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
--- | ||
name: Development Deployment | ||
|
||
on: | ||
push: | ||
branches: | ||
- deploy/dev | ||
|
||
jobs: | ||
deployment: | ||
name: Deployment | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout Code | ||
uses: actions/checkout@v4 | ||
|
||
- name: Set tag | ||
id: vars | ||
run: echo "rev_sha=$(git rev-parse HEAD)" >> "$GITHUB_OUTPUT" | ||
|
||
- name: Configure AWS credentials | ||
uses: aws-actions/configure-aws-credentials@v4 | ||
with: | ||
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | ||
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | ||
aws-region: ap-northeast-2 | ||
|
||
- name: Login to Amazon ECR | ||
id: login-ecr | ||
uses: aws-actions/amazon-ecr-login@v2 | ||
with: | ||
mask-password: 'false' | ||
|
||
- name: Build, tag, and push image to Amazon ECR | ||
id: build-image | ||
env: | ||
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} | ||
ECR_REPOSITORY: api-ecr | ||
IMAGE_TAG: ${{ steps.vars.outputs.rev_sha }} | ||
NODE_ENV: development | ||
JWT_SECRET: ${{ secrets.JWT_SECRET }} | ||
AES_SECRET: ${{ secrets.AES_SECRET }} | ||
|
||
run: | | ||
cat .env.example | envsubst > .env | ||
cat .env | ||
ls -al | ||
printenv | ||
echo $ECR_REGISTRY | ||
echo $ECR_REPOSITORY | ||
echo $IMAGE_TAG | ||
docker build --build-arg ENV=development -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG -f Dockerfile.development . | ||
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG | ||
echo "image=$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG" >> "$GITHUB_OUTPUT" | ||
- name: Download task definition | ||
run: | | ||
aws ecs describe-task-definition --task-definition 'api-service' --query taskDefinition > task-definition.json | ||
echo $(jq '.cpu = $CPU_VALUE' --arg CPU_VALUE 1024 task-definition.json) > task-definition.json | ||
echo $(jq '.memory = $MEMORY_VALUE' --arg MEMORY_VALUE 2048 task-definition.json) > task-definition.json | ||
- name: Fill in the new image ID in the Amazon ECS task definition | ||
id: task-def | ||
uses: aws-actions/amazon-ecs-render-task-definition@v1 | ||
with: | ||
task-definition: task-definition.json | ||
container-name: api-application | ||
image: ${{ steps.build-image.outputs.image }} | ||
|
||
- name: Deploy Amazon ECS task definition | ||
uses: aws-actions/amazon-ecs-deploy-task-definition@v1 | ||
with: | ||
task-definition: ${{ steps.task-def.outputs.task-definition }} | ||
service: api-service | ||
cluster: api-cluster | ||
wait-for-service-stability: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
--- | ||
name: Production Deployment | ||
|
||
on: | ||
push: | ||
branches: | ||
- deploy/prod | ||
|
||
jobs: | ||
deployment: | ||
name: Deployment | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout Code | ||
uses: actions/checkout@v4 | ||
|
||
- name: Set tag | ||
id: vars | ||
run: echo "rev_sha=$(git rev-parse HEAD)" >> "$GITHUB_OUTPUT" | ||
|
||
- name: Configure AWS credentials | ||
uses: aws-actions/configure-aws-credentials@v4 | ||
with: | ||
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | ||
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | ||
aws-region: ap-northeast-2 | ||
|
||
- name: Login to Amazon ECR | ||
id: login-ecr | ||
uses: aws-actions/amazon-ecr-login@v2 | ||
with: | ||
mask-password: 'false' | ||
|
||
- name: Build, tag, and push image to Amazon ECR | ||
id: build-image | ||
env: | ||
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} | ||
ECR_REPOSITORY: api-ecr | ||
IMAGE_TAG: ${{ steps.vars.outputs.rev_sha }} | ||
NODE_ENV: production | ||
JWT_SECRET: ${{ secrets.JWT_SECRET }} | ||
AES_SECRET: ${{ secrets.AES_SECRET }} | ||
|
||
run: | | ||
cat .env.example | envsubst > .env | ||
cat .env | ||
ls -al | ||
printenv | ||
echo $ECR_REGISTRY | ||
echo $ECR_REPOSITORY | ||
echo $IMAGE_TAG | ||
docker build --build-arg ENV=production -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG -f Dockerfile . | ||
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG | ||
echo "image=$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG" >> "$GITHUB_OUTPUT" | ||
- name: Download task definition | ||
run: | | ||
aws ecs describe-task-definition --task-definition 'api-service' --query taskDefinition > task-definition.json | ||
echo $(jq '.cpu = $CPU_VALUE' --arg CPU_VALUE 1024 task-definition.json) > task-definition.json | ||
echo $(jq '.memory = $MEMORY_VALUE' --arg MEMORY_VALUE 2048 task-definition.json) > task-definition.json | ||
- name: Fill in the new image ID in the Amazon ECS task definition | ||
id: task-def | ||
uses: aws-actions/amazon-ecs-render-task-definition@v1 | ||
with: | ||
task-definition: task-definition.json | ||
container-name: api-application | ||
image: ${{ steps.build-image.outputs.image }} | ||
|
||
- name: Deploy Amazon ECS task definition | ||
uses: aws-actions/amazon-ecs-deploy-task-definition@v1 | ||
with: | ||
task-definition: ${{ steps.task-def.outputs.task-definition }} | ||
service: api-service | ||
cluster: api-cluster | ||
wait-for-service-stability: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
name: Integration | ||
|
||
on: | ||
workflow_dispatch: | ||
pull_request: | ||
push: | ||
branches: | ||
- main | ||
- dev | ||
|
||
jobs: | ||
integration: | ||
name: Integration | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout Code | ||
uses: actions/checkout@v4 | ||
|
||
- name: Use Node.js | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: 20.9.0 | ||
|
||
- name: Install packages | ||
run: | | ||
npm install | ||
- name: Run lint | ||
run: | | ||
npm run lint:check | ||
- name: Run unit tests with coverage | ||
run: | | ||
npm run test:cov | ||
- name: Run build | ||
run: | | ||
npm run build | ||
- name: Upload coverage reports to Codecov | ||
uses: codecov/codecov-action@v4 | ||
env: | ||
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,3 +40,5 @@ data | |
# Environment variables | ||
.env* | ||
!.env.example | ||
.docker.env* | ||
!.docker.env.example |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<component name="ProjectRunConfigurationManager"> | ||
<configuration default="false" name="Local" type="docker-deploy" factoryName="docker-compose.yml" server-name="Docker"> | ||
<deployment type="docker-compose.yml"> | ||
<settings> | ||
<option name="envFilePath" value="" /> | ||
<option name="sourceFilePath" value="docker-compose.local.yaml" /> | ||
<option name="upDetach" value="false" /> | ||
</settings> | ||
</deployment> | ||
<method v="2" /> | ||
</configuration> | ||
</component> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
FROM node:20-alpine AS deps | ||
WORKDIR /app | ||
COPY ["package.json", "package-lock.json", "./"] | ||
RUN ["npm", "install"] | ||
|
||
FROM node:20-alpine AS builder | ||
WORKDIR /app | ||
COPY ["tsconfig.build.json", "tsconfig.json", "./"] | ||
COPY ["src/", "./src/"] | ||
COPY [".env", "./"] | ||
COPY --from=deps /app/node_modules ./node_modules | ||
RUN ["npx", "nest", "build"] | ||
|
||
FROM node:20-alpine AS runner | ||
WORKDIR /app | ||
COPY --from=builder /app/dist ./dist | ||
COPY --from=builder /app/node_modules ./node_modules | ||
COPY --from=builder /app/.env ./ | ||
RUN apk update && \ | ||
apk add --no-cache chromium fontconfig font-noto-cjk && \ | ||
fc-cache -f -v | ||
ENV CHROMIUM_LINUX_PATH /usr/bin/chromium-browser | ||
ENV NODE_ENV="development" | ||
CMD ["node", "dist/main"] | ||
|
||
EXPOSE 80 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
services: | ||
server: | ||
build: | ||
dockerfile: Dockerfile.local | ||
context: ./ | ||
container_name: api | ||
restart: unless-stopped | ||
depends_on: | ||
- sshtunnel | ||
ports: | ||
- '80:80' | ||
volumes: | ||
- ./src:/app/src | ||
command: | ||
- "npm" | ||
- "run" | ||
- "start:local:dev" | ||
|
||
sshtunnel: | ||
container_name: sshtunnel | ||
image: jossec101/sshtunneller | ||
expose: | ||
- 25001 # database | ||
environment: | ||
- "ssh_host=${SSH_HOST}" | ||
- "ssh_port=${SSH_PORT}" | ||
- "ssh_username=${SSH_USERNAME}" | ||
- "ssh_password=${SSH_PASSWORD}" | ||
- "remote_bind_addresses=[('${DATABASE_HOST}', ${DATABASE_PORT})]" | ||
- "local_bind_addresses=[('0.0.0.0', 25001)]" | ||
logging: | ||
driver: "json-file" | ||
options: | ||
max-size: "20m" | ||
max-file: "3" | ||
restart: unless-stopped |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.