-
Notifications
You must be signed in to change notification settings - Fork 1
[Feature/#160] - 서버 인프라 구성 #174
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
3f76f80
08bc757
7727cf9
7064e83
2dd3e2c
439d4ee
b3ceafb
b8e6d55
0a17e75
d31101c
f1b5493
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| name: Deployment Nestjs server (Dev) | ||
|
|
||
| on: | ||
| push: | ||
| branches: [development] | ||
|
|
||
| jobs: | ||
| build-and-deploy: | ||
| name: Build and Deploy to EC2 | ||
| runs-on: [self-hosted, nest-dev] | ||
|
|
||
| steps: | ||
| - name: Checkout source code | ||
| uses: actions/checkout@v3 | ||
| - name: install dependencies | ||
| run: | | ||
| corepack enable | ||
| yarn install | ||
|
|
||
| - name: Run Docker Compose | ||
| env: | ||
| DATABASE_HOST_DEV: ${{ secrets.DATABASE_HOST_DEV }} | ||
| DATABASE_USERNAME_DEV: ${{ secrets.DATABASE_USERNAME_DEV }} | ||
| DATABASE_PASSWORD_DEV: ${{ secrets.DATABASE_PASSWORD_DEV }} | ||
| DATABASE_ROOT_PASSWORD_DEV: ${{ secrets.DATABASE_ROOT_PASSWORD_DEV }} | ||
| REDIS_HOST_DEV: ${{ secrets.REDIS_HOST_DEV }} | ||
|
|
||
| run: | | ||
| yarn types:build | ||
| docker system prune -f | ||
| docker compose -f ./compose.server.dev.yaml down || true | ||
| docker compose -f ./compose.server.dev.yaml up -d --build |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| name: Deployment Nestjs server (Prod) | ||
|
|
||
| on: | ||
| push: | ||
| branches: [main] | ||
|
|
||
| jobs: | ||
| build-and-deploy: | ||
| name: Build and Deploy to EC2 | ||
| runs-on: [self-hosted, nest-prod] | ||
|
|
||
| steps: | ||
| - name: Checkout source code | ||
| uses: actions/checkout@v3 | ||
| - name: install dependencies | ||
| run: | | ||
| corepack enable | ||
| yarn install | ||
|
|
||
| - name: Run Docker Compose | ||
| env: | ||
| DATABASE_HOST_PROD: ${{ secrets.DATABASE_HOST_PROD }} | ||
| DATABASE_USERNAME_PROD: ${{ secrets.DATABASE_USERNAME_PROD }} | ||
| DATABASE_PASSWORD_PROD: ${{ secrets.DATABASE_PASSWORD_PROD }} | ||
| DATABASE_ROOT_PASSWORD_PROD: ${{ secrets.DATABASE_ROOT_PASSWORD_PROD }} | ||
| REDIS_HOST_PROD: ${{ secrets.REDIS_HOST_PROD }} | ||
|
|
||
| run: | | ||
| yarn types:build | ||
| docker system prune -f | ||
| docker compose -f ./compose.server.prod.yaml down || true | ||
| docker compose -f ./compose.server.prod.yaml up -d --build |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| name: Claude PR Review | ||
| on: | ||
| pull_request: | ||
| types: [opened, synchronize] | ||
| branches: [development] | ||
|
|
||
| jobs: | ||
| review: | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| contents: read | ||
| pull-requests: write | ||
| id-token: write | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| with: | ||
| fetch-depth: 1 | ||
|
|
||
| - uses: anthropics/claude-code-action@v1 | ||
| with: | ||
| anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }} | ||
| track_progress: true | ||
| prompt: | | ||
| REPO: ${{ github.repository }} | ||
| PR NUMBER: ${{ github.event.pull_request.number }} | ||
|
|
||
| Please review this pull request with a focus on: | ||
| - Code quality and best practices | ||
| - Potential bugs or issues | ||
| - Security implications | ||
| - Performance considerations | ||
|
|
||
| NOTE: The PR branch is already checked out in the current working directory. | ||
| NOTE: write your review in Korean. | ||
|
|
||
| Use `gh pr comment` for top-level feedback. | ||
| Use `mcp__github_inline_comment__create_inline_comment` to highlight specific code issues. | ||
| Only post GitHub comments - don't submit review text as messages. | ||
|
|
||
| claude_args: | | ||
| --allowedTools "mcp__github_inline_comment__create_inline_comment,Bash(gh pr comment:*),Bash(gh pr diff:*),Bash(gh pr view:*)" |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -27,6 +27,7 @@ export default function DashboardScreen() { | |||||
| <WebView | ||||||
| ref={webviewRef as any} | ||||||
| source={{ uri: `${process.env.EXPO_PUBLIC_CLIENT_URL}/dashboard` }} | ||||||
| userAgent="Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.103 Safari/537.36" | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Similar to the
Suggested change
|
||||||
| javaScriptEnabled={true} | ||||||
| originWhitelist={["*"]} | ||||||
| injectedJavaScriptBeforeContentLoaded={runFirst} | ||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| FROM node:22-alpine | ||
|
|
||
| WORKDIR /app | ||
|
|
||
| RUN corepack enable | ||
|
|
||
| COPY . . | ||
|
|
||
| RUN yarn install | ||
|
|
||
| WORKDIR /app/apps/kokomen-server | ||
|
|
||
| RUN yarn types:build | ||
|
|
||
| WORKDIR /app | ||
| CMD ["yarn", "server:start"] |
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| worker_processes auto; | ||
|
|
||
| events { | ||
| worker_connections 1024; | ||
| } | ||
|
|
||
|
|
||
| http { | ||
| charset utf-8; | ||
|
|
||
| log_format main '$request_id $remote_addr - $remote_user [$time_local] "$request" ' | ||
| '$status $body_bytes_sent "$http_referer" "$request_time" ' | ||
| '"$http_user_agent" "$http_x_forwarded_for" ' | ||
| '"$ssl_protocol/$ssl_cipher" "$content_length" "$request_length"'; | ||
| access_log /var/log/nginx/access.log main; | ||
|
|
||
| upstream kokomen-graphql-api-dev { | ||
| server kokomen-nest-server-dev:3000; | ||
| } | ||
|
|
||
| server { | ||
| listen 80; | ||
|
|
||
| set_real_ip_from 10.0.0.0/16; | ||
| set_real_ip_from 43.203.50.14; | ||
| real_ip_header X-Forwarded-For; | ||
| real_ip_recursive on; | ||
|
|
||
| server_name api-dev.kokomen.kr localhost; | ||
| server_tokens off; | ||
|
|
||
| location /api/v3 { | ||
| proxy_pass http://kokomen-graphql-api-dev; | ||
| proxy_set_header Host $host; | ||
| proxy_set_header X-Real-IP $remote_addr; | ||
| proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | ||
| proxy_set_header X-RequestID $request_id; | ||
| } | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| worker_processes auto; | ||
|
|
||
| events { | ||
| worker_connections 1024; | ||
| } | ||
|
|
||
|
|
||
| http { | ||
| charset utf-8; | ||
|
|
||
| log_format main '$request_id $remote_addr - $remote_user [$time_local] "$request" ' | ||
| '$status $body_bytes_sent "$http_referer" "$request_time" ' | ||
| '"$http_user_agent" "$http_x_forwarded_for" ' | ||
| '"$ssl_protocol/$ssl_cipher" "$content_length" "$request_length"'; | ||
| access_log /var/log/nginx/access.log main; | ||
|
|
||
| upstream kokomen-graphql-api-prod { | ||
| server kokomen-nest-server-prod:3000; | ||
| } | ||
|
|
||
| server { | ||
| listen 80; | ||
|
|
||
| set_real_ip_from 10.0.0.0/16; | ||
| set_real_ip_from 43.203.50.14; | ||
| real_ip_header X-Forwarded-For; | ||
| real_ip_recursive on; | ||
|
|
||
| server_name api-dev.kokomen.kr localhost; | ||
| server_tokens off; | ||
|
|
||
| location /api/v3 { | ||
| proxy_pass http://kokomen-graphql-api-prod; | ||
| proxy_set_header Host $host; | ||
| proxy_set_header X-Real-IP $remote_addr; | ||
| proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | ||
| proxy_set_header X-RequestID $request_id; | ||
|
|
||
| } | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,18 +1,19 @@ | ||
| // src/redis/redis.module.ts | ||
| import { Module, Global } from "@nestjs/common"; | ||
| import { ConfigService } from "@nestjs/config"; | ||
| import Redis from "ioredis"; | ||
|
|
||
| @Global() | ||
| @Module({ | ||
| providers: [ | ||
| { | ||
| provide: "REDIS_CLIENT", | ||
| useFactory: (configService: ConfigService): Redis => { | ||
| useFactory: (): Redis => { | ||
| const redis = new Redis({ | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| host: configService.get("REDIS_HOST", "127.0.0.1"), | ||
| port: configService.get("REDIS_PORT", 6379), | ||
| password: configService.get("REDIS_PASSWORD", ""), | ||
| host: process.env.REDIS_HOST, | ||
| port: process.env.REDIS_PORT | ||
| ? parseInt(process.env.REDIS_PORT, 10) | ||
| : 6379, | ||
| password: process.env.REDIS_PASSWORD || "", | ||
|
|
||
| enableReadyCheck: false, | ||
| lazyConnect: false, | ||
|
|
@@ -45,7 +46,7 @@ import Redis from "ioredis"; | |
|
|
||
| return redis; | ||
| }, | ||
| inject: [ConfigService] | ||
| inject: [] | ||
| } | ||
| ], | ||
| exports: ["REDIS_CLIENT"] | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| services: | ||
| kokomen-nest-server-dev: | ||
| build: | ||
| context: . | ||
| dockerfile: ./apps/kokomen-server/Dockerfile | ||
| environment: | ||
| TZ: Asia/Seoul | ||
| NODE_ENV: development | ||
| DATABASE_HOST: ${DATABASE_HOST_DEV} | ||
| DATABASE_PORT: 3306 | ||
| DATABASE_USERNAME: ${DATABASE_USERNAME_DEV} | ||
| DATABASE_PASSWORD: ${DATABASE_PASSWORD_DEV} | ||
| DATABASE_ROOT_PASSWORD: ${DATABASE_ROOT_PASSWORD_DEV} | ||
| DATABASE_DATABASE: kokomen-dev | ||
| REDIS_HOST: ${REDIS_HOST_DEV} | ||
| REDIS_PORT: 6379 | ||
| PORT: 3000 | ||
| container_name: kokomen-nest-server-dev | ||
| restart: on-failure:3 | ||
| ports: | ||
| - "3000:3000" | ||
| - "3001:3001" | ||
|
|
||
| nginx: | ||
| image: nginx:alpine | ||
| container_name: kokomen-nest-nginx-dev | ||
| ports: | ||
| - "80:80" | ||
| - "443:443" | ||
| volumes: | ||
| - ./apps/kokomen-server/nginx/dev/nginx.conf:/etc/nginx/nginx.conf:ro | ||
| depends_on: | ||
| - kokomen-nest-server-dev | ||
| restart: unless-stopped | ||
| environment: | ||
| TZ: Asia/Seoul |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adding a hardcoded user agent string can be problematic. It would be better to either dynamically generate this based on the platform or use a configuration value. This increases maintainability and avoids issues if the user agent needs to be updated in the future.
Consider using
react-native-device-infoto get the device's user agent.