Skip to content

Commit 277f79b

Browse files
authored
엔티티 리팩터링 및 docker-compose (#24)
* chore: add .gitattributes to enforce LF line endings * refactor: group entity * refactor: problem entity * refactor: reorganize module imports and update paths * feat: docker-compose.yml * feat: add module name mapping in jest
1 parent f3e7e45 commit 277f79b

60 files changed

Lines changed: 217 additions & 195 deletions

Some content is hidden

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

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* text eol=lf

.github/workflows/publish-deploy.yml

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -81,20 +81,13 @@ jobs:
8181
steps:
8282
- name: executing remote ssh commands using password
8383
uses: appleboy/ssh-action@v1.0.3
84+
env:
85+
PORT: ${{ secrets.ENV_PORT }}
8486
with:
8587
host: ${{ secrets.SSH_HOST }}
88+
port: ${{ secrets.SSH_PORT }}
8689
username: ${{ secrets.SSH_USERNAME }}
8790
password: ${{ secrets.SSH_PASSWORD }}
88-
port: ${{ secrets.SSH_PORT }}
8991
script: |
90-
IMAGE_ID=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
91-
IMAGE_ID=$(echo $IMAGE_ID | tr '[:upper:]' '[:lower:]')
92-
CONTAINER_ID=${{ env.IMAGE_NAME }}
93-
CONTAINER_ID=$(echo "CONTAINER_ID=Code-Poker/CodePoker-be" | sed -E 's#.*/##' | tr '[:upper:]' '[:lower:]')
94-
docker pull $IMAGE_ID:main
95-
docker stop $CONTAINER_ID
96-
docker rm $CONTAINER_ID
97-
docker run -d --name $CONTAINER_ID \
98-
-p 6370:6370 \
99-
--restart=always \
100-
$IMAGE_ID:main
92+
docker-compose pull
93+
docker-compose up -d

Dockerfile

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,4 @@ COPY . .
99
RUN npm install
1010
RUN npm run build
1111

12-
EXPOSE $PORT
13-
1412
CMD [ "npm", "run", "start" ]

docker-compose.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
services:
2+
backend:
3+
image: ghcr.io/code-poker/codepoker-be:main
4+
# build: .
5+
container_name: codepoker-be
6+
restart: unless-stopped
7+
ports:
8+
- ${PORT}:${PORT}
9+
depends_on:
10+
- mongodb
11+
12+
mongodb:
13+
image: mongo
14+
container_name: mongodb
15+
restart: unless-stopped
16+
volumes:
17+
- ./mongo_data:/data/db
18+
healthcheck:
19+
test: echo 'db.stats().ok' | mongosh localhost:27017/test --quiet
20+
interval: 10s
21+
timeout: 10s
22+
retries: 5

eslint.config.mjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ export default tseslint.config(
3131
'@typescript-eslint/no-floating-promises': 'warn',
3232
'@typescript-eslint/no-unsafe-argument': 'warn',
3333
'@typescript-eslint/no-unsafe-call': 'off',
34-
// '@typescript-eslint/no-unsafe-member-access': 'off',
35-
// '@typescript-eslint/no-unsafe-return': 'off',
34+
'@typescript-eslint/no-unsafe-member-access': 'off',
35+
'@typescript-eslint/no-unsafe-return': 'off',
3636
},
3737
},
3838
);

package.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,11 @@
7474
"**/*.(t|j)s"
7575
],
7676
"coverageDirectory": "../coverage",
77-
"testEnvironment": "node"
77+
"testEnvironment": "node",
78+
"moduleNameMapper": {
79+
"^@database/(.*)$": "<rootDir>/database/$1",
80+
"^@entities/(.*)$": "<rootDir>/entities/$1",
81+
"^@modules/(.*)$": "<rootDir>/modules/$1"
82+
}
7883
}
7984
}

src/app.module.ts

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
1+
import { DatabaseModule } from '@database/database.module';
2+
import { BojModule } from '@modules/boj/module';
3+
import { GroupModule } from '@modules/group/module';
4+
import { PokerModule } from '@modules/poker/module';
5+
import { ProblemModule } from '@modules/problem/module';
6+
import { SolvedModule } from '@modules/solved/module';
7+
import { SsuModule } from '@modules/ssu/module';
8+
import { UserModule } from '@modules/user/module';
19
import { CacheInterceptor, CacheModule } from '@nestjs/cache-manager';
210
import { Module } from '@nestjs/common';
311
import { APP_INTERCEPTOR } from '@nestjs/core';
412

5-
import { BojModule } from './boj/boj.module';
6-
import { DatabaseModule } from './database/database.module';
7-
import { GroupModule } from './group/group.module';
8-
import { PokerModule } from './poker/poker.module';
9-
import { ProblemModule } from './problem/problem.module';
10-
import { SolvedModule } from './solved/solved.module';
11-
import { SsuModule } from './ssu/ssu.module';
12-
import { UserModule } from './user/user.module';
13-
1413
@Module({
1514
imports: [
1615
CacheModule.register({
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import { applyDecorators } from '@nestjs/common';
2+
import { ApiQuery } from '@nestjs/swagger';
3+
4+
export function SolvedSearchQuery() {
5+
return applyDecorators(ApiQuery({}), ApiQuery({}), ApiQuery({}));
6+
}
File renamed without changes.

src/config.swagger.ts

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,18 @@
1+
import { BojModule } from '@modules/boj/module';
2+
import { GroupModule } from '@modules/group/module';
3+
import { PokerModule } from '@modules/poker/module';
4+
import { SolvedModule } from '@modules/solved/module';
5+
import { SsuModule } from '@modules/ssu/module';
16
import { INestApplication } from '@nestjs/common';
27
import { DocumentBuilder, SwaggerModule } from '@nestjs/swagger';
38

4-
import { BojModule } from './boj/boj.module';
5-
import { GroupModule } from './group/group.module';
6-
import { PokerModule } from './poker/poker.module';
7-
import { SolvedModule } from './solved/solved.module';
8-
import { SsuModule } from './ssu/ssu.module';
9-
10-
export const configSwagger = (app: INestApplication<any>) => {
9+
export const configSwagger = (app: INestApplication) => {
1110
configCodePoker(app);
1211
configSSUJoon(app);
1312
configSolved(app);
1413
};
1514

16-
const configCodePoker = (app: INestApplication<any>) => {
15+
const configCodePoker = (app: INestApplication) => {
1716
const options = new DocumentBuilder()
1817
.setTitle('코드포커 API')
1918
.setVersion('1.0')
@@ -28,7 +27,7 @@ const configCodePoker = (app: INestApplication<any>) => {
2827
SwaggerModule.setup('api', app, document);
2928
};
3029

31-
const configSSUJoon = (app: INestApplication<any>) => {
30+
const configSSUJoon = (app: INestApplication) => {
3231
const options = new DocumentBuilder()
3332
.setTitle('BaekSSU API')
3433
.setVersion('1.0')

0 commit comments

Comments
 (0)